Simple Quiz

I'm trying to write code for a simple quiz using a text file so users can switch/edit the file to display custom questions. I was wondering if there was a way to make the program find a string between two others and display it. EG:
<question1>How are you?</question1>
In the example above, it would then display "How are you?"
you can use the C++ string.h class

or break it into a char array and read begin reading from the char '>' until the char <''

char string[] = "<question1>How are you?</question1>";
int size_of_string = sizeof(string)/sizeof(char);
int start_index;

//returns start position
for(int i = 0; i < size_of_string; i++)
if(string[i] == '>')
start_index = i;

//then load the filler until you hit '<'
for(int i = 0; string[i] != '<'; i++)
//add those characters up

Like i said before, you can probably just use the string.h class



Topic archived. No new replies allowed.