Thread: Buffer Overload

  1. #1
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    Question Buffer Overload

    How can I test for overload on an array?

    Below is what I'm currently using. I basically declare a 15 integer array, and want to issue an overload error if it exceeds the available memory allocation.

    Code:
     
    int SomeArray[15];
    
    if(SomeArray[15]!='\0';
    {
    cout<<"You have exceeded you memory allocation";
    }
    I'm assuming this should work, but it doesn't.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    The easiest way is to learn the STL vector class. Alternatively you could write a stripped down version of the vector class, or the equivalent thereof using flags and counters.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  2. writing a pack-style function, any advices?
    By isaac_s in forum C Programming
    Replies: 10
    Last Post: 07-08-2006, 08:09 PM
  3. buffer contents swapping
    By daluu in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2004, 02:34 PM
  4. Tetris Questions
    By KneeGrow in forum Game Programming
    Replies: 19
    Last Post: 10-28-2003, 11:12 PM
  5. Console Screen Buffer
    By GaPe in forum Windows Programming
    Replies: 0
    Last Post: 02-06-2003, 05:15 AM