T
Tarjei Romtveit
I'm still a newbie into C++ programming, so I got a quite foolish
string related question.
Using: Dev-cpp 4.9.9.2 (I think Dev-Cpp uses a gcc compiler of some
sort)
If i declare a char string like this:
char szString[5] = "Hello";
The content of the szString array is now somthing similar to this:
szString[0] == H, szString[1] == e.. and so on, until szString[5] ==
\0. (right?)
But my compiler returns a following error:
"initializer-string for array of chars is too long"
If i do the declartaion like this
char szString[6] = "Hello";
it compiles correctly. If I choose to write something on the screen
like:
cout << szString[6] << endl;
It outputs a strange symbol that often differs (Probably something in
the memory).
The 'cout << szString << endl;' ouputs Hello.
Is there something wrong with my compiler? Or is my logical talent
really that bad?
(I'm a beginner so bear with me)
Mvh
Tarjei
string related question.
Using: Dev-cpp 4.9.9.2 (I think Dev-Cpp uses a gcc compiler of some
sort)
If i declare a char string like this:
char szString[5] = "Hello";
The content of the szString array is now somthing similar to this:
szString[0] == H, szString[1] == e.. and so on, until szString[5] ==
\0. (right?)
But my compiler returns a following error:
"initializer-string for array of chars is too long"
If i do the declartaion like this
char szString[6] = "Hello";
it compiles correctly. If I choose to write something on the screen
like:
cout << szString[6] << endl;
It outputs a strange symbol that often differs (Probably something in
the memory).
The 'cout << szString << endl;' ouputs Hello.
Is there something wrong with my compiler? Or is my logical talent
really that bad?
(I'm a beginner so bear with me)
Mvh
Tarjei