Hi everyone Im using xcode in c++ language and I am having trouble finding the place to save my txt file so the program would recognize it.
This is the code i have.
#include <iostream>
#include <fstream>
using namespace std;
int main (int argc, char * const argv[]) {
int x;
ifstream in;
in.open("Input.txt");
if(!in)
{
cout<<"\nProgram cannot find the input"<<endl;
return 1;
}
in>>x;
while (in) {
cout<<"Number"<<x<<endl;
in>>x;
}
in.close();
return 0;
}
The program displays the cout inside the if so its clearly not finding the txt file.
If anyone can help me please do.
Thanks
This is the code i have.
#include <iostream>
#include <fstream>
using namespace std;
int main (int argc, char * const argv[]) {
int x;
ifstream in;
in.open("Input.txt");
if(!in)
{
cout<<"\nProgram cannot find the input"<<endl;
return 1;
}
in>>x;
while (in) {
cout<<"Number"<<x<<endl;
in>>x;
}
in.close();
return 0;
}
The program displays the cout inside the if so its clearly not finding the txt file.
If anyone can help me please do.
Thanks