uninitialized local variable 'num' used?


int main()
    int num;
    printf("Enter your number \n");
    scanf_s("%d", num);
    printf("Your number is %d", num);
    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 ??


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.

Need Your Help

How to enable and disable a seekbar when clicked?

java android seekbar

Hi guys I have two seekbars A and B and they edit 2 textviews 1 and 2. A edits 1 and B edits 2. I want it to work so that when the user touches seekbar A then seekbar B becomes disabled and likewise

P/Invoking CreateToolhelp32Snapshot failing in Compact Framework

c# .net compact-framework windows-ce

Hey, im doing a little app for my smart phone, using Windows Mobile 6. I'm trying to get all currently running processec, but method CreateToolhelp32Snapshot always returns -1. So now im stuck. I t...