Need help!!

Hello everyone, i wrote a program and there are few errors that i can't fix. Please help me correct it.
I wrote QuizMe, a program for doing quizzes. A quiz is a sequence of questions the user is trying to answer to. At the end of the quiz, the program gives the final score of the user (i.e. how many good answers) and for each wrong answer the program displays both the (wrong) answer from the user and the (correct) answer from the program. The questions can be about general topics or can focus on some area like sports or science. QuizMe will have only four kinds of questions: questions about science, geography, sport or general topics (we call each topic a category).

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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
  #include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <vector>
#include <fstream>
#include <iomanip>
#include <windows.h>
#include <ctime>
using namespace std;

struct QuestionInfo
    {
        int category;
        int level;
    };

struct Question
    {
        QuestionInfo info;
        string question;
        string answer;
    };
int opening();
void closing();
void clearConsole();
vector<Question> All_questions();

void RN(string a[10],int c,int l);
void RQ(string a[10],Question b[10]);
string normalize(string s);
void doquiz(int c,int l);
vector<Question> v=All_questions();
int main()
{
	srand((unsigned)time(0));
	string b[11];
	int a;
	Question q[11];
	   while (a!=2)
   	{
    clearConsole();
   	a=opening();
   		closing();
	   }
}


void clearConsole()
{
    if (system("CLS"))
        system("clear");
};


vector<Question> All_questions()
{
	Question q;
	vector<Question> v;
	string category,level;
    string enter,info;

    	ifstream infile;
    infile.open("database.txt");


    while ( infile >> info)
{


    istringstream iss(info);


    getline(iss,category);
    getline(iss,level);

	getline(infile,q.question);
	getline(infile,enter);
	getline(infile,q.answer);


		if(category=="general")
			q.info.category=2;
		if(category=="science")
			q.info.category=3;
		if(category=="geography")
			q.info.category=4;
		if(category=="sport")
			q.info.category=5;

		if(level=="easy")
			q.info.level=1;
		if(level=="medium")
			q.info.level=2;
		if(level=="hard")
			q.info.level=3;

    v.push_back(q);

}
    infile.close();
    return v;
}

void RN(string a[],vector<Question>& v,int c,int l)
{


	int num,i,j,t,k[100];
	vector<string> n;
	if ((c==1) && (l!=0))
		for (i=0;i<v.size();i++)
	{
		if (v[i].info.level==l)
			n.push_back(v[i].info.size);
	}
	else if ((l==0) && (c!=1))
		for (i=0;i<v.size();i++)
	{
		if (v[i].info.category==c)
			n.push_back(v[i].info.category);
	}
	else
		for (i=0;i<v.size();i++)
	{
		if (v[i].info.category==c && v[i].info.level==l)
			n.push_back(v[i].info.level);
	}
	const int MIN = 1;
	const int MAX = n.size();
	i=0;
	while (i<=10)
	{

		t=0;

		num = MIN + rand() % MAX;
		for (j=0;j<=i;j++)
			if (n[num]==a[j])
			{
				t=1;
			//	break;
			}

		if (t==0)
		{
			a[i]=n[num];
			i++;
		}
	}

}

void RQ(string a[10],Question b[10])
{
	for (int i=0;i<10;i++)
	{
		b[i]=v[atoi(a[i].c_str())];
	}
}

string normalize(string s)
{
	string a;

	for (int i=0;i<s.length();i++)
		{
			if(s[i]==' ')
				{
				if (s[i+1]!=' ')
					a=a+' ';
				}
			else
			{

				char character = tolower(s[i]);
        		s[i] = character;
				a=a+s[i];
			}

		}
		if (a[0]==' ')
			a.erase(a.begin()+0);
		if (a[a.length()-1]==' ')
			a.erase(a.length()-1);
		return a;
}
void doquiz(int c,int l){
	int score=0;

	Question b[10];
	string a[10],answer[10];
	RN(a,c,l);
	RQ(a,b);
	cin.ignore(1);
	for(int i=0;i<10;i++)

		{
			cout<<i+1<<". "<<b[i].question;
			cout<<"Enter your answer: ";
			getline(cin,answer[i]);
			if (normalize(answer[i])==normalize(b[i].answer))
				{
					score++;
					answer[i]=b[i].answer;
				}
		}
		cout<<"\n\nYour score is " << score <<"/10 .\n";
		cout<<"Your wrong answer: \n";
		for(int i=0;i<10;i++)
			if(answer[i]!=b[i].answer)
				cout<<i+1<<". "<<answer[i] <<" / correct answer: "<<b[i].answer<<endl;

}

void closing()
{
	cout<<setw(12)<<"\nThanks for using Quizme!!!";
	//return 0;
}
int opening()
{
	int a,b,c;
	string q;
	cout<<setw(20)<<"WELCOME TO QUIZME"<<endl;
	cout<<setw(8)<<"\n\nWould you like to\n"<<"\n1. Do the quiz\n"<<"2. Quit"<<endl<<"Enter your choice:  ";
	cin>>a;
	switch(a)
	{
		case 1:
			{
				cout<<setw(8)<<"\nChoose your category\n"<<"\n1. All category\n2. General\n3. Science\n4. Geography\n5. Sport\nEnter your choice: ";
				cin>>b;
				while (b<1 || b>5)
                {
                    clearConsole();
                    cout<<setw(8)<<"\nChoose your category again:\n"<<"\n1. All category\n2. General\n3. Science\n4. Geography\n5. Sport\nEnter your choice: ";
				cin>>b;
                }
				cout<<setw(8)<<"\nLevel:\n0. All level\n1. Easy\n2. Medium\n3. Hard\nEnter your choice: ";
				cin>>c;
				while (c<0 || c>3)
                {
                    clearConsole();
                    cout<<setw(8)<<"\nChoose your level again:\n0. All level\n1. Easy\n2. Medium\n3. Hard\nEnter your choice: ";
				cin>>c;

                }
				doquiz(b,c);
				cout<< "\n    Another QUIZ? \n y to continue, n to quit !";
				cin>>q;
				if (q=="n")
					return 2;
				else
				return 1;
			}

		case 2:
			{
			return 2;
			}
	}
}



Hello everyone, i wrote a program and there are few errors that i can't fix.

Please describe the errors.
Line 38: a is an uninitialized variable.

Line 40: This is undefined behavior due to the uninitialized variable.

Line 112,118,124,166: You have a type mismatch between i and size().

Line 115: size is not a member of info.

Line 121,124: Type mismatch on push_back. push_back() is expecting a string. You're trying to push an int.

Your compiler should have given you these errors.
Registered users can post here. Sign in or register to post.