Hello everyone,
I'm trying to figure out how input/output files work. I got warnings, and it compiled, but when I tried to run the program, it gave me
input file failed
press any key to continue
I thought we are supposed to list the directory, and my input file is saved in the same folder, and the same directory, any suggestions??
Thanks a million!!
p.s. this is only the partial code.
Code:
int main()
{
string first_name; //declare string variable first name
string last_name; //declare string variable last name
string gender; //declare string variable gender
int age; //declare int variable age
string type_coverage; //declare string variable type of coverage
string club_member; //declare string variable health club
//member
string smoker; //declare string variable smoker
int zip_code; //declare int variable zip code
float basic_premium; //declare int variable basic premium
float discount_premium; //declare int variable discount premium
float premium; //declare int variable premium
ifstream inFile; //declare file streams
ofstream outFile;
inFile.open("C:\Windows\C++\proj4.in.txt"); //opens the input file
outFile.open("C:\Windows\C++\proj4.out.txt"); //opens the output file
if(!inFile)
{
cout << "Input file failed!" << endl;
return 1; //terminates the program if input fails
}