Why is this right ?
#include<iostream>
using namespace std;
int main()
{
char *s="raman";
char *t="rawan";
s=t;
cout<<s;
return 0;
}
But this is wrong?
#include<iostream>
using namespace std;
int main()
{
char s[]="raman";
char t[]="rawan";
s=t;
cout<<s;
return 0;
}
The first example assigns an pointer to another which is valid.
The second example assigns an array to another array which in not allowed in C & C++ both.
This excellent C++ FAQ entry and this answer should be a good read for you.