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:

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post A C++ 7 07-05-2011 07:49 PM bansalvikrant@gmail.com C++ 4 07-02-2009 10:20 AM chikkubhai C++ 9 09-27-2007 11:54 AM jimjim C Programming 16 03-27-2006 11:03 PM masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM