-
Registered User
help!!!
This program seems like it should work but it isn't it is probably something stupid that im doing wrong,but i cant figure it out
i dont really know how to use code tags so if u can not read this u can download the program
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{ofstream fout;
ifstream fin;float a,b,c;
fout.open("A:/outfile.dat", ios:ut);
for(int i=0;i<20;i++){
a=0;
b=0;
c=1;
cout<<"Enter three numbers: \n";
cin>>a>>b>>c;
fout<<a<<b<<c<<endl;
}
fout.close();
fin.open("A:/outfile.dat",ios::in);
for (int j=0;j<20;j++){
fin>>a>>b>>c;
cout<<a<<" "<<b<<"/"<<c<<endl;
}
fin.close();
return 0;
}
-
Try outputting the numbers seperated by a space. You're reading and writing in text mode which means your ifstream object won't be able to tell when one number ends and another starts.
Popular pages
Recent additions