配置文件的修改
修改前
代码
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc,char **argv)
{
int fd666;
char *readBuf=NULL;
if(argc!=2){
printf("param error\n");
exit(-1);
}
fd666=open(argv[1],O_RDWR);
int size =lseek(fd666,0,SEEK_END);
lseek(fd666,0,SEEK_SET);
readBuf=(char *)malloc(sizeof(char)*size+8);
int n_read=read(fd666,readBuf,size);
char *p=strstr(readBuf,"LENG=");
if(p==NULL){
printf("not found\n");
exit(-1);
}
p=p+strlen("LENG=");
*p='5';
int n_write=write(fd666,readBuf,strlen(readBuf));
close(fd666);
return 0;
}
修改后