From: "Aleksey Kondratyev" Newsgroups: comp.os.msdos.djgpp Subject: Re: Problem writing in a file... the sequel Date: Thu, 21 May 1998 12:58:27 +0400 Organization: Middle Volga Communication service Lines: 49 Message-ID: <6k0qj0$fv9$2@simtel.ru> References: <6jvpfo$oag$1 AT news4 DOT isdnet DOT net> NNTP-Posting-Host: ppp13.usr.mv.ru To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk JCx wrote > while (texte!=NULL) > { > fgets(texte,80,source); > fputs(texte,destination); > if (texte[0]=='[') > if (texte[1]=='d') > if (texte[2]=='r') > if (texte[3]=='i') > if (texte[4]=='v') > if (texte[5]=='e') > if (texte[6]=='r') > if (texte[7]=='s') > if (texte[8]=='3') > if (texte[9]=='2') > if (texte[10]=']') > { > fprintf(destination,"test string\n"); > printf("\nString added.\n"); > } > } I did not see your previous postings but it seems that you should consider reading a good book about C language. texte in your example is an address of a static array of char and it is not changed: texte!=NULL is always true (you are able to change a variable texte but it is not a good idea). You could want to write *texte='\0' if your file is "\n\0" terminated. Although, it is really better to use feof(FILE *) to check if the end of file is encounted. Also, there exists strncmp(const char *,const char *,size_t) library function. Multiple if's are substituted by strncmp(texte,"[drivers32]",sizeof("[drivers32]")-1) using it. ---------------------------------------------------------------------- Aleksey Kondratyev Ph.D. student of Ulyanovsk state University, Russia http://www.mv.ru/~akondra E-mail akondra AT mmf DOT univ DOT simbirsk DOT su akondra AT no-spam-mv DOT ru Remove "no-spam-" when replying