#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
struct payroll
{
int id;
string job;
char builddept;
string position;
char letter;
string paygroup;
float totalhours;
};
payroll employee;
const char lttr = 'L';
inFile = "C:/timeforce.txt"
outFile = "C:/timberline.txt"
int main()
{
ifstream ins;
ofstream outs;
ins.open(inFile);
if(ins.fail())
{
cerr << "*** ERROR: Cannot open " << inFile
<< " for input." << endl;
return EXIT_FAILURE;
}
outs.open(outFile);
if (outs.fail())
{
cerr << "*** ERROR: Cannot open " << outFile
<< " for output." << endl;
return EXIT_FAILURE;
}
ins >> employee.id;
ins >> employee.job;
ins >> employee.builddept;
ins >> employee.position;
ins >> employee.paygroup;
ins >> employee.totalhours;
cout <<employee.id;
cout <<employee.job;
cout <<employee.builddept;
cout <<employee.position;
cout <<employee.letter;
cout <<employee.paygroup;
cout <<employee.totalhours;
cout <<"Input file copied to output file." << endl;
ins.close();
outs.close();
return 0;
}
Hey Phlip
Since you seem to have quite a bit more experience in programming than
I do I will come to you again for help. I have made the revision you
suggested and here are the errors I am getting if you could offer any
more advice I would greatly appreciate it.
Compiling...
FP1.cpp
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(29) : error C2501: 'inFile' : missing
storage-class or type specifiers
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(30) : error C2440: 'initializing' :
cannot convert from 'char [17]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or
function-style cast
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(30) : error C2146: syntax error : missing
';' before identifier 'outFile'
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(30) : error C2501: 'outFile' : missing
storage-class or type specifiers
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(32) : error C2440: 'initializing' :
cannot convert from 'char [18]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or
function-style cast
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(32) : error C2144: syntax error : missing
';' before type 'int'
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(37) : error C2664: 'void __thiscall
std::basic_ifstream<char,struct std::char_traits<char> >:
pen(const
char *,int)' : cannot convert parameter 1 from 'int' to 'const char *'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(45) : error C2664: 'void __thiscall
std::basic_ofstream<char,struct std::char_traits<char> >:
pen(const
char *,int)' : cannot convert parameter 1 from 'int' to 'const char *'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(54) : error C2679: binary '>>' : no
operator defined which takes a right-hand operand of type 'class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<c
har> >' (or there is no acceptable conversion)
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(56) : error C2679: binary '>>' : no
operator defined which takes a right-hand operand of type 'class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<c
har> >' (or there is no acceptable conversion)
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(57) : error C2679: binary '>>' : no
operator defined which takes a right-hand operand of type 'class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<c
har> >' (or there is no acceptable conversion)
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(60) : error C2679: binary '<<' : no
operator defined which takes a right-hand operand of type 'class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<c
har> >' (or there is no acceptable conversion)
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(62) : error C2679: binary '<<' : no
operator defined which takes a right-hand operand of type 'class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<c
har> >' (or there is no acceptable conversion)
c:\documents and settings\administrator\my
documents\programming\fp1.cpp(64) : error C2679: binary '<<' : no
operator defined which takes a right-hand operand of type 'class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<c
har> >' (or there is no acceptable conversion)
Error executing cl.exe.
FP1.exe - 14 error(s), 0 warning(s)