Mail Archives: djgpp/1998/05/20/22:34:44
From: | "JCx" <jicehix AT worldnet DOT fr>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Problem writing in a file... the sequel
|
Date: | Thu, 21 May 1998 01:37:21 +0200
|
Lines: | 53
|
Message-ID: | <6jvpfo$oag$1@news4.isdnet.net>
|
NNTP-Posting-Host: | p14-017.province.worldnet.fr
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hi again... as many guys told me, I've modified my program (see a few
posts before this one), which now creates a copy of the first one with the
string added. But the problem is: the read/write loop never ends. Any idea ?
Thanks, JCx.
jicehix AT worldnet DOT fr
/* addv.c */
#include <stdio.h>
#include <stdlib.h>
FILE *source;
FILE *destination;
char texte[80];
void main(void)
{
printf("\nOpening file.");
source=fopen("test.ini","r");
destination=fopen("new.ini","w");
if ((source==NULL)||(destination==NULL))
{
printf("\nFile not found :(\n");
exit(1);
}
printf("\nFile opened.");
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");
}
}
fclose(source);
fclose(destination);
printf("\nModification OK.\n");
}
- Raw text -