Velocity Reviews > Variable and pointer

# Variable and pointer

Julia
Guest
Posts: n/a

 06-25-2003
I am a n00b to c, so have pitty on me if I ask dumb questions .
I have a function (testframe() ) that has needs a pointer to a 6 byte MAC
address as input. The input is an unsigned 8 bit char pointer.
This pointer should then point to the 6 byte MAC address stored somewhere.
How do I actually write this in code? An integer is only 32 bit, so how do I
have something holding the MAC Address and more again, how do I create a
pointer pointing to this "something".

Julia

Dan Pop
Guest
Posts: n/a

 06-25-2003
In <bdc6sk\$quo\$(E-Mail Removed)-c.dk> "Julia" <(E-Mail Removed)> writes:

>I am a n00b to c, so have pitty on me if I ask dumb questions .
>I have a function (testframe() ) that has needs a pointer to a 6 byte MAC
>address as input. The input is an unsigned 8 bit char pointer.
>This pointer should then point to the 6 byte MAC address stored somewhere.
>How do I actually write this in code? An integer is only 32 bit, so how do I
>have something holding the MAC Address and more again, how do I create a
>pointer pointing to this "something".

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: http://www.velocityreviews.com/forums/(E-Mail Removed)

Kevin Easton
Guest
Posts: n/a

 06-25-2003
Julia <(E-Mail Removed)> wrote:
> I am a n00b to c, so have pitty on me if I ask dumb questions .
> I have a function (testframe() ) that has needs a pointer to a 6 byte MAC
> address as input. The input is an unsigned 8 bit char pointer.
> This pointer should then point to the 6 byte MAC address stored somewhere.
> How do I actually write this in code? An integer is only 32 bit, so how do I
> have something holding the MAC Address and more again, how do I create a
> pointer pointing to this "something".

unsigned char mac[6] = { 0x00, 0xC0, 0x4F, 0xDD, 0xB8, 0x73 };

then just pass "mac". An array (like "mac") is evaluated as a pointer
to its first subobject unless it is the operand of unary-& or sizeof, so
you don't need to do anything special to create the pointer.

- Kevin.

Thomas Matthews
Guest
Posts: n/a

 06-25-2003
Julia wrote:
> I am a n00b to c, so have pitty on me if I ask dumb questions .
> I have a function (testframe() ) that has needs a pointer to a 6 byte MAC
> address as input. The input is an unsigned 8 bit char pointer.
> This pointer should then point to the 6 byte MAC address stored somewhere.
> How do I actually write this in code? An integer is only 32 bit, so how do I
> have something holding the MAC Address and more again, how do I create a
> pointer pointing to this "something".
>
> Julia
>
>

Most applications treat MAC addresses as a collection of
octects (bytes). Just access it via pointer to unsigned
char. If the processor wants to promote the 8-bit u.c.
to a 32-bit unsigned integer, let it. Some processors
actually fetch the 8 bits into a 32-bit register.

If you need more help, please post a code fragment
demonstrating what you are doing.

--
Thomas Matthews

Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq: