c - uninitialized local variable 'num' used? -


#include<stdio.h> #include<conio.h>  int main() {     int num;     printf("enter number \n");     scanf_s("%d", num);     printf("your number %d", num);     _getch();     return 0; } 

when build above code in vs2013 gives me following error :

error c4700: uninitialized local variable 'num' used ?? whhat reason ??

you forgot &:

scanf_s("%d", &num); 

scanf expect pointer, reading value of num find address write user input (and num not initialized, that's why compiler raise warning). meant address of num itself.


Comments

Popular posts from this blog

c# - OpenXML hanging while writing elements -

php - regexp cyrillic filename not matches -

java - IntelliJ - No such instance method -