My question relates to the assignment I'm working on. There seem to be several ways to get closer to the assignment.
The program I am writing will be a filter for text files. The goal of the assignment is to gain experience with fstream and getline.
Requirements:
- Read one text file (in any way possible, not necessarily all at once)
- Writing to a separate text file (in any way possible, adding or writing character by character)
- It is assumed that each offer ends for a period.
- The first letter of each sentence must be uppercase.
- Everything except the first letter of each sentence must be lowercase. (nouns too are a trivial example)
I have a working draft of a program that I wrote, but getline does not match the way it reads my text file. Basically, he will read one line as a line, which is what I want. As he reads in the second line; however, the program throws a run-time error halfway along the line, and Windows disables it.
Does getline have a buffer that fills up and needs to be cleared after each line?
My pseudo code for the program:
- Use getline to read in a row from line x, stopping over a period (.).
- Iterate over character strings, the top of the first letter, and then the bottom of the rest.
- Read on another line that continues after the last period (.) In the text file.
- Repeat until the text file is read.
- Writing to a second text file.
I implement getline as follows:
getline(fileIN, str1, '.')
str1 is a line that is read from each line.
Am I using getline correctly? Do I think this problem is correct and effective?
* I realized how I ended this extended question / section that getline can use more memory for the characters "\ r" or "\ n" at the ends of lines or for reasons not related to memory, getline is wrong (according to my goals ) sentences that wrap on new lines. Does getline really not handle sentence / hyphenation?
Also, is there a way to dynamically tell getline to read the first line before the period (.) Or new line ('\ n') that FIRST ever appears?
Thank you for your time and attention.
dwith source share