I writing with borland C++ compiler. I want to read numbers with 5 decimal places from text file then save it into another text file.
I wrote my program as below:
main
{
double Bid[25], Be1[25],Bn1[25];
int i,no=10,j,p;
char filename[30];
ifstream fp1;
fp1.open("bufile2.txt");
cout<<"\n id lat long";
for (i=1;i<=no;i++)
{
fp1>>Bid[i]>>Be1[i]>>Bn1[i];
cout<<"\n "<<i<<" "<<Bid[i]<<" "<<Be1[i]<<" "<<Bn1[i];
}
fp1.close();
getch();
return 0;
}
my input file is as follow:
id lat long
1 101.28411 2.91245
2 101.28211 2.91345
3 101.28301 2.91345
4 101.28401 2.91345
5 101.28501 2.91345
6 101.28001 2.91445
7 101.28101 2.91445
8 101.28201 2.91445
9 101.28301 2.91445
10 101.28401 2.91445
my problem is, the Be1[i]... not outputting 5 decimal number in my stored file "result.txt". It only give me 3 decimal places. The result is as followed:
id lat long
1 101.284 2.91245
2 101.282 2.91345
3 101.283 2.91345
4 101.284 2.91345
5 101.285 2.91345
6 101.280 2.91445
7 101.281 2.91445
8 101.282 2.91445
9 101.283 2.91445
10 101.284 2.91445
Help me please