Alright, I am trying to write a handy program that requires a user input of a text file where the User puts their Name on the first line, and on the second line, they put hours of the day they can work. I'm looking to use the "if" statement to sort out the text file, line by line. A good pseudo code would be:
OPEN TEXT FILE
READ LINE 1
IF LINE 1 HAS (Any letter of the alphabet) THEN PARSE THE LETTERS AS A NAME STRING
ELSE (ERROR)
READ LINE 2
IF LINE 2 BEGINS WITH M,T,W,TH,F (letters for days) THEN PARSE TO A TIME INT
ELSE (ERROR)
STOP READING
I know, I know, pseudo code isn't all very helpful when you're asking coding questions, however, my code right now only reads out all the lines in a text file. I'm saw a few read line by line questions on here, so I'll check those out. But my question here is: How do you use IF with fstream? (Or is there some other convention to accomplish this task?)
Aucun commentaire:
Enregistrer un commentaire