Programmer's Wiki

This function is specific to Microsoft compilers. It is the same as scanf, except it does not cause buffer overload.  It takes the input in a text based console program and places it into a variable.


int scanf_s(
  const char *format [,

Format - The format of the incoming string

Argument - Optional variables to place the incoming data


This function will be used when input is required in console programs.  This will receive all input on the line until the enter key is pressed.  It will then place the value into the variables you have declared.  This is the same as scanf, except it is safe.  This is an example:


int main()
   char c;
   printf("Enter a letter");
   scanf_s("%c", &c, 1);
   return 0;

C Programming For Beginners