So this is assignment number 14 and this is the fourth time Im bothering you...I hope you can help me.
I think Im almost done with it but I can not get "toupper" my name and lastname so it would be copied to the outfile.txt file.
Description: The program writes a while loop that copies all the characters from an input file stream(The file will have my name and lastname) to an output file stream.The only exeption will be that every lowecase is converted to uppercase.the loop should terminate when end-of-file is detected. the information should be writen to the new file.
#include<iostream>
#include<cctype>
#include<fstream>
#include <string>
using namespace std;
int main()
{
char ch=0;
char name=touppercase(ch);
//reads from a previously created file that contains my name and lastname
ifstream fin;
ifstream infile("infile.txt"); //opens the file
if(!infile.good()) throw "I/O error";
while(!infile.eof()) //while loop as specified by the teacher.
{
infile.get(ch);
fin>>ch;
cout<<ch;
}
infile.close();
//process
//this part creates the output file and should write my lastname but this time it
//should be in UPPER cases. this is where I cant get it to work!!!! HELP!
ofstream outfile;
outfile.open("outfile.txt");
if(!outfile.good()) throw "I/O error";
while (!outfile.eof())
{
name=tolower(ch);
cout<<name;
outfile>>name<<endl;
}
outfile.close();
//close file
//opens the file and reads the content to then close the file and program.
ifstream outf;
outf.open("outfile.txt");
if(!outf.good()) throw "I/O error";
while (!outf.eof())
{
outf<<name;
cout<<name;
}
system("pause");
return 0;
}