-
Macros...humm
I have this macros....
is there anyway i can make another one to convert the madePkt Back to the 2 ascii chars that made it up ?
typedef unsigned short p_type;
/*Make a Packet ID from 2 ASCII Chars */
#define make_pkt(a,b) p_type(((a)&255) | (b)<<8)
#define madePkt make_pkt ('C','H')
-
#define a(x) ((a)&0xFF)
#define b(x) ((b)>>8)
-
Hmmm....Lookies:
#include "stdafx.h"
typedef unsigned short p_type;
/*Make a Packet ID from 2 ASCII Chars */
#define make_pkt(a,b) p_type(((a)&255) | (b)<<8)
#define madePkt make_pkt ('C','H')
int main( void )
{
printf("madePkt: %d\n", madePkt );
return 0;
}
Output "madePkt: 18499"
Basically i want to get back the 2 ASCII Chars from the outputting number which i dont think is possible without having a loop to go through the whole ASCII Char set and compare results ?
-
keda's macros work, no loops needed...