c++ - How to display a two-dimensional string array properly? -


so table making

#include <iostream> #include <string> using namespace std;  int main() {     string tables[5][14] =      { { "0", "3", "6", "9", "12", "15", "18", "21", "24", "27", "30", "33", "36", "2 1" },     { "2", "5", "8", "11", "14", "17", "20", "23", "26", "29", "32", "35", "2 1" },     { "1", "4", "7", "10", "13", "16", "19", "22", "25", "28", "31", "34", "2 1" },     { "1st 12", "2nd 12", "3rd 12" },     { "1-10", "even", "red", "black", "odd", "19-36" } };       cout << tables << endl;     return 0;     } 

so run code , compiler not show errors printed strange string of letters , numbers,

007ef610

i have never encountered before , use advice, time!

your code prints tables, address of first string. if want print strings contained in array of array of strings, have write loop goes through tables[i][j], instance:

for(int i=0; i<5; ++i) {   for(int j=0; j<14; ++j)   {     cout << tables[i][j] << endl;   } } 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -