We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Undestanding sscanf

dpalyca755
dpalyca755 asked
on
Medium Priority
450 Views
Last Modified: 2012-05-11
Hello.  I am not that familiar with the C programming language.
What does this do exactly?
route parameter is a character string and offset is an integer initialized to "NOT_SET".
sscanf(route_parameter, "%*s %n", &offset);
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
> So, it doesn't matter whether it is initialized to "NOT_SET" or not.
It could matter if the sscanf format fails to match anything, in which case offset would be unchanged.

Commented:
> > So, it doesn't matter whether it is initialized to "NOT_SET" or not.
> It could matter if the sscanf format fails to match anything, in which case offset would be unchanged.
That is true.
But, in the program that "dpalyca755" is doing, the only thing it is trying to read is a string.
So, the situation you mentioned will arise, only if route_parameter is a null string!
Anyway, you have rightly pointed out the mistake and I agree to your point.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.