Thread: checking array bounds

  1. #1
    Unregistered
    Guest

    Question checking array bounds

    How do you handle an "array bounds exceeded" error from an infile.get statement?

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    139
    something like this.
    Code:
    const int MAX_ARRAY=10;
    ...
    int array[MAX_ARRAY];
    
    int x =0;
    while((inFile)&&(X<MAX_ARRAY))
    {
      inFile >> array[x];
      x++;
    }
    "The most common form of insanity is a combination of disordered passions and disordered intellect with gradations and variations almost infinite."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  3. Array bounds overflow
    By athos in forum C++ Programming
    Replies: 3
    Last Post: 08-10-2004, 12:05 PM
  4. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-11-2004, 11:15 PM
  5. Replies: 5
    Last Post: 05-30-2003, 12:46 AM