Recently, I have had big problems with understanding char*. Let's say I made a recursive function to return char*, but depending on how I initialize it, I get some access violations, and in my C ++ tutorial I did not find anything that would give me the correct way to understand therefore, I seek your help.
CASE 1
The first case when I received an access violation when trying to change the letters:
char * bob = "hello";
CASE 2 Then I tried this to make it work
char * bob = new char[5];
bob[0] = 'h';
bob[1] = 'e';
bob[2] = 'l';
bob[3] = 'l';
bob[4] = 'o';
CASE 3 But then, when I did cout, I got some random shit at the end, so I changed it to
char * bob = new char[6];
bob[0] = 'h';
bob[1] = 'e';
bob[2] = 'l';
bob[3] = 'l';
bob[4] = 'o';
bob[5] = '\0';
CASE 4 , ,
char * bob = new char[6];
bob = "hello\0";
CASE 5, , - , -
char* bob[];
- .
, , , ?