Hello, I am pretty new to C and have a hard time understanding what an array is and what it is used for could someone help explain?
Hello, I am pretty new to C and have a hard time understanding what an array is and what it is used for could someone help explain?
Arrays are meant for storing similar data types at contiguous locations for you
Lets take an example
i am having an array which is like this
then the memory location for the array will be likeCode:int array[3] = {1, 2, 3};
And with array you can perform operations fast0xFF0000 value == 1
0xFF0004 value == 2
0xFF0008 value == 3
And i am taking that int take 4 byte or a word in a memory
Think an example that you want to store marks of 50 students in a class..
You will not declare 50 variables for each student then what you can do declare an array which can hold 50 student marks kind of so long story dude just google it or wiki it
Array has little to do with speed.And with array you can perform operations fast
It could be faster if they are in 3 variables stored in registers.
i see, thx rocky. i did google it, reread the array section in the book i bought, and even asked my professor but i still did not understand