Results 1 to 2 of 2

Thread: seg faults in C

  1. #1
    Join Date
    May 2002

    Unanswered: seg faults in C

    I'm trying to write a C program but it keeps giving me seg-faults. I tracked down the error to a line where i'm opening up a file for reading:

    file_in = fopen(input_file,"r");

    (file_in is of type FILE and input_file is a string with the name of the file inside of it).

    the weirdest thing is that this same exact code works in a different part of my code... both are in the same method though ... could that be it?

    has anyone had this problem before? do you know how to get rid of this annoying seg-fault?


  2. #2
    Join Date
    Apr 2002
    hard to tell without the complete code, but a few thoughts:

    file_in should be a pointer to FILE, not FILE itself.
    does input_file point to a valid string (i.e. has a \0 within the allocated segment) at the point of the call or is maybe even null?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts