File * file;//文件指针
fgetchar();
fputchar();
fopen();
fclose();
Fflush();
Stdin(输入)
Stdout(输出)
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE* fp1;
FILE* fp2;
char ch;
fp1 = fopen("E:\\a.bat","wb");
if(fp1 == NULL){
printf("file open error!");
exit(0);
}
printf("please intput!");
ch = getchar();
while(ch != ‘#‘){
fputc(ch,fp1);
ch = getchar();
}
fflush(stdin);
fclose(fp1);
fp2 = fopen("E:\\a.bat","rb");
if(fp2 == NULL){
printf("file open error!");
exit(0);
}
while(!feof(fp2)){
ch = fgetc(fp2);
putchar(ch);
}
putchar(‘\n‘);
fflush(stdout);
fclose(fp2);
return 0;
}
时间: 2024-10-12 21:29:23