how to add string of words in a 2D array

i need to code a 2 D array that is similar to this output however i only managed to have the open and close words without the "stalls 1, 2, 3" and the days on the first row.


1. Display all stalls
2. Display the stalls opened on given day
3. Exit
enter your choice: 1

Mon Tues Wed Thurs Fri Sat
Stall 1 open close open close open open
stall 2 open open open open open open
stall 3 close close close open open open



this is what i code:

#include<iostream>
#include<iomanip>

using namespace std;

int choice = 0;

void displayStalls(){

int stalls[3][6] = {{1, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1},
{0, 0, 0, 1, 1, 1},
};

for (int r=0;r<3;r++)
{
for (int c=0;c<6;c++)
{
if (stalls[r][c]== 0){

cout<<"close"<<" ";
}

else
{
cout<<"open"<<" ";}
}

cout<<endl;
}

}

int main(){

cout<<"1. Display all stalls"<<endl;
cout<<"2. Display the stalls opened on given day"<<endl;
cout<<"3. Exit"<<endl;

cout<<"Enter your choice: ";
cin>>choice;

if (choice!=1){

return choice;
}


displayStalls();
system("pause");
return 0;
}



i only managed to have the open and close words without the "stalls 1, 2, 3" and the days on the first row.

So where did you do the cout of the "stalls 1, 2,3" and the days on the first row?
They're not going to appear by themselves.

It's unclear from your code if there are 3 days and 6 stalls, or 6 days and 3 stalls.
Using r and c as loop variables doesn't help to clarify that.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Topic archived. No new replies allowed.