|
|
发表于 2006-7-27 17:21:40
|
显示全部楼层
- /* a file copy program. Using library functions in stdio.h to copy one file
- * to another, block-by-block.
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- char s[1024];
- FILE *in, *out;
- in = fopen("test.c","r");
- out = fopen("file.txt", "w");
- int i = 1;
- while( !feof(in) ){
- fgets(s, 1024, in);
- if( feof(in) )
- {
- printf("line %d end of file\n", i);
- [color=red]break;[/color]
- }
- fputs(s, out);
- i = i + 1;
- }
- exit(0);
- }
复制代码 |
|