Stuck on Link List & Stack

So, I'm trying to read in a txt file to a link list, so that when a player chooses whether or not to go left or right, it stores the word into a stack (it makes a passphrase when complete) and moves the player on to the row/col as told by the txt file.

The issue I'm having, is getting the input from the player, storing that word and then moving on to the row/col that the txt/link list tells them to.
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
  #include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
using namespace std;


class node
{
	public:
		int left;
		char data;
		int right;
};

node *start_ptr = NULL;
node *current_ptr;


void maze1(node maze[10][10])
{
	int row, col;//file>>array>>.left/right/data
	ifstream maze1;
		maze1.open("maze.txt");
	for(row=0;row<10;row++)
		for(col=0;col<10;col++)
	{
		maze1>>maze[row][col].left;
		maze1>>maze[row][col].data;
		maze1>>maze[row][col].right;
	}
}

/*void letterlist(char stack[20],int &tos)
{
	int row, col;
	node maze[10][10];
	maze1(maze);
 if (tos==-1)
	 cout<<"Stack overflow Error"<<endl;
 else 
	{	
		tos--;
		cin>>maze[row][col].data;
		cin>>stack[tos];
	}

}*/

class stack
{
	char stacklist[20];
	int tos;
public:
	stack(){tos = 0;}
	void push(char ch)
	{
		if(tos==20)
		{
			cout<<"list is full"<<endl;
			return;
		}
		stacklist[tos] = ch;
		tos++;
	}
	char pop()
	{
		if (tos==0)
		{
			cout<<"List is Empty"<<endl;
			return 0;
		}
		tos--;
			return stacklist[tos];
	}
};

void play()
{
	node maze1[10][10];
	maze(maze1);
	int row, col, moves;
	char playerchoice, Left, Right;
	stack stackobject1;
	char stacklist[20];

	cout<<"Please choose a direction: Left or Right:"<<endl;
		cin>>playerchoice;
	if(playerchoice==Left&&moves<20)
	{
		cout<<maze[row][col].left;
		moves++;
		cout<<moves;		
		cin>>maze[row][col].left>>stackobject1.push;
		cout<<stacklist;
		return;		
		//move player to row/col on left
	}
	if(playerchoice==Right&&moves<20)
	{
		cout<<maze[row][col].right;
		moves++;
		cout<<moves;
		//pass maze.data to stack
		//move player to row,col on right
	}
}

void wordmazeshow()
{
	ifstream maze("maze.txt");
	int left;
	string letter;
	int right;

	while(maze>>left>>letter>>right)
	{
		cout<<left<<"   "<<letter<<"   "<<right<<endl;
	}

}

void main()
{
	char option;
	char stack[20];
	int tos=-1;

  do
  {
	 cout<<endl<<endl<<endl;
	 cout<<"Menu"<<endl<<endl;
	 cout<<"1.  Play Game"<<endl;
	 cout<<"2.  Show Maze"<<endl;
	 cout<<"Q.  Quit system"<<endl<<endl;
	 cout<<"Please enter option choice :";
	 cin>>option;
	 cin.ignore();
	 switch (option)
	 {
		case '1': play();
				 break;
		case '2': mazeshow();
				 break;
		case 'q':cout<<"Quitting system"<<endl;
				 break;
		default: cout<<"you have entered an incorrect option choice please try again"<<endl<<endl;
	 }
  }
  while (option!='5');


	system("pause");

}
Topic archived. No new replies allowed.