参数传递问题
我编了个函数传递四个参数,我想把一个由01组成的文件每一行对应的01相加 如:10011
编译无措只是执行时候出错,请大家帮我看看 + 01110
= 11121
int main()
{
...............
int *count=new int[100];
ifstream in;
string filename1;
cout<<"please input the filename you want to mine:";
cin>>filename1;
count=generate_set_including_frequent(cel,filename1,in,num_frequent-set1.count);
for(int d;d<20;d++)
cout<<count[d];
return 0;
....................
}
int * generate_set_including_frequent(cell * cell,string& filename1,ifstream in,int length)
{
int *count=new int[200];
in.open(filename1.c_str());
if(in.fail())
{
cout<<"File in.txt could not be opened";
exit(1);
}
else
do
{
string s;
getline(in,s);
for(int i=0;i<length;i++)
cell[i].num_1fre+=::atoi(s.c_str());
}while(!in.eof());
in.close();
for(int j=0;j<length;j++)
count[j]=cell[j].num_1fre;
return count;
}
还有个cell类
class cell
{
public:
int num_1fre;
char _item;
};
这个文件我输入的是bool型的01,而相加需要int型,我把它们取进string类型肯定不妥吧,请高手指点