i have this:
Code:
int main()
{
ifstream infile("/home/user_acct/path/to/file/to/read.txt");
if (!infile)
{
cerr << "Could not open file!" << endl;
return 1;
}
}
i want to replace '/home/user_acct' with a variable so i can use
the code on more than one box but am getting errors. this is
something i've tried:
Code:
int main()
{
char homepath = getenv("HOME");
ifstream infile(homepath + "/path/to/file/to/read.txt");
if (!infile)
{
cerr << "Could not open file!" << endl;
return 1;
}
}
could someone show me how to do what i'm trying to do here?
thanks,
BabaG