⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 type4.c

📁 c语言的小编译器,学习的好东东.
💻 C
字号:
/*
 * Program to display a file assuming tab stops are at 4 character
 * Intervals. By redirecting the output from this program to the
 * printer, you may properly print the MICRO-C listings.
 *
 * In MICRO-C, the operation "a && b" is defined as returning zero
 * without evaluating "b" if "a" evaluates to zero, otherwise "b"
 * is evaluated and returned.
 *
 * The statement "j = (chr != '\n') && j+1" shows how && (or ||) may
 * be used to create a very efficent conditional expression in MICRO-C.
 * NOTE that this is not "standard", and is NOT PORTABLE. The more
 * conventional equivalent is: "j = (chr != '\n') ? j+1 : 0"
 *
 * Copyright 1989,1990 Dave Dunfield
 * All rights reserved.
 */
#include \mc\stdio.h

#define TAB_SIZE	4		/* tab spacing */

main(argc, argv)
	int argc;
	char *argv[];
{
	int i, j, chr;
	FILE *fp;

	if(argc < 2)
		abort("\nUse: type4 <filename*>\n");

	for(i=1; i < argc; ++i) {
		if(fp = fopen(argv[i], "r")) {
			j = 0;
			while((chr = getc(fp)) != EOF) {
				if(chr == '\t') {			/* tab */
					do
						putc(' ', stdout);
					while(++j % TAB_SIZE); }
				else {						/* not a tab */
					j = (chr != '\n') && j+1;	/* see opening comment */
					putc(chr, stdout); } }
			fclose(fp); }
		else {
			fputs(argv[i], stderr);
			fputs(": Unable to access\n", stderr); } }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -