I need to put X in the grid, as an array, and i will need to people to attach a persons name to that arrays, so that when yoou check who is sitting in D5, it will come up with the person sitting there?
2.) If you want to attach names to the people please use string variables instead of messing around with char-pointers /-arrays.
Strings are more C++, easier and better to overview and handle.
Btw, if you start a project like this I urgent recommend learning about pointers..!
They aren't as complicated as is might seem ;3
#include <cstdlib>
#include <iostream>
usingnamespace std;
//you probably want to redraw the array when you've changed something
//so we'll make an extra function
void display (int** seats, int row_number, int col_number) {
for (int row_index = 0; row_index < row_number; row_index++){
for (int col_index = 0; col_index < col_number; col_index++) {
cout << char (seats[row_index][col_index]) << " ";
}
cout << endl;
}
cout << endl;
}
int main(int argc, char *argv[])
{
int row = 10;
int col = 6;
int **seats; // here i would suggest a string pointer
//I use a pointer instead of an array
//because otherwise the function doesn't want to work
seats = newint* [row];
for (int i = 0; i < row; i++)
seats[i]= newint[col];
//initializing the pointer
for (int row_index = 0; row_index < row; row_index++){
for (int col_index = 0; col_index < col; col_index++) {
seats[row_index][col_index] = 'A'+col_index;
}
}
display (seats, row, col);
// change seat pointer e.g: D6
// D = 4, but since we're dealing with indices we write 4-1 = 3
seats [3][5] = 'X';
//we could also let the user change this number it doesn't matter
display (seats, row, col);
cin.get();
return EXIT_SUCCESS;
}
I hope I could adress the right problems ^_____^"
DonLuccar