0
#include<stdio.h>
#include<conio.h>

int main()
{
    int num;
    printf("Enter your number \n");
    scanf_s("%d", num);
    printf("Your number is %d", num);
    _getch();
    return 0;
}

When i build the above code in VS2013 it gives me following error :

error C4700: uninitialized local variable 'num' used ?? Whhat would be the reason for this ??

TheSpy
  • 265
  • 1
  • 8
  • 21

1 Answers1

5

You forgot the &:

scanf_s("%d", &num);

scanf expect a pointer, so it was reading the value of num to find the address to write the user input (and num was not initialized, that's why the compiler raise a warning). But what you really meant is the address of num itself.

fede1024
  • 3,099
  • 18
  • 23