I think one way to check it is to find the index of \0
in your array. If the position is equal or greater than 1000
, then you should not add more chars to it.
If you are using cin.getline()
you can use a variable n
to specify the maximum of chars you want
istream& getline (char* s, streamsize n );
istream& getline (char* s, streamsize n, char delim );
Here you can set n=1001
(it also counts the termination char \0
).