Problems with FILE pointers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bluesteel
    New Member
    • Mar 2007
    • 84

    Problems with FILE pointers

    Hi everyone! I am currently experiencing some problems... My program crashes when i open a file which does exist. The problem seems to happen when two pointers point at the same file. Could it be the reason why my program's crashing?

    Paul. Thanks a lot.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by bluesteel
    Hi everyone! I am currently experiencing some problems... My program crashes when i open a file which does exist. The problem seems to happen when two pointers point at the same file. Could it be the reason why my program's crashing?

    Paul. Thanks a lot.
    Hi,.
    Is the program crashing during opening the file or during any file operations when u do with the file pointer.
    Usuallu fopen wont crash.
    After opening the file check for NULL and then do the file operations.

    Raghuram

    Comment

    • sanYAua007
      New Member
      • Oct 2007
      • 6

      #3
      Hi.
      It is the reason of program crashing, because when you assign your pointer with file, using fopen() system closes previous connection to this file. So when you try to use it later, you get crash.

      Code:
      ........
      f1=fopen();
      f2=fopen();//after this f1 points to nowhere
      ........

      Comment

      Working...