+ 1

Array with string? An example please?

24th Jan 2018, 2:36 AM
Kevin Abinady
Kevin Abinady - avatar
5 Antworten
+ 9
Given you're taking only C++, I'll do it in that language. string arrayColors[] = {"Red", "Green", "Blue"}; cout << arrayColors[1] << endl;
24th Jan 2018, 3:05 AM
John Wells
John Wells - avatar
+ 5
string arrayWords[][] = {{"home", "close", " door", "blue"},{"yellow", "window", " dog", "open"}, {"cat", " box", "green", "car"}, {"dad", " friend", "brother, "mom"}}; cout<< arrayWords[1][2] << endl; // outputs dog arrayWords[0] is {"home", "close", " door", "blue"} arrayWords[1][0] is "yellow"
24th Jan 2018, 3:37 AM
John Wells
John Wells - avatar
+ 1
thanks, have a nice day! Greetings from México.
24th Jan 2018, 3:49 AM
Kevin Abinady
Kevin Abinady - avatar
0
c++
24th Jan 2018, 3:01 AM
Kevin Abinady
Kevin Abinady - avatar
0
oh! thanks so much, and an example array bi-dimentional? string arrayWords[3][4] = {{"home", "close", " door", "blue"},{"yellow", "window", " dog", "open"}, {"cat", " box", "green", "car"}, {"dad", " friend", "brother, "mom"}}; cout<< arrayWords[2][3] << endl; //screen out:" dog" it's ok made this way?
24th Jan 2018, 3:19 AM
Kevin Abinady
Kevin Abinady - avatar