jeudi 22 janvier 2015

C Code: Comparison with an int fails and I have no idea why

I'm dealing with a strange problem and I'm not the best C Programmer on earth, so be gentle with me! :)


The thing is: I'm trying to compare a value based on a volatile unsigned int Pointer. The Basic Code looks like this:



// *error_data is a volatile unsigned int Pointer
int code = (int) *error_data;
printf("Errorcode: %d\n", code); // prints 400 and is definitely 400!!!
if (code == 400) // here the comparison fails totally
{
printf("Test.\n"); // I'm never getting this output
}
else
{
printf("WHY???\n"); // I'm always getting this path of the if statement
}


Does somebody know what's the issue? I'm working on this Problem since yesterday and broke down the example to this and I have no answer why this happens. It's really weird.


Aucun commentaire:

Enregistrer un commentaire