Skip to content

Instantly share code, notes, and snippets.

@Dviejopomata
Created January 2, 2018 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dviejopomata/25ce26172876e363b74185bfc958e94c to your computer and use it in GitHub Desktop.
Save Dviejopomata/25ce26172876e363b74185bfc958e94c to your computer and use it in GitHub Desktop.
QuizzicalDaringNaga created by dviejo - https://repl.it/@dviejo/QuizzicalDaringNaga
#include "stdio.h"
#define ROWS 5
int* fn_input(){
static int intArr[ROWS];
int i;
// Requests users to enter the value for elements
for (i = 0; i< ROWS; i++) {
printf("Enter the value for array intArr[%d]:", i);
scanf("%d", &intArr[i]);
}
return intArr; // return array pointer
}
int main()
{
int *intPtr;
int i;
intPtr = fn_input(); // accepts the pointer to an array
printf("\nArray Elements are:\n");
for (i = 0; i< ROWS; i++)
printf("%d\t", *(intPtr + i)); // displays the values as if it is accessing the array itself
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment