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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -