I have a struct that holds 4 variable types, the data of this struct is held in a text file. The struct is made up of question number, question level, question, and question answer. I am trying to print only the question to the console window but atm the program insists on writing first the question number then the level then finally the question then the question answer. I only want to print the question to the console screen. Here's what I have so far:
static void quiz(QuestionStruct[] _quiz)
{
bool asked = true;
int score = 0;
int AmountAsked = 0;
string level = "1";
string ans;
int pos = 0;
var pathToFile = @"..\..\..\Files\questions.txt";
using (StreamReader sr = new StreamReader(pathToFile, true))
{
while (AmountAsked < 20 || score >= 50)
{
Console.Clear();
//int pos = 0;
if (level == "1")
{
AmountAsked++;
questions[pos].Question = sr.ReadLine();
Console.Write(questions[pos].Question);
ans = Console.ReadLine();
if (ans == questions[pos].answer)
{
level = "2";
score = score + 1;
while (questions[pos].Level != "2")
{
pos++;
}
}
}
}
}