using sscanf in a loop
-
Hi, How can I advance the sscanf statement to read each word in the sentence? Right now my output is an endless loop of "This".
CString incoming_line="This is my example incoming line.";
CString string_out;
while (sscanf(incoming_line, "%s", string_out )==1)
{
cout<<string_out<<endl;
}Thanks!
-
Hi, How can I advance the sscanf statement to read each word in the sentence? Right now my output is an endless loop of "This".
CString incoming_line="This is my example incoming line.";
CString string_out;
while (sscanf(incoming_line, "%s", string_out )==1)
{
cout<<string_out<<endl;
}Thanks!
you could do something like this:
int offset = 0;
while (sscanf(incoming_line + offset, "%s", string_out )==1)
{
cout<
image processing toolkits | batch image processing -
you could do something like this:
int offset = 0;
while (sscanf(incoming_line + offset, "%s", string_out )==1)
{
cout<
image processing toolkits | batch image processing -
Hi, How can I advance the sscanf statement to read each word in the sentence? Right now my output is an endless loop of "This".
CString incoming_line="This is my example incoming line.";
CString string_out;
while (sscanf(incoming_line, "%s", string_out )==1)
{
cout<<string_out<<endl;
}Thanks!
b-rad311 wrote:
while (sscanf(incoming_line, "%s", string_out )==1)
You cannot use a
CString
object in this capacity."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
b-rad311 wrote:
while (sscanf(incoming_line, "%s", string_out )==1)
You cannot use a
CString
object in this capacity."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
Chris, Thanks for your help. I'm getting the following error when I use your suggestion.
Error 2 error C2666: 'ATL::CStringT<BaseType,StringTraits>::operator +' : 3 overloads have similar conversions
Any ideas? Thanks,
oops. didn't see the CString there.
-
If you did, then how would
scanf()
be able to change its contents? Since you are using MFC, have a look atCStringT::Tokenize()
orAfxExtractSubString()
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius