Thread: Putting limits on values taken from a file

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    3

    Putting limits on values taken from a file

    I am accessing a file in the following way

    ifstream infile("Info.txt",ios::in);

    while(infile>>freq>>dbels)
    {
    arr1[i]=freq; //of course all the variables are declared
    arr2[i]=dbels;
    i++
    }

    However, now I want to put a limit on either the freq or dbel value that I take in. i have tried

    do
    {
    infile>>freq>>dbels;
    ..................
    } while(freq<=2000);

    However this is not working.

    Any suggestions,

    Thanks,
    DBB




  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4

    heh

    pretty easy to fix this problem

    just use:

    if(freq<=2000)
    infile>>freq>>dbels;

    maby this is what you mean

    other wise change the loop to:
    while(freq<= 2000){
    infile>>freq>>dbels;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM