Hello everyone,
I need help. In my assignment i have an input file that contains string data: ----> i love music and chicken. today is the first day of the rest of your life. my name is john.
I must change it to the following in the output file: ----> I love music and chicken. Today is the first day of the rest of your life. My name is john.
I need to use this function to help achieve this:
void initialCap(string&);
No classes are required.
All the white space is erased initially that's why i use the insert function. However, the last word "john" is erased when i use this function. How do i increase the size of the string in order to still have john included in the output. I realize string is an array and arrays are immutable but i know there has to be a way around this. Also, I can't capitalize the words i need to capitalize. I need to use the replace function but, i'm not sure how the parameters work.
Any help is greatly appreciated
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void initialCap(string&);
int main () {
ifstream inputFile;
inputFile.open("C:/Notepad++/input.txt");
ofstream outputFile;
outputFile.open("c:/Notepad++/output.txt");
string baseSentence = "";
string str2 = " dave";
if (inputFile) {
while (!inputFile.eof()) {
string str1 = baseSentence;
str1.insert(0," ");
inputFile>>baseSentence;
cout<<str1;
outputFile<<baseSentence;
}
}
else {
cout<<"this file does not exist dave!";
}
inputFile.close();
outputFile.close();
cout << "\n\n";
system("pause");
return 0;
}