- fgetc函数:
- 功能:在文件中读取一个字符;
- 具体内容如下:
#include
int fgetc(FILE *stream);
- fputc函数:
- 功能:在文件中写入一个字符;
- 具体内容如下:
#include
int fputc(int c, FILE *stream);
- perror函数:
- 功能:错误码被重置后,直接打印错误信息;
- 具体内容如下:
#include
void perror(const char *s);
#include
int main(int argc, const char *argv[])
{
if(3 != argc)
{
printf("Usage : %s src_file dest_file\n",argv[0]);
return -1;
}
FILE *fp1 = fopen(argv[1],"r");
if(NULL == fp1)
{
perror("fopen error");
return -1;
}
FILE *fp2 = fopen(argv[2],"w");
if(NULL == fp1)
{
perror("fopen error");
return -1;
}
int ret = 0;
while(EOF != (ret = fgetc(fp1)))\
{
fputc(ret,fp2);
}
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41