Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Another Sscanf question

May
12,846
164
If I do this,

Sscanf(psz, L" %u-%u-%u%*[ ,]%u:%u:%u%*[ ,]%c",
&st.wYear, &st.wMonth, &st.wDay, &st.wHour, &st.wMinute, &st.wSecond, &c)

with the string "2008-11-19 00:00:00 u", Sscanf (correctly?) returns 7 (assignments made) and c is assigned.

But if I do

Sscanf(psz, L" %u-%u-%u%*[ ,]%c",
&st.wYear, &st.wMonth, &st.wDay, &c)

with the string "2008-11-19 u"

Sscanf returns 3 (where 4 is expected?) and c is not assigned.

What's going on?
 
Never mind. It was my fault. I had an extra character in the second example's format string which was screwing up the search.

If I do this,

Sscanf(psz, L" %u-%u-%u%*[ ,]%u:%u:%u%*[ ,]%c",
&st.wYear, &st.wMonth, &st.wDay, &st.wHour, &st.wMinute, &st.wSecond, &c)

with the string "2008-11-19 00:00:00 u", Sscanf (correctly?) returns 7 (assignments made) and c is assigned.

But if I do

Sscanf(psz, L" %u-%u-%u%*[ ,]%c",
&st.wYear, &st.wMonth, &st.wDay, &c)

with the string "2008-11-19 u"

Sscanf returns 3 (where 4 is expected?) and c is not assigned.

What's going on?
 

Similar threads

Back
Top