I am writing this C++ program for my class. My problem is that I don't know where to put the files program1.dat and program1.out or know what kind of files they are supposed to be. There are no build errors, and it works in Visual Basic at school, because I know where to put those files and what kind of files they are. I can get it to work in xcode if I declare the variable cm in the program and use cin and cout, but I need to be able to put my data in the file program1.dat and have the program read the data out of that file and output it into the file program1.out I tried putting blank text files with those names everywhere in the subfolders on the side, but none worked. I could put them somewhere else on my computer and access them by using the full file name, but I want them to just be a part of the project. Please help!!!! I don't want to have to use Visual Basic. I;m pretty sure I'm missing something really simple here. The code is below, the last build succeeded.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main ()
{
int cm, tin, yds, ft, inch, i;
ifstream inf;
inf.open ("program1.dat");
ofstream outf;
outf.open ("program1.out");
for (i=1; i<= 10; i++)
{
inf >> cm;
tin = cm/2.54;
yds = tin/36;
ft = tin%36/12;
inch = tin%36%12;
outf
<< cm << "Cm = "
<< yds << " Yards, "
<< ft << " Feet, "
<< inch << " Inches, "
<< "for the sum of approximately "
<< tin << " Total Inches"
<<endl;
}
}
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main ()
{
int cm, tin, yds, ft, inch, i;
ifstream inf;
inf.open ("program1.dat");
ofstream outf;
outf.open ("program1.out");
for (i=1; i<= 10; i++)
{
inf >> cm;
tin = cm/2.54;
yds = tin/36;
ft = tin%36/12;
inch = tin%36%12;
outf
<< cm << "Cm = "
<< yds << " Yards, "
<< ft << " Feet, "
<< inch << " Inches, "
<< "for the sum of approximately "
<< tin << " Total Inches"
<<endl;
}
}