#include <stdio.h>
#include <string.h>
main()
{char a, str[80]="The quick brown fox jumps over a lazy dog."
FILE*fp;
int i=0;
if((fp=fopen("e: (labc. txt","w+"))==NULL
{printf("Cannot open the file!\n"); exit(0);}
while(str[i]) { putc(str[i],fp);i++;)
putc(OxFF,fp);
rewind(fp);
a=getc(fp);
while(a!=EOF) {putchar(a);a=getc(fp);}
putchar(’\n’);
fclose(fp);
system("pause") ;
}
修改如下,供参考:
#include <stdio.h>
#include <string.h>
int main()
{
char a, str[80]="The quick brown fox jumps over a lazy dog.";//;
FILE *fp;
int i=0;
if((fp=fopen("d:\\labc. txt","w+"))==NULL)// if((fp=fopen("e: (labc. txt","w+"))==NULL
{
printf("Cannot open the file!\n");
exit(0);
}
while(str[i]) {
fputc(str[i],fp);//putc( )
i++;
} //)
fputc(0xFF,fp);//putc(OxFF,fp);
rewind(fp);
a=fgetc(fp); //getc()
while(a!=EOF) {
putchar(a);
a=fgetc(fp);
}
putchar('\n');
fclose(fp);
system("pause") ;
return 0;
}
if((fp=fopen("e: (labc. txt","w+"))==NULL) //少一个右括号