This is probably another very simple error on my part, but for the life of me I cannot figure out what I'm doing wrong.
My array prints on its own (when I remove the rest of the code) without the values passed from the function, but it does not print with the added values. This is for a seating chart program, where available seats are meant to print as # symbols and taken seats are meant to print as * symbols.
I've tried locally changing the values to integers (display [2] [2]=taken;) for example, and it does print those.
As is, with my functions included, it isn't printing my array at all-which leads me to believe that there's an issue with my function call but I don't see it. Any assistance would be greatly appreciated, thank you so much!!
#include <iostream>
#include <iomanip>
//function prototype storing seat choices
int getSeatChoice ();
//function prototype storing row choice
int getRowChoice ();
usingnamespace std;
int main ()
{
constint SEATS=30;
constint ROWS=15;
char available='#';
char display [ROWS][SEATS];
char taken='*';
int rowChoice;
int seatChoice;
{
for (int j=0; j<ROWS; j++)
{
for (int k=0; k<SEATS; k++)
{
getRowChoice();
getSeatChoice();
cout<<setw(17)<<"Seats"<<endl;
display [j][k]=available;
display[rowChoice][seatChoice]=taken;
cout<<display[j][k]<<"";
cout<<"\n";
}
}
}
return 0;
}
int getSeatChoice ()
{
int seatChoice=0;
int seatHolder=0;
cout<<"Which seat would you like to sit in?";
cin>>seatHolder;
seatChoice=(seatHolder-1);
return (seatChoice);
}
int getRowChoice ()
{
int rowChoice=0;
int rowHolder=0;
cout<<"Which row would you like to be seated in? ";
cin>>rowHolder;
rowChoice=(rowHolder-1);
return (rowChoice);
}
In function 'int main()':
39:39: warning: 'rowChoice' may be used uninitialized in this function [-Wmaybe-uninitialized]
39:39: warning: 'seatChoice' may be used uninitialized in this function [-Wmaybe-uninitialized]
Did you see messages like this?
You're calling functions which return values, but you're just ignoring those values.
I don't-in my IDE the program compiles and runs, it just doesn't print the array. I'm required to use DevC++, and while we just send the source code to our professor I try to follow her instructions...but the few actual programmers I've had contact with don't seem to like DevC++ and I'm guessing this is one of the reasons why.
Thank you so much for the feedback! That's really helpful, I can't thank you enough!
I imagine you can turn on warnings even in the old version of Dev-C++, no?
Try looking in the Compiler settings for an option to enable them, it's worth a shot.
Ganado, thanks for your help! I was able to turn them on once I looked around a bit.
Salem, will do! I *think* what my professor likes about this version of DevC++ is that you have to type in every character (no suggestions, etc.), which causes you to be careful. Can't say for sure, I'm not experienced enough to pretend I could talk about IDEs (as my handle says-I have a lot to learn!), but I will ask. Thanks again for your help!!