Hi all. I have an assignment for class (obviously I am new to this), that requires us to read from a file and then print out the first 22 characters from each line within that file. I have tried using getline and get, but can't seem to get it to work right. Is there a way to limit the amount of symbols that 'get' reads and then move to the next line and do the same thing? Thanks so much for your help!!
Jump to Post
I think a better approach would be just use getline to grab all of a line into a large string, then print out the first 22 characters that appear (or less if the line's not that long.)
You can (with char array type strings) limit how much input getline …
All 4 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.