Matrixinline <an**********@gmail.comwrote:
Hi All,
File Text.txt
Contains following text as :
"C:\program file\application data\details\app" "D:\Program File"
I tried to read that data as
fscanf(oFp, "%s %s", sCopyDirectory, sToDirectory);
it gives me
sCopyDirectory = "C:\program
sToDirectory= file\application
How can I read a full string between a two double quote mark from a
file?
Try
fscanf( fp, "\"%[^\"]\" \"%[^\"]\"", sCopyDirectory, sToDirectory );
The '%[^\"]' tells fscanf() to read everything up (but not
including) the next double quote. You may want to add the
maximum number of characters that fit into the target string
between the '%' and the '[', otherwise you may try to write
more characters to the target string than fits in there (and
don't forget about the trailing '\0' character that also needs
to fit in there;-)
Well we can read "C:\program file\application data\details\app" "D:
\Program File"
in two character pointers easily. I need the same solution but reading
from a file.
What means "Well we can read"? Reading from standard input and
a file doens't make any noticable difference here. And be care-
ful with your terminology, you can't "read into a character
pointer", you can only write to where a character pointer points
to, and that, of course, only if it points to enough memory
you own.
Regards, Jens
--
\ Jens Thoms Toerring ___
jt@toerring.de
\__________________________
http://toerring.de