Nov 21, 2013 at 6:37am UTC
hi,i wanna give a file from notepad that i dont know the number of row and column like
15.0 12.2 13.8
12 54 7 6 4
12 8 74 90 76
i write this program,plz show me my mistake
#include <iostream>
#include <string>
#include<fstream>
using namespace std;
int main()
{
string s,ss;
double x,y,z;
int * f;
int a,b,c,i,j,row,col;
ifstream A;
ofstream B;
ifstream C;
A.open("C:/Users/milad/Desktop/miladam.txt");
i=0;
while (!A.eof())
{
getline(A,s);
A>>s;
i++;
}
row=i;
A.close();
f=new int [row];
A.open("C:/Users/milad/Desktop/miladam.txt");
for(j=0;j<row;j++)
{
getline(A,ss);
A>>ss;
B.open("C:/Users/milad/Desktop/miladam10000.txt");
B<<ss;
B.close();
C.open("C:/Users/milad/Desktop/miladam10000.txt");
col=0;
while(!C.eof())
{
C>>z;
col++;
}
C.close();
cout<<col;
}
cin>>x;
return 0;
}
its output is 114
Nov 21, 2013 at 7:28am UTC
[#include <iostream>
#include <string>
#include<fstream>
using namespace std;
int main()
{
string s,ss;
double x,y,z;
int * f;
int a,b,c,i,j,row,col;
ifstream A;
ofstream B;
ifstream C;
A.open("C:/Users/milad/Desktop/miladam.txt");
i=0;
while (!A.eof())
{
getline(A,s);
A>>s;
i++;
}
row=i;
A.close();
f=new int [row];
A.open("C:/Users/milad/Desktop/miladam.txt");
for(j=0;j<row;j++)
{
getline(A,ss);
A>>ss;
B.open("C:/Users/milad/Desktop/miladam10000.txt");
B<<ss;
B.close();
C.open("C:/Users/milad/Desktop/miladam10000.txt");
col=0;
while(!C.eof())
{
C>>z;
col++;
}
C.close();
cout<<col;
}
cin>>x;
return 0;
}
][/code]
Nov 21, 2013 at 7:29am UTC
[#include <iostream>
#include <string>
#include<fstream>
using namespace std;
int main()
{
string s,ss;
double x,y,z;
int * f;
int a,b,c,i,j,row,col;
ifstream A;
ofstream B;
ifstream C;
A.open("C:/Users/milad/Desktop/miladam.txt");
i=0;
while (!A.eof())
{
getline(A,s);
A>>s;
i++;
}
row=i;
A.close();
f=new int [row];
A.open("C:/Users/milad/Desktop/miladam.txt");
for(j=0;j<row;j++)
{
getline(A,ss);
A>>ss;
B.open("C:/Users/milad/Desktop/miladam10000.txt");
B<<ss;
B.close();
C.open("C:/Users/milad/Desktop/miladam10000.txt");
col=0;
while(!C.eof())
{
C>>z;
col++;
}
C.close();
cout<<col;
}
cin>>x;
return 0;
}
]