Thread: Unfamiliar debugger problems

  1. #1
    Registered User
    Join Date
    Dec 2008

    Unfamiliar debugger problems

    I'm still a bit rusty on programming, and I have never seen these debugger complaints before.

    GNU GCC in Code::Blocks

    Source code:

    #include <iostream>
    #include <fstream>
    using namespace std;
    int main()
        int cc=0;
        int accumilator=0;
        int counter=0;
        int lngb=0;
        int count=0;
        string IN;
        /* IN now needs to be converted to a C style string so that it can be manipulated
        easier and compared to what is read from the file.
        int lng= IN.length();
        char in [lng];
        while (cc<lngb);
        // Time to find out what word we're looking for:
        cout<<"Enter word to search file for.\n\n";
        //Get the text data from the file.
        ofstream file_read ("A.txt");
        int F_Read_Length=file_read.length();
        char cstring [F_Read_Length];
        //Remember your safe coding practices.
        if (file_read.is_open())
                //Convert the data from file to c style string:
                cstring[counter] = file_read[counter];
            while (counter<F_Read_Length);
            cout<<"Program fail on primary file read. File could not be opened. Quitting. \n\n";
            return 0;
        //Time to compare:
                /* If what came out of the file equals what was entered,
                accumilator in incremented by one for each character.*/
              if (in[count]==cstring[count])
        else {
        // Otherwise, we lose one.
        accumilator --;
        if (accumilator==lng){
        cout<<"Perfect match.\n\n";
        else {
        cout<<"Match not found.\n\n";
    return 0;
    The errors that the debugger are throwing are :

    error: 'struct std:fstream' has no member named length


    error: no match for 'operator[]' in 'file_read[counter]'

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Those are compiler errors, not from the debugger.
    Read up on file I/O: Input/Output with files - C++ Documentation
    You'll find that you can't find the length of a stream and randomly access something within a stream (generally ).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array problems, unfamiliar error messages
    By Trckster in forum C++ Programming
    Replies: 6
    Last Post: 02-19-2012, 12:03 PM
  2. Errors in Code i am unfamiliar with, Please Help
    By msween21 in forum C Programming
    Replies: 6
    Last Post: 10-03-2009, 12:06 AM
  3. unfamiliar syntax
    By bean66 in forum C++ Programming
    Replies: 11
    Last Post: 04-02-2009, 12:36 PM
  4. little sign convention i'm unfamiliar with
    By trickae2 in forum C Programming
    Replies: 8
    Last Post: 08-25-2006, 08:32 PM
  5. unfamiliar with linux
    By macronin in forum C++ Programming
    Replies: 0
    Last Post: 03-25-2002, 09:17 AM

Tags for this Thread