{{keywords>wiki library source code example reference}}
===== scanf =====
int scanf(const char *format, ...);
The function returns the number of items that were successfully read\\
EOF if the input stream reached its end, or a negative number if an error occurs.\\
===== C Sourcecode Example =====
/*
* scanf example code
* http://code-reference.com/c/stdio.h/scanf
*/
#include /* including standard library */
//#include /* uncomment this for Windows */
int main ( void )
{
char input[20];
printf ("Enter some Text (max 20 chars) ");
scanf ("%s",input);
printf ("Scanf input was %s.\n",input);
return 0;
}
==== output ====
output: ./scanf
Enter some Text (max 20 chars) Hello this is a test for scanf
Scanf input was Hello.
see also [[c:stdio.h:fscanf|]] [[c:stdio.h:printf|]] [[c:stdio.h:fprintf|]]