Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
C++ read individual characters/lines in a file
If I am not being very clear, please ask, I really want to make this program. Thanks!
Undoubtedly, yes, a loop of some sort will be needed somewhere.
I understand that homework-type questions are not answered on here very often, though, for the very reason that they are meant to be your work, not someone elses. Also, one of the best ways to learn is to nut it out for yourself.
Not to say of course that no-one will help. I think most people would like to see you give it a good shot first, maybe try quite a few methods, and only come back here if you are truly stuck, but not at the beginning of the task.
Is it just one long string of a text file? Or is each character on a different line?
Either way is pretty simple, but can take different approaches.
If it is just one long string of characters, read them into a character array and work with it there (hint: a string can be used as a char array). If it is one on each line, then setup a loop and read each line separately with getline, do the comparison and move on.
And of course, there are several other ways to do it, those two were on the top of my head.
Code is Poetry
Also look at an ASCII chart you'll see part of your solution done for you.