tzushky
Member level 3
- Joined
- May 21, 2007
- Messages
- 63
- Helped
- 10
- Reputation
- 20
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Sophia-Antipolis,France
- Activity points
- 1,819
u_char in c
hello everyone
i have a small C manipulation problem.
u_char is the typedef of unsigned char. Used for bytes.
I define a MAC address as
typedef u_char mac_address[6];
and later in main() i have a pointer
mac_address *mac_src;
which will be assigned a value using a pointer to some packet data. This works just fine. My problem is printing the MAC to the screen in intelligible form ( xx:xx...xx)
Why? I try and get the values of the 6 components of the mac_src in memory by mac_src[0]...etc. This gets me their addresses, which on one side I understand...but how do I get to the contents of the addresses, my MAC components?? With *mac_src[0] ?
I had honestly thought I understood the idea of arrays and pointers in C, but it's making me nuts. PLZ help!
thanks in advance
Added after 59 minutes:
nobody curious yet?
i seem to have found a very lucrative way: printf( mac_src[0][0], mac_src[0][1]...)
because it seems that mac_src[0] is my pointer value and so inside it there is the table of bytes....weird...
hello everyone
i have a small C manipulation problem.
u_char is the typedef of unsigned char. Used for bytes.
I define a MAC address as
typedef u_char mac_address[6];
and later in main() i have a pointer
mac_address *mac_src;
which will be assigned a value using a pointer to some packet data. This works just fine. My problem is printing the MAC to the screen in intelligible form ( xx:xx...xx)
Why? I try and get the values of the 6 components of the mac_src in memory by mac_src[0]...etc. This gets me their addresses, which on one side I understand...but how do I get to the contents of the addresses, my MAC components?? With *mac_src[0] ?
I had honestly thought I understood the idea of arrays and pointers in C, but it's making me nuts. PLZ help!
thanks in advance
Added after 59 minutes:
nobody curious yet?
i seem to have found a very lucrative way: printf( mac_src[0][0], mac_src[0][1]...)
because it seems that mac_src[0] is my pointer value and so inside it there is the table of bytes....weird...