Hi,
I am trying to read from a txt file but when I use :-
Code:
ifstream StreamName;
StreamName.open("Dieters.txt");
It fails to locate the txt file, which is what is holding the data I wish to use.
I believe my actual code is correct, and so believe it is just that Visual Studio doesn't know where to locate the file.
Here is my code:-
Code:
#include <iostream>
#include <fstream>
using namespace std;
const int MAXPATIENTS = 10;
struct patient
{
int id;
double weight;
double height;
bool ismale;
};
int main()
{
patient patientstruct[MAXPATIENTS];//array of structs
ifstream StreamName;
StreamName.open("Dieters.txt");
if(!StreamName)
{
cout << "phail " << endl;
}
else
{
cout << "opened" << endl;
}
system("pause");
return 0;
}
This is for some practice on a test we had last week, and we were given a pre-made Microsoft Visual Studio Solution file, which fired straight up and contained the txt file, but we use a strange college specific library.
So basically I'm asking how I can use the StreamName.open("Dieters.txt"); line to point to the location of the txt file so that V.Studio can find it, as the code I have posted above works fine when I don't have to use the weird library.
Many thanks for any help!