1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Array troubles

Discussion in 'C++' started by Brett.h, Jan 30, 2010.

  1. Brett.h

    Brett.h New Member

    Joined:
    Dec 18, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    When i compile and run the program with only this function working, it should assign consecutive line in a document to an array element, but it doesn't print out anything just the "\n" (line 6) no text???


    void AI::init(){
    test.open("greetings.txt");
    for (int counter = 0; !test.eof(); counter++){
    getline(test,tests);
    cout << tests /// this prints out the right output
    recognisedStatements[counter] == tests;
    cout << recognisedStatements[counter] << "\n"; //this doesn't
    }
    }
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    What does the == operator do? Does it assign or does it compare?
    Probably your compiler threw a warning at this line - code does nothing, or something along those lines.
     

Share This Page