Hi guys / girls i am new in this forum and i hope you could help me in this problem. i programmed a link list which stores some information one of them is strings and i entered them using the function gets(); instead of scanf(); to enable the program to read the space character, and at the termination of the program i call a function to save the linked list to a file but the problem aarise when i return and open the file and load the link list from the file to Main Memmory this what happen: suppose i entered the string "aaaa bbbb" note that there is a space.. when i close the program and then reexecute it and use the function fscanf(); to read from a file it consider "aaaa" a string and "bbbb" another string it don't consider them as one string. please help me.. :rolleyes: :rolleyes: :rolleyes:
Avoid both gets and scanf -- with which it looks like you discovered that the %s specifier is whitespace delimited. Instead use fgets to read a whole line, followed by sscanf to pick off the parameters (or other means since you've already got one big string) -- and don't forget to specify the maximum width with the %s (that is, %10s for example).
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314