top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What is scanf_s in visual studio express edition ?

+3 votes
139 views

In visual studio compiler instead of using scanf function compiler asking me to use scanf_s function?what is the difference between these two

posted Mar 14, 2015 by Gnanendra Reddy

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

scanf_s is specific to Microsoft compilers as you specified about visual studio express edition. It is the same as scanf, except it does not cause buffer overload.

Syntax

int scanf_s(const char *format [, argument]...);
Format - The format of the incoming string    
Argument - Optional variables to place the incoming data

Now check this program which will receive input on the line until the enter key is pressed and place the value into the variable. This is the same as scanf, except it is safe.

#include<stdio.h>

int main()
{
   char c;
   printf("Enter a letter");
   scanf_s("%c",&c);
}
answer Mar 15, 2015 by Salil Agrawal
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...