first of all this is not duplicate one because same error Question asked before but in different context
1
code
#include<iostream>
#include<cstring>
int main()
{
const char *s1;
const char *s2="bonapart";
s1=new char[strlen(s2)+1];
strcpy(s1,s2);
std::cout<<s1;
}
Output
[Error] invalid conversion from 'const char*' to 'char*' [-fpermissive]
Why such error ?
If I replace const char *s1
by char *s1
compile fine. But I think this const
only saying that s1 is pointing to constant string means we can't modify that string whom it is pointing. It does not mean that s1
is constant ptr. please put some light on this.