I'm quite new to C and I'm having some problems with the syntax and pointers.
I have an array
int ar[6] = {2, 3, 6, 7, 1, 9};
and I have a pointer
int* p = ar;
In the output instead of printing out to which number the pointer is pointing at, I want to have a ^ underneath of that number. And I want it to move as the pointer moves.
I want the output to the like this:
The array = {2 3 6 7 1 9}
^
but I don't know how to have it skip the "The array = {" part
I'm just printing the array like this
printf("The array = { ");
for(int i=0; i< 6;i++){
printf("%d ", ar[i]);
}
And I'm moving the pointer with getchar(), so the input from the user.
p = &a[0];
c = getchar();
if(c =='a'){
if(p == &ar[0]){
p--;
}
if( c=='d'){
p++;
}
I don't know if there's and easier way to do this or not.