#include
#include
#include
int main(void)
{
FILE *fp;
int ch;
long read, write;
if ((fp = fopen("d:\\test.txt", "r+")) == NULL) {
printf("can't rewrite");
exit(EXIT_FAILURE);
}
puts("修改前的文件:");
while ((ch = fgetc(fp)) != EOF)
putchar(ch);
rewind(fp);
read = write = 0;
fseek(fp, read++, SEEK_SET);
while((ch = fgetc(fp)) != EOF) {
fseek(fp, write++, SEEK_SET);
fputc(toupper(ch), fp);
fseek(fp, read++, SEEK_SET);
}
rewind(fp);
puts("修改后的文件:");
while ((ch = fgetc(fp)) != EOF)
putchar(ch);
fclose(fp);
}
阅读(362) | 评论(0) | 转发(0) |