Sign in to follow this  

scanf question

This topic is 3568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm teaching a few people at work to program in C which, much like this forum, is doing nothing but showing me how little I know (Ignorance may not be bliss but it's much better for your ego). Anway, I was trying to explain how scanf (yes I know the function is insecure) worked, and wasn't positive so I figured I'd ask and see if I needed to correct myself. I "think" (from my memory and admittedly sparse research) what's happening is that is that user-requested input is consumed until the request is filled or stdin's buffer is empty at which point a call to scanf will buffer input until <Enter> is pressed (or, more generally until 'end-of-line' is reached?). Can someone confirm or clarify?

Share this post


Link to post
Share on other sites
The definition is as follows.

Reads data from stdin and stores them according to the parameter format into the locations pointed by the additional arguments. The additional arguments should point to already allocated objects of the type specified by their corresponding format tag within the format string.

so that should answer your question :p

for the most part i belive for all the depreateced functions there is a prefex for the fixed version something like s_scanf() or something around that just check out msdn and search for scanf im sure it will tell you the new updated type safe function.

regards jouei.

Share this post


Link to post
Share on other sites

This topic is 3568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this