c 删除文件中指定的部分内容
#include <stdio.h>
#include <dirent.h>
#include <string.h>
void search_file(char* dir);
void clear_file(char* FileName,char* Filename1);
DIR *dp;
struct dirent *dirp;
char* file;
FILE * fp=NULL;
char n_filename[50];
char o_filename[50];
char buf[80];
int pid;
int status;
char* logdir;
char* logbak;
char *optarg;
int main(char *argv[]){
logdir="/usr/local/tmp_file/";
logbak="/usr/local/tmp_file2/";
printf("Begin now !");
search_file(logdir);
}
void search_file(char* dir){
if ((dp = opendir(dir)) == NULL)
{
printf("directory %s is not found!",logdir);
}
/* print err */
while ((dirp = readdir(dp)) != NULL){
optarg = dirp->d_name;
/*printf ("%s " , optarg);*/
if ((strstr(optarg,".htm")!=NULL)
(strstr(optarg,".vbs")!=NULL)
(strstr(optarg,".asp")!=NULL) ) {
n_filename[0]='