Skip to main content
gamedev.net
🔒 Locked

scanf question

Started by linternet Mar 6, 2008 at 10:03 AM 0 replies 700+ views
Original Post
linternet
linternet
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 is pressed (or, more generally until 'end-of-line' is reached?). Can someone confirm or clarify?
Jouei
Jouei
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.