Jul 27, 2010 #1 1 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?
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?
Jul 27, 2010 #2 M millwood Advanced Member level 3 Joined Jul 2, 2009 Messages 733 Helped 80 Reputation 164 Reaction score 35 Trophy points 1,308 Activity points 5,088 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.
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.