scanf question
How would you go about to discard or overlook a section of a string, when using scanf?
I'm trying to scan a http headerline. I need to read the status code e-g- Code:
int status; |
Re: scanf question
Quote:
%* must be followed with a format string. For example, %*c will discard a character (like %c will read a character). Also, scanf() returns the number of matches, not the string that was matched. To trap that, you will need to assign it to a value. scanf() can parse integers, so you might as well do that all in one go: Code:
int status; |
Thanks for the reply.
|
That should be:
Code:
sscanf(hdrstr, "HTTP/1.%*c %d", &status); |
gotcha ;)
|
All times are GMT -5. The time now is 06:54 AM. |