I have this code and it has problem.
#include <iostream>
#include <stdio.h>
using namespace std;
void main()
{
char* str="hello_world";
cout<<str<<endl;
str[3]='\0';
cout<<str<<endl;
}
but if I change char* str
to char str[]
.
it works fine.Why?