Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Question about a 32 bit pointer in embedded C

Status
Not open for further replies.

123music

Junior Member level 1
Joined
Jun 24, 2010
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,381
I have a long *temp and int *temp1(assuming long is 4 bytes and int is 2 bytes and initialized with some memory address)

if i want to write 2 bytes into temp1 from temp, i will write as
*temp1 = *(int*)temp;

what if i want to write 2 bytes into temp from temp1??can i write as
*(int*)temp = temp1??

Is it allowed in embedded C?

But i think the second case we cannot call it as type casting..What do we call it then?
 

32 bit pointer

whether someone is a 32-bit pointer has nothing to do with if the object it points to is a 32-bit type or not.

"*temp1 = *temp;" takes the value temp points to (a 4-byte type) and gives it to the object temp1 points to (a 2-byte type).

"*temp=*temp1;" does the opposite.

"*temp=temp1;" takes the value of temp1 (a pointer) and gives it to the object temp points to). This operation is almost meaningless.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top