read two strings into a text file

Hello!

I've to read two strings into a text file. the two strings can contain spaces...

How can I read these strings?

I tried:
 
fscanf("%s %s", str1, str2);


but when the first string in the file has a space into it the program reads not all the strings but (of course) only the first that is split by a space...how can I let my program to read two strings into a text file?
Thanks
Last edited on
What delimits the two strings?
I use a space to delimit.
I't an error, I know (that's why I cannot then read the strings properly) but I don't know what char to use to delimit the strings...
newline?
I can write all ASCII characters to the file so I think new line would not solve the problem..
harmodrew wrote:
I can write all ASCII characters to the file [...]

What do you mean? A newline character could be part of a string? Any character could be part of a string? Then, consider reading them in binary mode. You could store the length of each string as an integer before storing the string and use then that information to load it.
yes. ok, I'll try binary files then :)
Topic archived. No new replies allowed.