[C] #define - unexpected Results
From: Paulie (p1150gs_at_yahoonospam.co.uk)
Date: 11/28/04
- Next message: Anthony Borla: "Re: A Question about arrays file merging"
- Previous message: Jonathan Mcdougall: "Re: A Question about arrays file merging"
- Next in thread: Arthur J. O'Dwyer: "Re: [C] #define - unexpected Results"
- Reply: Arthur J. O'Dwyer: "Re: [C] #define - unexpected Results"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Nov 2004 22:03:13 -0000
Hi all.
I just came across something that I think is weird in my program and
wondered if I was misunderstanding it or the compiler was at fault. Cut
down to the basics the program goes like this:
void foo(unsigned char);
#define NINE 9
int main (void)
{
printf("%x", NINE); // Prints out 9
foo(NINE);
blah blah
}
void foo(unsigned char a)
{
printf("%x", a);
}
I would expect the program to print out 9 as the hex value, but it actually
prints out F9 (I am working on a mainframe system using EBCDIC notation so
F9 is character '9'). Am I missing the point or is there something curious
going on that needs further investigation.
I tried it out on my PC compiler and got 9 both times (as I expected).
Thanks, Paulie
- Next message: Anthony Borla: "Re: A Question about arrays file merging"
- Previous message: Jonathan Mcdougall: "Re: A Question about arrays file merging"
- Next in thread: Arthur J. O'Dwyer: "Re: [C] #define - unexpected Results"
- Reply: Arthur J. O'Dwyer: "Re: [C] #define - unexpected Results"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|