It was the shift of the char pointer. I commented that out and the program runs fine now. Here was the bad code with the bug commented out:
Code:
void wordtomusicvalue::write_file_three()
{
char c;
ifstream theInputString("file_out.txt");
ofstream fout3("file_out_3.txt", fstream::app);
while (theInputString.get(c))
{
if(c == 32)
{
//c -= 1;
fout3 << "\n";
}
else if(c == 46)
{
continue;
}
fout3 << c;
}
theInputString.close();
fout3.close();
}
And here is the program results now everything is working good:
Code:
Enter your sentence, end it with a period: to infinity and beyond.
Input sentence to program, from input.txt;
to
value: 1: musical value C: 261Hz: red
infinity
value: 4: musical value C: 261Hz: red
and
value: 2: musical value g sharp: 415Hz: cyan
beyond
value: 2: musical value g sharp: 415Hz: cyan
Press any key to continue . . .
Process returned 0 (0x0) execution time : 11.670 s
Press any key to continue.