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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -