|
-
Dec 7th, 2002, 09:56 PM
#1
Thread Starter
Hyperactive Member
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')
-
Dec 8th, 2002, 03:45 AM
#2
transcendental analytic
#define a(x) ((a)&0xFF)
#define b(x) ((b)>>8)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 8th, 2002, 08:25 AM
#3
Thread Starter
Hyperactive Member
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 ?
-
Dec 8th, 2002, 02:29 PM
#4
keda's macros work, no loops needed...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|