Problem Opening Data FIle

I have been wot=rking on my social secutriy EXAMPLE program from a book i have to prectice input files in c++. It wont open for me when i run the program tho. would anyone know how to fix it?




#include <string>
#include <fstream>

using namespace std;
int main()
{
ifstream inData;
ofstream outData;
inData.open("name.dat");
outData.open("name.out");

string SocialSecurity; //Social Security Number
string FirstName; //First Name
string LastName; //Last name
string MiddleName; //Middle name
string MiddleInitial; //Middle Initial

inData >> SocialSecurity >> FirstName >> MiddleName >> LastName ;

MiddleInitial = MiddleName.substr(0, 1) + ".";

outData << MiddleInitial << FirstName << LastName << SocialSecurity << endl;

inData.close();
outData.close();
return 0;
}
Topic archived. No new replies allowed.