pointers
Ian Lance Taylor
iant@google.com
Sat May 12 19:01:00 GMT 2007
Gordiano <sagrav@racsa.co.cr> writes:
> char *c_ptr;
> char ch;
> c_ptr = &ch;
> *c_ptr = "hello";// :( ptr3.cc:17: error: invalid
> // conversion from ‘const char*’ to ‘char’
This is not a gcc question. It is a C++ language question.
The string "hello" has type "const char*". The variable c_ptr has
type "char*". The language forbids assigning a value of type "const
char*" to a variable of type "char*". Look for "const_cast".
Ian
More information about the Gcc-help
mailing list