Fandom

Programmer's Wiki

scanf_s

406pages on
this wiki
Add New Page
Talk0 Share

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.

Syntax Edit

int scanf_s(
  const char *format [,
  argument]...
);


Format - The format of the incoming string

Argument - Optional variables to place the incoming data

Usage Edit

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:

#include<stdio.h>

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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.