I compiled and run the following console program which is supposed to read an integer and return the number of field successfully read:
# include <stdio.h>
int main ( void )
{
int result, number;
printf ( " Enter an integer : \n ");
result=scanf ( " %d " , & number );
printf ( " Fields read % d " , result );
return 0;
}
I compiled ( VS 2008 ) and tested it on 2 machines under Win Vista and while on one machine it runs as expected, in the other case when I enter the number the scanf does not return and waits for additonal input. I have to enter another integer for it to exit and furthermore when it exits it returns 1 as a result value which is incorrect since I entered 2 integers .
Am I missing something ?