How to fix illegal pointer use error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • noorhidayah
    New Member
    • Jan 2011
    • 2

    #1

    How to fix illegal pointer use error?

    Hi 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 and the output of classes & feature vector format should be: 1 1 : 9.8776757. If you could tell me what should I change, I would be most grateful.

    Code:
    #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
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    should line 49 be ?
    Code:
    cout <<" "<<lineCount <<":";

    Comment

    • noorhidayah
      New Member
      • Jan 2011
      • 2

      #3
      Oh, thank you for point it out to me! :)

      However, the program seems to work as if the code are not there. That codes are supposed to build the classes and feature vector for my data, but instead the program just read the whole data.

      Comment

      Working...