kesavan_sridhar
asked on
Reading String (with whitespaces) Using SScanf
Hello
Iam trying to read a string value from a CString object using sscanf.The CString was initially formatted using the
format function of CString.
But if the string has whitespaces in it, then I will not be able to get the
whole string with the whitespaces, if I use %s as a format specifier for that.
Even if I use %nc(n is no of characters), Iam not able to read the String
Properly?
Any ideas to read the string (with the whitespaces) from the CString?
Thanks
Sridhar
ASKER
Actually the CString object contains lot of data including
integers and Strings, Iam extracting each one of them
by giving the Format Specifiers for them. In additon to this "String with whitespace", some other data is also there in the CString object.
Thatz why I didn't do the way that you have suggested.
Thanks
Sridhar
integers and Strings, Iam extracting each one of them
by giving the Format Specifiers for them. In additon to this "String with whitespace", some other data is also there in the CString object.
Thatz why I didn't do the way that you have suggested.
Thanks
Sridhar
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops, I forgot to mention, I ran this through in debug, and examined the variables after the sscanf executed in the variables window of MSVC++. You can print them out if you'd like. :p
ASKER
Thank You for your response.
Bye
Sridhar
Bye
Sridhar
CString str("With whitespace");
char* psz = (LPCTSTR) str;
or
CString str("With whitespace");
char ac [ MY_SIZE];
strncpy ( ac, (LPCTSTR) str, MY_SIZE);
?