Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Variable and pointer

Reply
Thread Tools

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


 
Reply With Quote
 
 
 
 
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".


unsigned char macaddr[6], *p = macaddr;

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
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.

 
Reply With Quote
 
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:

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pointer to pointer or reference to pointer A C++ 7 07-05-2011 07:49 PM
Pointer to pointer Vs References to Pointer bansalvikrant@gmail.com C++ 4 07-02-2009 10:20 AM
Differences in code implemented using this pointer and a variable THIS simulating this pointer chikkubhai C++ 9 09-27-2007 11:54 AM
passing the address of a pointer to a func that doesnt recieve a pointer-to-a-pointer jimjim C Programming 16 03-27-2006 11:03 PM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM



Advertisments