Reputation: 71
I've written a program in VB which exports data into a text file, which I want to be read by another program in C++ and then that data be assigned as a variable. The program is essentially a quiz and the program I wrote in VB is question maker that exports all the data required into the text file.
Below is the text file:
test question|test A|test B|test C|test D|A|100|0|0|0|Right, I know this. The answer is 100% A. Good luck!|B|100|0|
From left to right we have, the question, AnswerA, AnswerB, AnswerC, AnswerD, the correct answer, percent 1, 2, 3, 4, (for polling an audience of what they think the answer may be) a friend's answer, a wrong answer (the program eliminates two wrong answers at one point, this answer is the remaining wrong answer) and percent 1 and 2 again (in case they eliminate 2 wrong answers but still want a poll).
I did quite a lot of google searching but found nothing to my following question (perhaps due to the fact I used the wrong keywords, I'm not too educated when it comes to programming jargon). What I want the C++ program to do is read the file and when it sees "|" it knows that what is coming is a new variable. Would I be better using ifstream or something else and how would I tell the program to identify the "|" and make it read whatever is in between as a variable?
Upvotes: 0
Views: 112
Reputation: 2275
Look at the documentation for istream::getline
. You can use the | character as a delimiter.
Upvotes: 0