#include #include /* * demo program to show what valgrind says and how to use it */ #define LEN 10 int find_square(); int main() { char ans[LEN]; do { find_square(); printf("again? "); scanf("%10s", ans); } while( ans[0] != 'n' ); } int find_square(){ int *x = malloc( LEN * sizeof(int) ); // dyn arr of ints int i; int pos; for ( i = 0 ; i < LEN ; i++ ) x[i] = i*i; printf("see which element? "); scanf("%d", &pos); printf("that value is %d\n", x[pos]); return 0; }