Hey,
How do I make a string array like
string blah[10];
blah[0]="blibity blah";
blah[1]="blibbering baww";
Thanks,
Gr3g
This is a discussion on String Array within the C++ Programming forums, part of the General Programming Boards category; Hey, How do I make a string array like string blah[10]; blah[0]="blibity blah"; blah[1]="blibbering baww"; Thanks, Gr3g...
Hey,
How do I make a string array like
string blah[10];
blah[0]="blibity blah";
blah[1]="blibbering baww";
Thanks,
Gr3g
Chance favors the prepared mind.
Vis. C++ 6.0
Hi Gr3g,
You need to copy the strings to your array:
or if you are using MFC:Code:char blah[2][100]; /* can hold 2 strings, each max 99 characters long */ strcpy(blah[0], "blibity blah"); strcpy(blah[1], "blibbering baww");
Code:CString blah[2]; blah[0] = "blibity blah"; blah[1] = "blibbering baww";
Hi,
I just want to add something ....
Every string is an array of char, has the same number of char that the string has + "/0", which will allow it to have one more room for the " /0" { "/0 means end of hte string "}
Now you can do what monster told you to do, or you can use dinamic array,
As in the same above,,,!
![]()
C++
The best
it won't give you any kind of misstake...
you better be carful next time...
I hope that helped you ....
C++
The best
Yes thank you, Im going to write my program now, when (hehe or if) i finish ill post the code...
Gr3g
Chance favors the prepared mind.
Vis. C++ 6.0
Or...
Prints out: blibity blah blibbering bawwCode:#include <string> #include <iostream> using namespace std; int main() { string blah[2] = { "blibity blah", "blibbering baww" }; cout << blah[0] << ' ' << blah[1] << endl; return 0; }
I used to be an adventurer like you... then I took an arrow to the knee.