Hey,
How do I make a string array like
string blah[10];
blah[0]="blibity blah";
blah[1]="blibbering baww";
Thanks,
Gr3g
Printable View
Hey,
How do I make a string array like
string blah[10];
blah[0]="blibity blah";
blah[1]="blibbering baww";
Thanks,
Gr3g
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,,,!
;)
it won't give you any kind of misstake...
you better be carful next time...
I hope that helped you ....
:D Yes thank you, Im going to write my program now, when (hehe or if) i finish ill post the code...
Gr3g
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;
}