Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
im at a bit of a loss here. I never had to work with strings, so forgive me if it is trivial:
i want to have an array of strings in C++, for example:string array[10];
array[0] = "I dont";
array[1] = "understand";program compiles, but i cant cout any values from an array. any help is much appreciated

What you're after here I think is
char *array[2] = { "help me", "I've fallen and I can't get up" };
cout [[ array[0]
should see help me
cout [[ array[1]
should see I've fallen and I can't get up
If you're after individual chars, then
array1[4] = { 'A', 'B', 'C', 'D' };
cout [[ array1[0];
shoud see the letter A
cout [[ array[3]
should see the letter D
That *should* work with the "string" variable as well, but I'm using an older compiler where "string" isn't defined as an array of characters. You might have to remove the * symbol before the array name when using string, but I'm not sure.
HTH

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |