You will have two file streams: an input file stream for the file to be normalized and an output file stream that contains the normalized file. You should issue an error message and exit the program if either file cannot be opened.
Your program should prompt the user for the filename of the file to be normalized (the input file). The output filename should be the input filename with ".normal" added to it. For example, if the input file is "data.txt", the output file name will be "data.txt.normal".
Be careful to not leave an extra blank line at the end of your output file.
My question here is how do I rename the file that the user entered to have a ".normal" at the end of it? I was thinking along the lines of having to string names and changing the second string's name and use that as the output file. any examples cause I didn't exactly get that to work.
However, this would only work with std::string you cannot do this with char arrays. Are you allowed to use std::string ? Because that would be much easier.
If not you need to use a for loop to add characters one at a time to the end of the file name, and place a null character '\0' at the end. First you need to find out where the actual end of the file name is - remember array subscripts start at 0.
Once you have declared a char array, you don't need to put the size of the array into statements.
Yeah. Since the professor hasn't gone over it yet, we can't use it.
"I didn't teach it so you can't use it. Or I consider that you cheated or used outside help."
applies to everything he hasnt taught us. printf, scanf, and etc
i get the error "no matching function to call to 'std::basic_ifstream<char>::open(std::string&)'
It works perfectly in c++ shell here but not in the mac terminal
Are you sure this is the entire assignment? It just seems too easy & trivial with strings. I am confused now as to whether you should be using arrays. I also hope there is no confusion over the difference between a char array and a std::string?
You said you were allowed to use strings, but then said no std::string ? The 2 are equivalent.
Does the mac have any special naming conventions for file names - does one have to type in the whole path with escape characters for the slashes? Is the file in the same directory as the program?
You might need the c_str function which might be necessary when dealing with file names.