make fgets() wait for new lines.

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Nov 2008
Posts: 35
Reputation: CoolAtt is an unknown quantity at this point 
Solved Threads: 0
CoolAtt's Avatar
CoolAtt CoolAtt is offline Offline
Light Poster

Re: make fgets() wait for new lines.

 
0
  #11
Feb 4th, 2009
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()

}
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: make fgets() wait for new lines.

 
0
  #12
Feb 4th, 2009
And did you assign the result of fopen ?
And please learn how to use code tags.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 35
Reputation: CoolAtt is an unknown quantity at this point 
Solved Threads: 0
CoolAtt's Avatar
CoolAtt CoolAtt is offline Offline
Light Poster

Re: make fgets() wait for new lines.

 
0
  #13
Feb 5th, 2009
yes i have assigned it.
Last edited by CoolAtt; Feb 5th, 2009 at 12:09 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: make fgets() wait for new lines.

 
0
  #14
Feb 5th, 2009
Well I guess you'll just have to post your real code, and not just random bits of pseudo-code.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 35
Reputation: CoolAtt is an unknown quantity at this point 
Solved Threads: 0
CoolAtt's Avatar
CoolAtt CoolAtt is offline Offline
Light Poster

Re: make fgets() wait for new lines.

 
0
  #15
Feb 6th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC