I need some pointers with pointers.
What is the difference between a variable preceded by an "*" and an "&"?
Some of my sample code uses one and some the other. I'm getting compiler errors trying both saying the variable is not defined. First use this function.
It may also help if you see & as an address of operator.
o in this statement: INT32* pVoltage = &Voltage_High; you define a pointer to an int32 and you give it an address of a float. I guess the compiler is not happy with that. int32 is 4 bytes and a float is normally 8 bytes in memory.
If Voltage_High is of type float, then &Voltage_High is of type pointer-to-float. The fact that all pointers are the same size in memory is irrelevant. If you want to point to a float, you need a float-pointer;
It didn't work that way (didn't accept float*) so I was thinking that all pointers were of type INT because the address of the pointer is 32 bits in a 32 bit processor. So it should always by of the type that the pointer is pointing for?
int i = 65;
/* good compilers wont accept this, an int is not a char */
char c = i;
/* cast an int to char */
char c = (char)i;
In the last line, you are telling the compiler: "He, I know what I'm doing, it is OK." c should now be equal to 'A'. But casting does not always work to change one type to another. Casting a float to a char, will not work.
Then you cpuld cast the PortBuffer pointer to a UINT32. Don't really know your intentions, do you want to cast the address of the PortBuffer or the contents of the address the PortBuffer is pointing to?
On this port, I have to send 16 bit data, 24 bit and 32 bit data 8 bits at a time. I have a 32 bit processor that transfers 8, 16 or 32 bits at a time. There is another processor that will do 24 (type short long) bits but won't do 32. Another question...how do I access the bytes from the pointer at the other end?
I had just gotten an older book that explained pointers fairly well. I was correct in thinking all pointers were the same size for a particular processor but the reason for saying "char *ptr" or "float *ptr" is to set the size of item each pointer is pointing to. Otherwise type int is assumed.
This article explained it the rest of the way. Thank you very much!
For accessing the bytes from the other end do I...
INT8 is defined elsewhere as type char and could easily be called char since type char is always 8 bits. INT16 is defined as a 16 bit integer appropriate for the particular processor. It's called INT16 in the program for portability.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...