If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > seg faults in C

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-17-02, 10:50
somealien somealien is offline
Registered User
 
Join Date: May 2002
Location: MA
Posts: 4
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?

Thanks

Reply With Quote
  #2 (permalink)  
Old 06-18-02, 04:40
Apel Apel is offline
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 228
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On