Re: pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gordiano <sagrav@xxxxxxxxxxx> 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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux