从一个博客的回复上看到的,学习之后加了注释。源代码来自csdn博客。
通过这段代码学习到fgets实现从文件中一行一行读,fputs实现把每次读到的内容原样写到一个文件中,strstr查找包含某个xxx内容的字符串,feof判断文件末尾,#if #else #endif预编译命令,通过写bat文件向编译好的文件传入main函数的参数(这个同样可以通过在Project中设置实现向main函数传参数),实际上使用bat文件和在cmd使用dos命令作用是相同的,这里就相当于在cmd下cd进入到exe文件夹下,然后敲入xxx.exe arg[1] arg[2],其中后面为传入main函数的两个参数常用的c的文件操纵函数还有
//printf fprintf
//scanf fscanf
//getc fgetc
//putc fputc
//gets fgets
//puts fputs
//fread fwrite
//fseek fgetpos feof
#include
#include
#include
#include
using namespace std;
#define DST_FILE "dst.txt"
#define SRC_FILE "src.txt"
//assume that every line is not larger than 256 bytes
#define MAX_LEN 256
static char achBuf[MAX_LEN] = {0};
static int RemoveSameStringLine(int arg