Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C how do I check if an array is full?

Tags:

c

I have an array: array[3][3]

I will let the user input data into the array as long as it is not full. As soon as the array gets full I want to stop the user from inserting more data into it.

like image 349
user2927590 Avatar asked Nov 20 '25 16:11

user2927590


2 Answers

You cannot check if "array is full". To do what u want to do, keep track of index while adding elements to array.

like image 185
Neeraj Kumar Avatar answered Nov 23 '25 06:11

Neeraj Kumar


C has no array bounds check. You have to do it yourself. Use a variable to keep track of how many items you have inserted, and stop when your counter is equal to the array size.

like image 36
Filipe Gonçalves Avatar answered Nov 23 '25 05:11

Filipe Gonçalves



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!