Begginer to C++

Joined
Sep 11, 2006
Messages
1
Reaction score
0
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;
}
 
Joined
Sep 18, 2006
Messages
2
Reaction score
0
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top