Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C++ homework help

  1. Mar 26, 2007 #1
    1. The problem statement, all variables and given/known data
    Well I have to read in data from a text file test some conditions on certain columns and count up the failures. I am having a problem with the infile command, I have tried using infile.close(); but it does not seem to reset it.

    if((2+4*i==total) && ((150>y) || (y>170)))

    if((3+4*i==total) && ((60>y)||(y>70)))


    2. Relevant equations

    3. The attempt at a solution

    I have attemped infile.close(); but it did not seem to reset the counter saying it was the end of the file.

    I also tried change the value of while(infile>>y) it was >>x before. Also I have tried reopening the file before this loop but it also does not seem to work.

    Just to preface this there is a second loop before this that counts the total number of elements a number that I need and cannot nest within this loop.
    1. The problem statement, all variables and given/known data

    2. Relevant equations

    3. The attempt at a solution
  2. jcsd
  3. Mar 26, 2007 #2
  4. Mar 27, 2007 #3
    infile.clear(); does not seem to work, is there a library that I need to include to use it. Right now I am using cstdlib, iostream, and fstream.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook