Need help with Functions

the project i am creating is for a small theater. the program allows a user to input the row and seat they would like to buy. i created a function that asks the user for the row and seat and then it is suppose to change the value of the spot in an array from # to a *. when i display the seating chart after they input a seat, the value is still a # and im not sure why. below is my code. could really use the help. please and thank you

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//Author:	Steven Cortright
//Course:	CSC 136
//Date:		Spring 2013
//Purpose:	Develop a program that will allow a theater to sell tickets for performances

#include <cstdlib>
#include <string>
#include <iostream>
#include "search.h"
#include <fstream>
using namespace std;


const char seatTaken = '*';
const char seatEmpty = '#';


/////////////////////////////////////function Prototypes//////////////////////////////////////////////


int menu();													//function to display menu
void theaterPrices(int prices[]);
void initializeSeating (char seats[15][30]);	        //sets seats to empty
void printSeating (char seats[15][30]);                 //prints seating shart
void customerProcessing(char seats[15][30], int rSelect, int sSelect);						//function to ask user what seat they want
void checkAvailability(char search[15][30], int rowSelected, int seatSelected);
char seating[15][30];


int main()
{
	initializeSeating(seating);
	//char seats[15][30];
	int selectedRow = -1;
	int selectedSeat = -1;
	int choice;
	

	choice = menu();
	switch (choice)
	{
	case 1:
			customerProcessing(seating, selectedRow, selectedSeat);
			main();
			break;
	case 2: 
			printSeating(seating);
			break;
	case 3:
			cout << "You picked number 3.";
			break;
	case 4:
			cout << "quit\n";
			break;
	default: cout << "Error input\n";

	}
	return 0;
}
int menu() //displays menu   WORKS
{
	int pick;
	cout << endl;
	cout << "1.  Process a Customer" << endl;
	cout << "2.  Print a seating chart" << endl;
	cout << "3.  Report total tickets sold and total price" << endl;
	cout << "4.  Quit" << endl;
	cout << "Choice:  ";
	cin >> pick;
	cout << endl;
	return pick;
}

void theaterPrices(int prices[]) //reads in seat prices
{
	ifstream infile;
	infile.open("prices.txt");

		for(int i=0; i < 15; i++)
		{
		infile >> prices[i];
		}
	
	infile.close();
}

void initializeSeating (char seats[15][30])  //sets seats to empty
{
	for(int row = 0; row < 15; row ++)
	{
		for (int col = 0; col < 30; col ++)
		{
			seats[row][col] = seatEmpty;
		}
	}
}
void printSeating (char seats[15][30])  // prints seating chart
{
	cout << "                   Seats" << endl;
	cout << "       123456789012345678901234567890" << endl;
	for(int row = 0; row < 15; row ++)
	{
		cout << "Row " << (row + 1)<< " ";
		if (row <= 9)
		{
			cout << " ";
		}
		for (int col = 0; col < 30; col ++)
		{
			cout << seats[row][col];
		}
		cout << endl;
	}
}

void customerProcessing(char seats[15][30], int rSelect, int sSelect)
{
	
	cout << "Enter the row you want: ";
	cin >> rSelect;
	cout << endl;
	cout << "ENter the seat you want: ";
	cin >> sSelect;
	cout << endl;

	if(seating[rSelect-1][sSelect-1] = '#')
	{
		seating[rSelect-1][sSelect-1] = '*';
		cout << "Seat Reserved" << endl;
	}
	
}
Removed my comment.

Plexus is right.
Last edited on
I think it's the '=' in line 126. Change it to '=='.


Topic archived. No new replies allowed.