Array in C

Status
Not open for further replies.
You'll have to keep it stored somewhere. C arrays are just pointers to blocks of memoy (see pointer arithmetic).

Say you have a 4 element array [0-3].
Code:
char array[] = {'a', 'b', 'c', 'd'};
You could keep track of the current element with an integer or a pointer.
Code:
int cur_index = 2; /* points to 'c' */
char* cur_index = &array[0]; /* points to 'a' */
cur_index++; /* points to 'b' */
cur_index++; /* points to 'c' */
 
Status
Not open for further replies.
Back
Top Bottom