YourFace
<span style="color:#9C9C9C;"><strong>Runner Up - T
- Reaction score
- 91
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
fstream File;
char FirstName[256];
char LastName[256];
int Age;
int IsMarried;
// should open file for input but wtf
File.open("Data.txt", ios::in);
if (File.is_open())
{
File >> FirstName >> LastName >> Age>>IsMarried;
cout <<"Your name is " << FirstName << " " << LastName;
cout <<" and you are " << Age << " years old" << endl;
if (IsMarried == 1)
{
cout << "You're married, make sure not to make lots of kids" << endl;
}
else if (IsMarried == 0)
{
cout << "Don't worry, there's like 20 chicks that want to go out with you in class" << endl;
}
}
else
{
cout << "Couldn't open it :(" << endl;
}
File.close();
return 0;
}
Whenever I run this code, I always get couldn't open it . I have a file called Data.txt but the program doesn't take the input from it and display it on the screen like it's suppose to!
Does anyone know how to fix this?