[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Help me stay away from visual C++ :)



I'm taking an intro C class, and of course everything there is run on win95. 
For a project we're doing now, I need to be able to tell if a scanf("%d",&x)
actually gets an int or not, but scanf seems to freak out if it gets anything
but an int.  For example:

int test;
for(;;)
{
        printf("Status is %d\n",scanf("%d",&test));
        fflush(stdin); 
}

prints out "Status is 1" if it gets an int, but freaks out and keeps printing
"Status is 0" over and over if you give it a char.  The same snippet works fine
under visual C++.  Is this something that's (most likely) broken in vc++, or
perhaps (less likely) broken in glibc 2.1?  All I have to test it on is a
potato box, so I don't know if other versions of gcc have the same problem.

Pointers to faqs or relevant docs are appreciated, I've spent an entire day
poking around in various gcc things (I hate info :)) but with no luck.

Thanks,
Moses

--
Moses Leslie <marmoset@l8r.net>


Reply to: