C
coinjo
#include<fstream>
using namespace std;
int main()
{
ifstream indata;
ofstream outdata;
indata.open("D:\\C++\\New Folder\\infile.txt");
outdata.open("D:\\C++\\New Folder\\outfile.txt");
int a=0;
int i=0;
int b=0;
while(a<9)
{
indata>>i;
b=i;
outdata<<b<<" ";
a=a+1;
}
indata.close();
outdata.close();
return 0;
}
This is in the infile.txt
1
2
3
4
5
6
7
8
9
The infile.txt and the outfile.txt are both in the same folder but when
i run the program even after deleting the outfile.txt it shows this:
0 0 0 0 0 0 0 0 0
rather than this:
1 2 3 4 5 6 7 8 9
PLEASE HELP!
using namespace std;
int main()
{
ifstream indata;
ofstream outdata;
indata.open("D:\\C++\\New Folder\\infile.txt");
outdata.open("D:\\C++\\New Folder\\outfile.txt");
int a=0;
int i=0;
int b=0;
while(a<9)
{
indata>>i;
b=i;
outdata<<b<<" ";
a=a+1;
}
indata.close();
outdata.close();
return 0;
}
This is in the infile.txt
1
2
3
4
5
6
7
8
9
The infile.txt and the outfile.txt are both in the same folder but when
i run the program even after deleting the outfile.txt it shows this:
0 0 0 0 0 0 0 0 0
rather than this:
1 2 3 4 5 6 7 8 9
PLEASE HELP!