??? 11/20/07 15:30 Read: times |
#147262 - pointer to a const Responding to: ???'s previous message |
There is a reason for this error, although some compliers might just generate a warning. As Andy stated, you are setting a non-constant pointer to a const. There is such a thing as a pointer to a const (there is also a const pointer, which is different).
If you were to declare your pointer as follows, you shouldn't have an error: const char *mycharptr; const char mystr = 'A'; mycharptr = &mystr; This is an example of a pointer to a constant, where the value being pointed to can't be modified. A const pointer on the other hand, can't change where it is pointing to, but the value at the location is pointing to can be changed. |
Topic | Author | Date |
Sequence of learning 8051, asm and C | 01/01/70 00:00 | |
2 Issues | 01/01/70 00:00 | |
my wrong path | 01/01/70 00:00 | |
OT, but | 01/01/70 00:00 | |
OT - error message | 01/01/70 00:00 | |
Use the tags | 01/01/70 00:00 | |
single-character const | 01/01/70 00:00 | |
QED? | 01/01/70 00:00 | |
As Erik suggests | 01/01/70 00:00 | |
Just learning - too luxury. | 01/01/70 00:00 | |
how can that be "too luxorious" | 01/01/70 00:00 | |
Foolish builder? | 01/01/70 00:00 | |
pointer to a const | 01/01/70 00:00 | |
True, but... | 01/01/70 00:00 | |
Explaining | 01/01/70 00:00 | |
helpfull ,thanks, but.. | 01/01/70 00:00 | |
Declaration | 01/01/70 00:00 | |
thanks | 01/01/70 00:00 | |
Adjust declaration | 01/01/70 00:00 | |
thanks again | 01/01/70 00:00 | |
const | 01/01/70 00:00 | |
no wrong path | 01/01/70 00:00 | |
learning C | 01/01/70 00:00 | |
Freebies | 01/01/70 00:00 | |
Erik is right | 01/01/70 00:00 | |
not necessary | 01/01/70 00:00 | |
You\'re skipping the most important step ... | 01/01/70 00:00 |