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

Discussion in 'C++' started by Charles Wilson, May 3, 2012.

  1. 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;

    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.
    {
    maxindex=0;
    for(i=1;i<=end;i++)

    if(plist.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<<plist.chronum<<plist.pname<<endl;
    return 0;
    }
     
    Charles Wilson, May 3, 2012
    #1
    1. Advertising

  2. Charles Wilson

    Ian Collins Guest

    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;
    >
    > 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.
    > {
    > maxindex=0;
    > for(i=1;i<=end;i++)
    >
    > if(plist.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<<plist.chronum<<plist.pname<<endl;
    > return 0;
    > }


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

    --
    Ian Collins
     
    Ian Collins, May 3, 2012
    #2
    1. Advertising

  3. Charles Wilson

    Ian Collins Guest

    On 05/ 3/12 07:38 PM, 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>


    Why <cstring>?


    --
    Ian Collins
     
    Ian Collins, May 3, 2012
    #3
  4. On May 3, 2:39 am, Ian Collins <> wrote:
    > On 05/ 3/12 07:38 PM, 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>

    >
    > Why <cstring>?
    >
    > --
    > Ian Collins

    oops typo

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

    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.
    {
    maxindex=0;
    for(i=1;i<=end;i++)

    if(plist.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<<plist.chronum<<plist.pname<<endl;
    return 0;
    }
     
    Charles Wilson, May 3, 2012
    #4
  5. Charles Wilson

    Guest

    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.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)
     
    , May 3, 2012
    #5
  6. On May 3, 2:38 am, 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;

    >
    > > 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.
    > >            {
    > >             maxindex=0;
    > >             for(i=1;i<=end;i++)

    >
    > >                    if(plist.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<<plist.chronum<<plist.pname<<endl;
    > > return 0;
    > > }

    >
    > What compile errors do you get?  The code looks legal.
    >
    > --
    > Ian Collins



    This is what I get


    [cwilson@orion Hw7]$ gcc hw7.cpp
    /tmp/ccN2xrWu.o: In function `main::._84::._84()':
    hw7.cpp:(.text+0x15): undefined reference to `std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >::basic_string()'
    /tmp/ccN2xrWu.o: In function `main::._84::~._84()':
    hw7.cpp:(.text+0x31): undefined reference to `std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >::~basic_string()'
    /tmp/ccN2xrWu.o: In function `main::._84::eek:perator=(._84 const&)':
    hw7.cpp:(.text+0x65): undefined reference to `std::basic_string<char,
    std::char_traits<char>, std::allocator<char>
    >::eek:perator=(std::basic_string<char, std::char_traits<char>,

    std::allocator<char> > const&)'
    /tmp/ccN2xrWu.o: In function
    `__static_initialization_and_destruction_0(int, int)':
    hw7.cpp:(.text+0xa1): undefined reference to
    `std::ios_base::Init::Init()'
    /tmp/ccN2xrWu.o: In function `__tcf_0':
    hw7.cpp:(.text+0xe4): undefined reference to
    `std::ios_base::Init::~Init()'
    /tmp/ccN2xrWu.o: In function `main':
    hw7.cpp:(.text+0x1ee): undefined reference to
    `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream()'
    hw7.cpp:(.text+0x1fa): undefined reference to
    `std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream()'
    hw7.cpp:(.text+0x210): undefined reference to
    `std::basic_ifstream<char, std::char_traits<char> >::eek:pen(char const*,
    std::_Ios_Openmode)'
    hw7.cpp:(.text+0x232): undefined reference to
    `std::basic_ofstream<char, std::char_traits<char> >::eek:pen(char const*,
    std::_Ios_Openmode)'
    hw7.cpp:(.text+0x260): undefined reference to
    `std::basic_istream<char, std::char_traits<char> >&
    std::eek:perator>><char, std::char_traits<char>, std::allocator<char>
    >(std::basic_istream<char, std::char_traits<char> >&,

    std::basic_string<char, std::char_traits<char>, std::allocator<char>
    >&)'

    hw7.cpp:(.text+0x2bc): undefined reference to
    `std::basic_istream<char, std::char_traits<char> >&
    std::eek:perator>><char, std::char_traits<char>, std::allocator<char>
    >(std::basic_istream<char, std::char_traits<char> >&,

    std::basic_string<char, std::char_traits<char>, std::allocator<char>
    >&)'

    hw7.cpp:(.text+0x2cf): undefined reference to `std::basic_ios<char,
    std::char_traits<char> >::eof() const'
    hw7.cpp:(.text+0x406): undefined reference to
    `std::basic_ofstream<char, std::char_traits<char>
    >::~basic_ofstream()'

    hw7.cpp:(.text+0x422): undefined reference to
    `std::basic_ofstream<char, std::char_traits<char>
    >::~basic_ofstream()'

    hw7.cpp:(.text+0x437): undefined reference to
    `std::basic_ifstream<char, std::char_traits<char>
    >::~basic_ifstream()'

    hw7.cpp:(.text+0x453): undefined reference to
    `std::basic_ifstream<char, std::char_traits<char>
    >::~basic_ifstream()'

    /tmp/ccN2xrWu.o: In function `bool std::eek:perator><char,
    std::char_traits<char>, std::allocator<char> >(std::basic_string<char,
    std::char_traits<char>, std::allocator<char> > const&,
    std::basic_string<char, std::char_traits<char>, std::allocator<char> >
    const&)':
    hw7.cpp:(.text._ZStgtIcSt11char_traitsIcESaIcEEbRKSbIT_T0_T1_ES8_[bool
    std::eek:perator><char, std::char_traits<char>, std::allocator<char>
    >(std::basic_string<char, std::char_traits<char>, std::allocator<char>
    > const&, std::basic_string<char, std::char_traits<char>,

    std::allocator<char> > const&)]+0x19): undefined reference to
    `std::basic_string<char, std::char_traits<char>, std::allocator<char>
    >::compare(std::basic_string<char, std::char_traits<char>,

    std::allocator<char> > const&) const'
    /tmp/ccN2xrWu.o:(.eh_frame+0x13): undefined reference to
    `__gxx_personality_v0'
    collect2: ld returned 1 exit status
    [cwilson@orion Hw7]$
     
    Charles Wilson, May 3, 2012
    #6
  7. Charles Wilson

    Guest

    On Thursday, May 3, 2012 8:52:40 AM UTC+1, 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.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;
     
    , May 3, 2012
    #7
  8. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #8
  9. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #9
  10. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #10
  11. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #11
  12. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #12
  13. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #13
  14. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #14
  15. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #15
  16. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #16
  17. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #17
  18. On May 3, 2:52 am, 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.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.
     
    Charles Wilson, May 3, 2012
    #18
  19. On May 3, 2:53 am, wrote:
    > On Thursday, May 3, 2012 8:52:40 AM UTC+1, 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.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?
     
    Charles Wilson, May 3, 2012
    #19
  20. On May 3, 2:53 am, wrote:
    > On Thursday, May 3, 2012 8:52:40 AM UTC+1, 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.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?
     
    Charles Wilson, May 3, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    20,308
  2. Rajendran

    I want to clear a portion of screen - How??

    Rajendran, Sep 2, 2006, in forum: C Programming
    Replies:
    11
    Views:
    1,349
    Peyman
    Sep 4, 2006
  3. Nagaraj
    Replies:
    1
    Views:
    869
    Lionel B
    Mar 1, 2007
  4. PerlFAQ Server
    Replies:
    0
    Views:
    119
    PerlFAQ Server
    Jan 7, 2011
  5. JW Huang

    conditional running of code portion

    JW Huang, Aug 5, 2012, in forum: Python
    Replies:
    5
    Views:
    244
    Serhiy Storchaka
    Aug 6, 2012
Loading...

Share This Page