checking array bounds

This is a discussion on checking array bounds within the C++ Programming forums, part of the General Programming Boards category; How do you handle an "array bounds exceeded" error from an infile.get statement?...

  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, 04:25 PM
  2. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 05:15 AM
  3. Array bounds overflow
    By athos in forum C++ Programming
    Replies: 3
    Last Post: 08-10-2004, 01:05 PM
  4. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-12-2004, 12:15 AM
  5. Replies: 5
    Last Post: 05-30-2003, 01:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21