RE: [Dev-C++] Some help with ported C ansi code
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2002-07-25 01:49:24
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Roberto Ricardi
> Sent: Wednesday, July 24, 2002 6:59 AM
> To: dev...@li...
> Subject: [Dev-C++] Some help with ported C ansi code
>
>
> Hi all,
>
> I ported all my code from DJGPP to Dev-C++ in ansi C format. The
> compilation is ok now.
> But when I run it the program crash near at the end.
>
> I use some like 8 files to read or write in a form
> FILE *fp1 ...*fp8;
>
> fp1 = fopen(archme,"r");
> fp2 = fopen(archme,"w");
Guh! Now i noticed. You cannot do that in horizontal mode! I mean you
must not fopen() the same file more than once!
If you want to open it with read/write access in text mode without
overwriting it if it exists use:
fp1=fopen(archme, "a+");
if(!fp1)
{
printf(stderr, "Men the lifeboats. Women and children first!\n");
return EXIT_FAILURE;
}
...
fclose(fp1);
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|