943,511 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 1797
  • C RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Feb 4th, 2009
0

Re: make fgets() wait for new lines.

hi everyone.

i modified me_ansh code and its working.
The problem is that when it reaches the last line the program crashes
(segmentation fault)

Plz help.
thx

My implementation:

while(1){

while(!feof(fp)){

if(fgets(line,1000,fp))
//process line
}

fclose()
fopen()

}
Reputation Points: 10
Solved Threads: 0
Light Poster
CoolAtt is offline Offline
39 posts
since Nov 2008
Feb 4th, 2009
0

Re: make fgets() wait for new lines.

And did you assign the result of fopen ?
And please learn how to use code tags.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Feb 5th, 2009
0

Re: make fgets() wait for new lines.

yes i have assigned it.
Last edited by CoolAtt; Feb 5th, 2009 at 12:09 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
CoolAtt is offline Offline
39 posts
since Nov 2008
Feb 5th, 2009
0

Re: make fgets() wait for new lines.

Well I guess you'll just have to post your real code, and not just random bits of pseudo-code.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Feb 6th, 2009
0

Re: make fgets() wait for new lines.

hi .

i managed to find the bug. now it's not crashing.
thanks.
Btw i will use use code tags next time
Last edited by CoolAtt; Feb 6th, 2009 at 1:07 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
CoolAtt is offline Offline
39 posts
since Nov 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Prime numbers
Next Thread in C Forum Timeline: pointer to member of struct





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC