40分 |
仅供参考:
#include <stdio.h> #include <string.h> FILE *f; int c; void main(int argc,char **argv) { if (argc==3) { if (stricmp(argv[1],"-a")) goto USAGE; f=fopen(argv[2],"a"); if (NULL==f) goto FNULL; goto FOK; } else if (argc==2) { if (0==strcmp(argv[1],"/?")) { USAGE: fprintf(stderr,"Usage: program | tee [-a] file\n"); return; } f=fopen(argv[1],"w"); if (NULL==f) goto FNULL; FOK: while (1) { c=getchar(); if (EOF==c) break; if (EOF==fputc(c,f)) { putchar(c); break; } else { if (EOF==putchar(c)) break; } } fclose(f); } else { FNULL: while (1) { c=getchar(); if (EOF==c) break; if (EOF==putchar(c)) break; } } } console屏幕处理例子程序。终端窗口屏幕处理相关API使用例子。来自MSVC20\SAMPLES\win32\console\ http://download.csdn.net/detail/zhao4zhong1/3461309 |