- fgetc函数:
- 功能:在文件中读取一个字符;
- 具体内容如下:
#include <stdio.h>
int fgetc(FILE *stream);
- fputc函数:
- 功能:在文件中写入一个字符;
- 具体内容如下:
#include <stdio.h>
int fputc(int c, FILE *stream);
- perror函数:
- 功能:错误码被重置后,直接打印错误信息;
- 具体内容如下:
#include <stdio.h>
void perror(const char *s);
#include <stdio.h>
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;
}