illegal pointer use. what should i do?

hai everyone. I'm stucked in the middle of my programming. I'm trying to read data form the file, and then create the classes as well as feature vector format for that data. e.g my data: 9.8776757 classes & feature vector format: 1 1:9.8776757. if you could tell me what should i change, i would be most grateful.


#include <stdio>
#include <iostream>
#include <stdlib>
#include <fstream>
#include <string>
#include <conio>


int main()
{

const int SIZE = 100000;
char input[SIZE];
int lineCount = 1;
int length=0;
string lineBuffer;

ifstream infile;
ofstream outfile;
outfile.open ("schizo_output.dat", ios::out | ios::app);

infile.open ("schizo.dat", ios::in);
if(!infile)
{
cout << "ERROR: Cannot open file.\n";
getch();

return 0;
}
cout << "File is successfully opened! \n";


while (!infile.eof())
{

int count = 1;
count = lineCount;

int counter=0;
int classes=+1;
lineCount ++;


lineCount <<classes;
for(int q=0;q<32;q++)
{
counter++;
}
count <<" "<<lineCount <<":";
infile.getline(input,SIZE);
cout << input << endl;
outfile.close();

}

getch();
return 0;
}



the error occur on (49,15): Illegal use of pointer
closed account (zb0S216C)
I can't see a pointer anywhere in the code you posted.

What is this supposed to accomplish?:
1
2
3
4
for(int q=0;q<32;q++)
{
    counter++;
}

You never use counter after the for loop.
Last edited on
input seems to be a char array, which will act as a pointer in some circumstances.

infile.getline(input,SIZE);

Note the prototype of the getline funciton:

1
2
std::basic_istream< Char, Traits >& getline( std::basic_istream< Char, Traits >& in,
                                             std::basic_string< Char, Traits >& str );


getline wants a basic_istream, and a basic_string.

You are feeding it a char*, and an int.
^Actually, istreams have a getline member function:

istream& getline (char* s, streamsize n );.

As for the error...I'm not really sure what is causing it...
Doh. So they do. I did not know that and the first lookup I found didn't mention it. Forget I spoke.
Last edited on
[code] "Your code goes here" [/cobde]
Line 49: count <<" "<<lineCount <<":";
invalid operands of types 'int' and 'const char [2]' to binary 'operator<<'
Maybe it was supposed to be std::cout ?
Topic archived. No new replies allowed.