OneBite.Dev - Coding blog in a bite size

get the first element of array in C

Code snippet on how to get the first element of array in C

  int firstElement = myArray[0];

This code can be used to get the first element of an array in the C programming language. The variable “firstElement” will contain the value of the first element of the array “myArray”. The array index starts at 0, meaning the first element is located at index 0. This code simply assigns the value of myArray at the index of 0 to the variable “firstElement”.

c