Skip to content

Instantly share code, notes, and snippets.

@minostro
Created September 18, 2016 02:27
Show Gist options
  • Save minostro/b0d6456e8a888ddbc495536590bdbb06 to your computer and use it in GitHub Desktop.
Save minostro/b0d6456e8a888ddbc495536590bdbb06 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int* initialize_array(int n) {
int array[n];
for(int i=0; i<n; i=i+1){
array[i] = i+1;
}
return array;
}
int main(int args, char *argv[]) {
int array_size;
printf("Enter the array size:\n");
scanf("%d", &array_size); //user has to enter the size of the array
int* my_array = initialize_array(array_size); //a new array will be initialized
for(int i=0; i<array_size; i=i+1){
printf("value: %i\n", my_array[i]); //display current value
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment