Another Sscanf question

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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?
 
#2
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?