All pastes #219295 Raw Edit

Unnamed

public cpp v1 · immutable
#219295 ·published 2006-10-24 16:34 UTC
rendered paste body
int parse_file(string namefile, string *quote, string* author, string *year, int nline, int linetoreturn){int counter=0;int i=0;int k=0;linetoreturn=2;char quotec[MAX_CHAR];char authorc[MAX_CHAR];char yearc[MAX_CHAR];char *vettore[3];vettore[0]=&quotec[0];vettore[1]=&authorc[0];vettore[2]=&yearc[0];int lunghezze[2];std::ifstream inf(namefile.c_str());if (!inf)    {    cout << "Error opening the file: "+namefile+" Aborting "<<endl;    exit(1);    }if (inf.is_open())                {                 char ch;                //                //cout<<"linetoreturn:"<<linetoreturn<<" "<<nline<<endl;                assert(linetoreturn<nline);               while(!inf.eof())            	{                inf.get(ch);                //cout<<"line"<<counter;                if(counter==linetoreturn)                            {                                                                                                                     if(i<MAX_CHAR) {                                                           //cout<<ch;                                                           *((vettore[k])+i)=ch;                                                           }                                            i++;                                            if (ch=='\t')	                                                            {                                                           lunghezze[k]=i;                                                           cout<<"I"<<i<<" lk"<<lunghezze[k]<<" K"<<k<<endl;                                                                                i=0;                                                           k++;                                                           cout<<"---->";                                                           }                                                           }                if (ch=='\n')	 {                                  counter++;                                 lunghezze[k]=i;                                 cout<<"I"<<i<<" lk"<<lunghezze[k]<<" K"<<k<<endl;                                                      cout<<"---->";                                 }            	                }                }for(int ki=0;ki<3;ki++){//cout<<lunghezze[ki]<<endl<<endl;for (int ii=0;ii<(lunghezze[ki]);ii++) ;//cout<<*((vettore[ki])+ii);}cout<<endl;                inf.close();                return 0;}