Hi,
I am studying C (and pointers) now, I found a nice tutorial site (with excercises) here. I am now trying to solve the excercise under "Pointers" chapter:
Right now, I have this:Write a C program to read through an array of any type using pointers.
It reads through a CHAR array (and displays the values), but how can I read through ANY array using 1 (the same) pointer? Or is that impossible? (I don't understand C and pointers very well yet)Code:#include <stdio.h> int main(int argc, char**argv) { int arr1[10] = {1,2,3,4,5,6,7,8,9,10}; char s[10] = {'a', 'b', 'c', 'd', 'e', 'd', 'c', 'b', 'a', 'z'}; char *p = s; while (*p != '\0') { printf("%c", s[p-s]); p++; } return 0; } // this outputs: abcdedcbaz
Edit: Is a void* pointer the solution?