+ 1

How can i append more numbers to an array (integer type) in C?

https://code.sololearn.com/c181sr9nI82s/?ref=app

2nd Feb 2019, 6:19 PM
Shekhar Srivastava
Shekhar Srivastava - avatar
2 Answers
+ 7
By the way, if you define an array with four elements and try to change its fifth element, this will affect whatever is stored at that memory location (which might very well be another, totally unrelated variable of your program). So you might want to avoid that.
3rd Feb 2019, 6:39 AM
Anna
Anna - avatar
+ 2
You can't append elements to an array.They are static data structures, and their elements are allocated in contiguous memory locatios. To do a[4] = 7; You must declare a[] with at least 5 elements: int a[5]={4,5,6,8};
2nd Feb 2019, 10:33 PM
unChabon
unChabon - avatar