Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > I just want get this portion of the code to compile.

Reply
Thread Tools

I just want get this portion of the code to compile.

 
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:52*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > On 05/ 3/12 07:25 PM, Charles Wilson wrote:
> > > I believe that my problem is in how I am doing my C++ strings. But I
> > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > #include<iomanip>
> > > #include<iostream>
> > > #include<fstream>
> > > #include<cstring>
> > > using namespace std;

>
> I can't believe how long it took me to find the bug!
>
> RULE 1: DON'T USE "using namespace std;"
> you'll find std::string isn't defined
>
>
>
> > > int main()
> > > {
> > > * * * struct{int chronum;string pname;int next;}//makes structure box with C
> > > ++ style string
> > > * * * * * * * plist[50],temp;//give the number of colmns
> > > * * * int n=0,end,maxindex,i;
> > > * * * ifstream fin;
> > > * * * ofstream fout;
> > > * * * fin.open("pres.dat");
> > > * * * fout.open("hw7.dat");
> > > * * * fin>>plist[n].pname;//inputs president name into list
> > > * * * while(!fin.eof())
> > > * * * * * * * {
> > > * * * * * * * *plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > * * * * * * * *n++;//tracks current president
> > > * * * * * * * *fin>>plist[n].pname;
> > > * * * * * * * }
> > > * * * for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > than removes one of end each time.

>
> what?
>
>
>
> > > * * * * * * * {
> > > * * * * * * * *maxindex=0;
> > > * * * * * * * *for(i=1;i<=end;i++)

>
> > > * * * * * * * * * * * if(plist[i].pname>plist[maxindex].pname)
> > > * * * * * * * * * * * * * * * maxindex=i;
> > > * * * * * * * *temp=plist[maxindex];
> > > * * * * * * * *plist[maxindex]=plist[end];
> > > * * * * * * * *plist[end]=temp;
> > > * * * * * * * }
> > > * * * //cout.setf(ios::fixed);
> > > * * * //cout.setf(ios::showpoint);
> > > * * * //cout.precision(2);
> > > * * * //cout<

> > *return 0;
> > > }

>
> > What compile errors do you get? *The code looks legal.

>
> cut down version of the code:-
>
> 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

in responce to the your question what. That is simply a note for me to
figure exactly how that algorithm is workin.
 
Reply With Quote
 
 
 
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:52*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > On 05/ 3/12 07:25 PM, Charles Wilson wrote:
> > > I believe that my problem is in how I am doing my C++ strings. But I
> > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > #include<iomanip>
> > > #include<iostream>
> > > #include<fstream>
> > > #include<cstring>
> > > using namespace std;

>
> I can't believe how long it took me to find the bug!
>
> RULE 1: DON'T USE "using namespace std;"
> you'll find std::string isn't defined
>
>
>
> > > int main()
> > > {
> > > * * * struct{int chronum;string pname;int next;}//makes structure box with C
> > > ++ style string
> > > * * * * * * * plist[50],temp;//give the number of colmns
> > > * * * int n=0,end,maxindex,i;
> > > * * * ifstream fin;
> > > * * * ofstream fout;
> > > * * * fin.open("pres.dat");
> > > * * * fout.open("hw7.dat");
> > > * * * fin>>plist[n].pname;//inputs president name into list
> > > * * * while(!fin.eof())
> > > * * * * * * * {
> > > * * * * * * * *plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > * * * * * * * *n++;//tracks current president
> > > * * * * * * * *fin>>plist[n].pname;
> > > * * * * * * * }
> > > * * * for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > than removes one of end each time.

>
> what?
>
>
>
> > > * * * * * * * {
> > > * * * * * * * *maxindex=0;
> > > * * * * * * * *for(i=1;i<=end;i++)

>
> > > * * * * * * * * * * * if(plist[i].pname>plist[maxindex].pname)
> > > * * * * * * * * * * * * * * * maxindex=i;
> > > * * * * * * * *temp=plist[maxindex];
> > > * * * * * * * *plist[maxindex]=plist[end];
> > > * * * * * * * *plist[end]=temp;
> > > * * * * * * * }
> > > * * * //cout.setf(ios::fixed);
> > > * * * //cout.setf(ios::showpoint);
> > > * * * //cout.precision(2);
> > > * * * //cout<

> > *return 0;
> > > }

>
> > What compile errors do you get? *The code looks legal.

>
> cut down version of the code:-
>
> 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

in responce to the your question what. That is simply a note for me to
figure exactly how that algorithm is workin.
 
Reply With Quote
 
 
 
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:52*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > On 05/ 3/12 07:25 PM, Charles Wilson wrote:
> > > I believe that my problem is in how I am doing my C++ strings. But I
> > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > #include<iomanip>
> > > #include<iostream>
> > > #include<fstream>
> > > #include<cstring>
> > > using namespace std;

>
> I can't believe how long it took me to find the bug!
>
> RULE 1: DON'T USE "using namespace std;"
> you'll find std::string isn't defined
>
>
>
> > > int main()
> > > {
> > > * * * struct{int chronum;string pname;int next;}//makes structure box with C
> > > ++ style string
> > > * * * * * * * plist[50],temp;//give the number of colmns
> > > * * * int n=0,end,maxindex,i;
> > > * * * ifstream fin;
> > > * * * ofstream fout;
> > > * * * fin.open("pres.dat");
> > > * * * fout.open("hw7.dat");
> > > * * * fin>>plist[n].pname;//inputs president name into list
> > > * * * while(!fin.eof())
> > > * * * * * * * {
> > > * * * * * * * *plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > * * * * * * * *n++;//tracks current president
> > > * * * * * * * *fin>>plist[n].pname;
> > > * * * * * * * }
> > > * * * for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > than removes one of end each time.

>
> what?
>
>
>
> > > * * * * * * * {
> > > * * * * * * * *maxindex=0;
> > > * * * * * * * *for(i=1;i<=end;i++)

>
> > > * * * * * * * * * * * if(plist[i].pname>plist[maxindex].pname)
> > > * * * * * * * * * * * * * * * maxindex=i;
> > > * * * * * * * *temp=plist[maxindex];
> > > * * * * * * * *plist[maxindex]=plist[end];
> > > * * * * * * * *plist[end]=temp;
> > > * * * * * * * }
> > > * * * //cout.setf(ios::fixed);
> > > * * * //cout.setf(ios::showpoint);
> > > * * * //cout.precision(2);
> > > * * * //cout<

> > *return 0;
> > > }

>
> > What compile errors do you get? *The code looks legal.

>
> cut down version of the code:-
>
> 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

in responce to the your question what. That is simply a note for me to
figure exactly how that algorithm is workin.
 
Reply With Quote
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:52*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > On 05/ 3/12 07:25 PM, Charles Wilson wrote:
> > > I believe that my problem is in how I am doing my C++ strings. But I
> > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > #include<iomanip>
> > > #include<iostream>
> > > #include<fstream>
> > > #include<cstring>
> > > using namespace std;

>
> I can't believe how long it took me to find the bug!
>
> RULE 1: DON'T USE "using namespace std;"
> you'll find std::string isn't defined
>
>
>
> > > int main()
> > > {
> > > * * * struct{int chronum;string pname;int next;}//makes structure box with C
> > > ++ style string
> > > * * * * * * * plist[50],temp;//give the number of colmns
> > > * * * int n=0,end,maxindex,i;
> > > * * * ifstream fin;
> > > * * * ofstream fout;
> > > * * * fin.open("pres.dat");
> > > * * * fout.open("hw7.dat");
> > > * * * fin>>plist[n].pname;//inputs president name into list
> > > * * * while(!fin.eof())
> > > * * * * * * * {
> > > * * * * * * * *plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > * * * * * * * *n++;//tracks current president
> > > * * * * * * * *fin>>plist[n].pname;
> > > * * * * * * * }
> > > * * * for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > than removes one of end each time.

>
> what?
>
>
>
> > > * * * * * * * {
> > > * * * * * * * *maxindex=0;
> > > * * * * * * * *for(i=1;i<=end;i++)

>
> > > * * * * * * * * * * * if(plist[i].pname>plist[maxindex].pname)
> > > * * * * * * * * * * * * * * * maxindex=i;
> > > * * * * * * * *temp=plist[maxindex];
> > > * * * * * * * *plist[maxindex]=plist[end];
> > > * * * * * * * *plist[end]=temp;
> > > * * * * * * * }
> > > * * * //cout.setf(ios::fixed);
> > > * * * //cout.setf(ios::showpoint);
> > > * * * //cout.precision(2);
> > > * * * //cout<

> > *return 0;
> > > }

>
> > What compile errors do you get? *The code looks legal.

>
> cut down version of the code:-
>
> 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

in responce to the your question what. That is simply a note for me to
figure exactly how that algorithm is workin.
 
Reply With Quote
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:52*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > On 05/ 3/12 07:25 PM, Charles Wilson wrote:
> > > I believe that my problem is in how I am doing my C++ strings. But I
> > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > #include<iomanip>
> > > #include<iostream>
> > > #include<fstream>
> > > #include<cstring>
> > > using namespace std;

>
> I can't believe how long it took me to find the bug!
>
> RULE 1: DON'T USE "using namespace std;"
> you'll find std::string isn't defined
>
>
>
> > > int main()
> > > {
> > > * * * struct{int chronum;string pname;int next;}//makes structure box with C
> > > ++ style string
> > > * * * * * * * plist[50],temp;//give the number of colmns
> > > * * * int n=0,end,maxindex,i;
> > > * * * ifstream fin;
> > > * * * ofstream fout;
> > > * * * fin.open("pres.dat");
> > > * * * fout.open("hw7.dat");
> > > * * * fin>>plist[n].pname;//inputs president name into list
> > > * * * while(!fin.eof())
> > > * * * * * * * {
> > > * * * * * * * *plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > * * * * * * * *n++;//tracks current president
> > > * * * * * * * *fin>>plist[n].pname;
> > > * * * * * * * }
> > > * * * for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > than removes one of end each time.

>
> what?
>
>
>
> > > * * * * * * * {
> > > * * * * * * * *maxindex=0;
> > > * * * * * * * *for(i=1;i<=end;i++)

>
> > > * * * * * * * * * * * if(plist[i].pname>plist[maxindex].pname)
> > > * * * * * * * * * * * * * * * maxindex=i;
> > > * * * * * * * *temp=plist[maxindex];
> > > * * * * * * * *plist[maxindex]=plist[end];
> > > * * * * * * * *plist[end]=temp;
> > > * * * * * * * }
> > > * * * //cout.setf(ios::fixed);
> > > * * * //cout.setf(ios::showpoint);
> > > * * * //cout.precision(2);
> > > * * * //cout<

> > *return 0;
> > > }

>
> > What compile errors do you get? *The code looks legal.

>
> cut down version of the code:-
>
> 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

in responce to the your question what. That is simply a note for me to
figure exactly how that algorithm is workin.
 
Reply With Quote
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:52*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > On 05/ 3/12 07:25 PM, Charles Wilson wrote:
> > > I believe that my problem is in how I am doing my C++ strings. But I
> > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > #include<iomanip>
> > > #include<iostream>
> > > #include<fstream>
> > > #include<cstring>
> > > using namespace std;

>
> I can't believe how long it took me to find the bug!
>
> RULE 1: DON'T USE "using namespace std;"
> you'll find std::string isn't defined
>
>
>
> > > int main()
> > > {
> > > * * * struct{int chronum;string pname;int next;}//makes structure box with C
> > > ++ style string
> > > * * * * * * * plist[50],temp;//give the number of colmns
> > > * * * int n=0,end,maxindex,i;
> > > * * * ifstream fin;
> > > * * * ofstream fout;
> > > * * * fin.open("pres.dat");
> > > * * * fout.open("hw7.dat");
> > > * * * fin>>plist[n].pname;//inputs president name into list
> > > * * * while(!fin.eof())
> > > * * * * * * * {
> > > * * * * * * * *plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > * * * * * * * *n++;//tracks current president
> > > * * * * * * * *fin>>plist[n].pname;
> > > * * * * * * * }
> > > * * * for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > than removes one of end each time.

>
> what?
>
>
>
> > > * * * * * * * {
> > > * * * * * * * *maxindex=0;
> > > * * * * * * * *for(i=1;i<=end;i++)

>
> > > * * * * * * * * * * * if(plist[i].pname>plist[maxindex].pname)
> > > * * * * * * * * * * * * * * * maxindex=i;
> > > * * * * * * * *temp=plist[maxindex];
> > > * * * * * * * *plist[maxindex]=plist[end];
> > > * * * * * * * *plist[end]=temp;
> > > * * * * * * * }
> > > * * * //cout.setf(ios::fixed);
> > > * * * //cout.setf(ios::showpoint);
> > > * * * //cout.precision(2);
> > > * * * //cout<

> > *return 0;
> > > }

>
> > What compile errors do you get? *The code looks legal.

>
> cut down version of the code:-
>
> 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

in responce to the your question what. That is simply a note for me to
figure exactly how that algorithm is workin.
 
Reply With Quote
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:52*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > On 05/ 3/12 07:25 PM, Charles Wilson wrote:
> > > I believe that my problem is in how I am doing my C++ strings. But I
> > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > #include<iomanip>
> > > #include<iostream>
> > > #include<fstream>
> > > #include<cstring>
> > > using namespace std;

>
> I can't believe how long it took me to find the bug!
>
> RULE 1: DON'T USE "using namespace std;"
> you'll find std::string isn't defined
>
>
>
> > > int main()
> > > {
> > > * * * struct{int chronum;string pname;int next;}//makes structure box with C
> > > ++ style string
> > > * * * * * * * plist[50],temp;//give the number of colmns
> > > * * * int n=0,end,maxindex,i;
> > > * * * ifstream fin;
> > > * * * ofstream fout;
> > > * * * fin.open("pres.dat");
> > > * * * fout.open("hw7.dat");
> > > * * * fin>>plist[n].pname;//inputs president name into list
> > > * * * while(!fin.eof())
> > > * * * * * * * {
> > > * * * * * * * *plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > * * * * * * * *n++;//tracks current president
> > > * * * * * * * *fin>>plist[n].pname;
> > > * * * * * * * }
> > > * * * for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > than removes one of end each time.

>
> what?
>
>
>
> > > * * * * * * * {
> > > * * * * * * * *maxindex=0;
> > > * * * * * * * *for(i=1;i<=end;i++)

>
> > > * * * * * * * * * * * if(plist[i].pname>plist[maxindex].pname)
> > > * * * * * * * * * * * * * * * maxindex=i;
> > > * * * * * * * *temp=plist[maxindex];
> > > * * * * * * * *plist[maxindex]=plist[end];
> > > * * * * * * * *plist[end]=temp;
> > > * * * * * * * }
> > > * * * //cout.setf(ios::fixed);
> > > * * * //cout.setf(ios::showpoint);
> > > * * * //cout.precision(2);
> > > * * * //cout<

> > *return 0;
> > > }

>
> > What compile errors do you get? *The code looks legal.

>
> cut down version of the code:-
>
> 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

in responce to the your question what. That is simply a note for me to
figure exactly how that algorithm is workin.
 
Reply With Quote
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:52*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > On 05/ 3/12 07:25 PM, Charles Wilson wrote:
> > > I believe that my problem is in how I am doing my C++ strings. But I
> > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > #include<iomanip>
> > > #include<iostream>
> > > #include<fstream>
> > > #include<cstring>
> > > using namespace std;

>
> I can't believe how long it took me to find the bug!
>
> RULE 1: DON'T USE "using namespace std;"
> you'll find std::string isn't defined
>
>
>
> > > int main()
> > > {
> > > * * * struct{int chronum;string pname;int next;}//makes structure box with C
> > > ++ style string
> > > * * * * * * * plist[50],temp;//give the number of colmns
> > > * * * int n=0,end,maxindex,i;
> > > * * * ifstream fin;
> > > * * * ofstream fout;
> > > * * * fin.open("pres.dat");
> > > * * * fout.open("hw7.dat");
> > > * * * fin>>plist[n].pname;//inputs president name into list
> > > * * * while(!fin.eof())
> > > * * * * * * * {
> > > * * * * * * * *plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > * * * * * * * *n++;//tracks current president
> > > * * * * * * * *fin>>plist[n].pname;
> > > * * * * * * * }
> > > * * * for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > than removes one of end each time.

>
> what?
>
>
>
> > > * * * * * * * {
> > > * * * * * * * *maxindex=0;
> > > * * * * * * * *for(i=1;i<=end;i++)

>
> > > * * * * * * * * * * * if(plist[i].pname>plist[maxindex].pname)
> > > * * * * * * * * * * * * * * * maxindex=i;
> > > * * * * * * * *temp=plist[maxindex];
> > > * * * * * * * *plist[maxindex]=plist[end];
> > > * * * * * * * *plist[end]=temp;
> > > * * * * * * * }
> > > * * * //cout.setf(ios::fixed);
> > > * * * //cout.setf(ios::showpoint);
> > > * * * //cout.precision(2);
> > > * * * //cout<

> > *return 0;
> > > }

>
> > What compile errors do you get? *The code looks legal.

>
> cut down version of the code:-
>
> 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

in responce to the your question what. That is simply a note for me to
figure exactly how that algorithm is workin.
 
Reply With Quote
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:53*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:52:40 AM UTC+1, nick_keigh...@hotmail.com wrote:
> > On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > > On 05/ 3/12 07:25 PM, Charles Wilson wrote:

>
> > > > I believe that my problem is in how I am doing my C++ strings. But I
> > > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > > #include<iomanip>
> > > > #include<iostream>
> > > > #include<fstream>
> > > > #include<cstring>
> > > > using namespace std;

>
> > I can't believe how long it took me to find the bug!

>
> > RULE 1: DON'T USE "using namespace std;"
> > you'll find std::string isn't defined

>
> > > > int main()
> > > > {
> > > > *struct{int chronum;string pname;int next;}//makes structure box with C
> > > > ++ style string
> > > > * * * * *plist[50],temp;//give the number of colmns
> > > > *int n=0,end,maxindex,i;
> > > > *ifstream fin;
> > > > *ofstream fout;
> > > > *fin.open("pres.dat");
> > > > *fout.open("hw7.dat");
> > > > *fin>>plist[n].pname;//inputs president name into list
> > > > *while(!fin.eof())
> > > > * * * * *{
> > > > * * * * * plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > > * * * * * n++;//tracks current president
> > > > * * * * * fin>>plist[n].pname;
> > > > * * * * *}
> > > > *for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > > than removes one of end each time.

>
> > what?

>
> > > > * * * * *{
> > > > * * * * * maxindex=0;
> > > > * * * * * for(i=1;i<=end;i++)

>
> > > > * * * * * * * * *if(plist[i].pname>plist[maxindex].pname)
> > > > * * * * * * * * * * * * *maxindex=i;
> > > > * * * * * temp=plist[maxindex];
> > > > * * * * * plist[maxindex]=plist[end];
> > > > * * * * * plist[end]=temp;
> > > > * * * * *}
> > > > *//cout.setf(ios::fixed);
> > > > *//cout.setf(ios::showpoint);
> > > > *//cout.precision(2);
> > > > *//cout<
> > > *return 0;
> > > > }

>
> > > What compile errors do you get? *The code looks legal.

>
> > cut down version of the code:-

>
> > 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

>
> sorry, the offending line is
>
> *fin>>plist[n].pname;


How?
 
Reply With Quote
 
Charles Wilson
Guest
Posts: n/a
 
      05-03-2012
On May 3, 2:53*am, nick_keighley_nos...@hotmail.com wrote:
> On Thursday, May 3, 2012 8:52:40 AM UTC+1, nick_keigh...@hotmail.com wrote:
> > On Thursday, May 3, 2012 8:38:31 AM UTC+1, Ian Collins wrote:
> > > On 05/ 3/12 07:25 PM, Charles Wilson wrote:

>
> > > > I believe that my problem is in how I am doing my C++ strings. But I
> > > > am not sure. *Can someone point me in the right direction. Thank you

>
> > > > #include<iomanip>
> > > > #include<iostream>
> > > > #include<fstream>
> > > > #include<cstring>
> > > > using namespace std;

>
> > I can't believe how long it took me to find the bug!

>
> > RULE 1: DON'T USE "using namespace std;"
> > you'll find std::string isn't defined

>
> > > > int main()
> > > > {
> > > > *struct{int chronum;string pname;int next;}//makes structure box with C
> > > > ++ style string
> > > > * * * * *plist[50],temp;//give the number of colmns
> > > > *int n=0,end,maxindex,i;
> > > > *ifstream fin;
> > > > *ofstream fout;
> > > > *fin.open("pres.dat");
> > > > *fout.open("hw7.dat");
> > > > *fin>>plist[n].pname;//inputs president name into list
> > > > *while(!fin.eof())
> > > > * * * * *{
> > > > * * * * * plist[n].chronum=n+1;//assigns chronum to presidents as inputed.
> > > > * * * * * n++;//tracks current president
> > > > * * * * * fin>>plist[n].pname;
> > > > * * * * *}
> > > > *for(end=n-1;end>0;end--)//it seems to input all on the first past and
> > > > than removes one of end each time.

>
> > what?

>
> > > > * * * * *{
> > > > * * * * * maxindex=0;
> > > > * * * * * for(i=1;i<=end;i++)

>
> > > > * * * * * * * * *if(plist[i].pname>plist[maxindex].pname)
> > > > * * * * * * * * * * * * *maxindex=i;
> > > > * * * * * temp=plist[maxindex];
> > > > * * * * * plist[maxindex]=plist[end];
> > > > * * * * * plist[end]=temp;
> > > > * * * * *}
> > > > *//cout.setf(ios::fixed);
> > > > *//cout.setf(ios::showpoint);
> > > > *//cout.precision(2);
> > > > *//cout<
> > > *return 0;
> > > > }

>
> > > What compile errors do you get? *The code looks legal.

>
> > cut down version of the code:-

>
> > 1>w:\project\bin\quick\wilson.cpp(10) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

>
> sorry, the offending line is
>
> *fin>>plist[n].pname;


How?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
conditional running of code portion JW Huang Python 5 08-06-2012 08:59 PM
Re: Is there freeware that will blur just a selected portion of a JPEG? iuridicus_wannabeee Digital Photography 5 05-01-2010 12:12 AM
Re: Is there freeware that will blur just a selected portion of a JPEG? Yrrah Digital Photography 4 04-29-2010 07:38 PM
I want to clear a portion of screen - How?? Rajendran C Programming 11 09-04-2006 07:04 PM
Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and anu Java 11 05-12-2005 03:25 PM



Advertisments