Begginer to C++

Discussion in 'C Programming' started by Dra2k, Sep 11, 2006.

  1. Dra2k

    Dra2k

    Joined:
    Sep 11, 2006
    Messages:
    1
    Hi there, This is my first post so I apologies in advance if the format if off.

    This is an error message Im getting for my code (which I'll leave at the bottom)

    error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
    Error executing cl.exe.

    If anyone could point my where Im going wrong it would be much appreciated.

    Ps: Im using Visual Studio v6

    #include <iostream>
    #include <fstream>
    #include <string>
    #include <conio.h>
    using namespace std;


    int main()
    {
    double vArray[15];
    int index=0;


    ifstream filein;
    string filename;

    // Open the file: this links the program variable "filein" with the disk file
    filename = "filedata.txt";
    filein.open( filename.c_str() );
    if (filein.good())
    {

    filein >> vArray[index];
    while ( filein.good() )
    {
    for (index=0; index<15; index++)
    {

    filein >> vArray[index] >> endl;
    }
    }


    filein.close();

    }
    else
    {// moan - it could be that there is no file with that name
    cout << "***ERROR could not open file " << filename << "***" << endl;
    }
    return 0;
    }
     
    Dra2k, Sep 11, 2006
    #1
    1. Advertising

  2. Dra2k

    Stockhausen

    Joined:
    Sep 18, 2006
    Messages:
    2
    simple mistake

    change

    Code:
    filein >> vArray[index] >> endl;
    
    to
    Code:
    filein >> vArray[index];
    
    You cannot read anything into the "endl" variable as it is just a global constant. And you needn't be concerned with end of line (EOL) characters with the insertion operator since it will eat all white space.

    - Tim
     
    Stockhausen, Sep 18, 2006
    #2
    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. dhillon2004

    Begginer Question about TK::filevent

    dhillon2004, Sep 3, 2004, in forum: Perl
    Replies:
    0
    Views:
    492
    dhillon2004
    Sep 3, 2004
  2. grzybek

    Web Application begginer

    grzybek, Nov 24, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    440
    grzybek
    Nov 24, 2003
  3. Tom
    Replies:
    2
    Views:
    377
    =?Utf-8?B?d2VpY2h1bmcgW01DU0QsIE1DREJBXQ==?=
    Nov 24, 2004
  4. ablyplus

    new page - begginer

    ablyplus, Mar 26, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    444
    Steve C. Orr [MVP, MCSD]
    Mar 27, 2005
  5. adi.rajvosa@gmail.com

    begginer

    adi.rajvosa@gmail.com, Nov 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    525
    adi.rajvosa@gmail.com
    Nov 23, 2005
Loading...

Share This Page