troubleshooting Question

fopen is failing

Avatar of sctt_tiger
sctt_tiger asked on
C++
19 Comments2 Solutions572 ViewsLast Modified:
#includ<stdio.h>

FILE *f,*g;
void main()
{
   //Some code
   f=fopen("abc.log", "wt");
     if(f==NULL)
      DisplayError("\nabc.log Cant created ");
   WriteData(f);
   fclose(f);
   // more code
   g=fopen("xyz.log","wt");
      if(g==NULL)
            DisplayError("\nxyz.log cant be created");
      
}// main ends

void DisplayError( char *message) /* Routine for displaying the error messages.  */
{      printf("%s\n", message);
      printf("Program stopped !!\n");
      exit(0);
}


Problem
2nd fopen always fails. i have tried it many times by changing file name like abc.txt, abc.dat  file1.txt etc.
1st fopen succeeds.

please explain, why, what are various reasons that fopen can fail.
while running above program, no other file is opend.
i can create other files from DOS prompt, i mean no problem regarding disk space.
please chekc.
Thanks.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 19 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros