I know how to open and display a text file, just wondering if you can use the text from a terxt file to work for a struct,
eg.
Txt file
"blablabla" , 3
or
"blablabla" 3
and to read the bla bla bla on the screen and compare it to 3?
I know how to open and display a text file, just wondering if you can use the text from a terxt file to work for a struct,
eg.
Txt file
"blablabla" , 3
or
"blablabla" 3
and to read the bla bla bla on the screen and compare it to 3?
I have no idea what you want to do. Do you want to put data from a text file into a struct? Do you want to compare what somebody types (I guess that might be what you mean by "read what's on the screen") to a struct, or a text file, or both?
Sorry I will be a bit more specific.
I have a question scruct which questions in it,
I was wondering if I could put that info (Question, Answer) into a text document and load it in from there so I can just add questions on the fly without re compilingCode:RiddleGenerator::QnA RiddleGenerator::mQnA[RiddleGenerator::QuestionCount] = { { "What shape as 4 sides?\n\t1)Triangle\n\t2)Circle\n\t3)Square", 3 }, { "What is the capital of England?\n\t1)Paris\n\t2)London\n\t3)Washington", 2 } // NEW QUESTIONs CAN GO IN THE ABOVE SPACE <---! };
Well, yes, I suppose. You'll have to be competent about how you organize your struct/class -- for instance, you can't specify RiddleGenerator::QuestionCount, but rather the data will. There's no need to write it like it's C, because it's not C, it's a text file. Just read in the file and stuff it into a vector as you go.
I can only find stuff about saving out variables but not the rest, i tried googling but cant find anything useful.
Wondering if anyone knwos a book or a reference for this?
Not entire lines of words and then a number like with the above structure
Then I guess your magic word is "parsing", if you mean "I want to split my line that I just read in on the comma".
Yes I would say so,
I just wish to read the questiosn and answers from a text file