How to check if the limit of a vector has not been exceeded?

-2

Good afternoon, gentlemen!

I am doing a college job that asks you to create a schedule. I've done most of the code, but I can not see the light so when the user tries to register a person in the calendar, show whether the calendar is already full or not.

The statement follows, I can post the whole code here, but it's too big.

"g) Define a block of instructions inserts a person: Insert in alphabetical order of name moves all the following elements of the vector to the next position. the messageAGENDACHEIA); "

    
asked by anonymous 20.09.2018 / 19:59

1 answer

0

If the vector has a static size (I suppose so, since there is a limit), you have defined the size at some point, right? For example, I'll consider the following:

#define MAXTAM 100

Having this constant you can use it to make checks, for example, if there is a stop condition it can be i <= MAXTAM .

If this is not possible, another possible solution might be to set a fixed value for the last position (just as %code% is used to check the end of a string). Then after inserting you see if the value of the last position remains the established fixed value or changed.

    
04.10.2018 / 05:09