Skip to content

Instantly share code, notes, and snippets.

@MastodonHQ
Created May 28, 2012 05:35
Show Gist options
  • Save MastodonHQ/2817466 to your computer and use it in GitHub Desktop.
Save MastodonHQ/2817466 to your computer and use it in GitHub Desktop.
Some of my early work quite a feat considering I was a novice then
#include <stdio.h>
/*
This Program prints an array dynamically without knowing the number of indices, and makes use of function pointers. Of course any programmer will tell you there is next to no need to ever do this and that you should know the size of the array at the time of declaration.
*/
void list(char * array[], int indices){
int x=0;
for(;x!=indices;x++){
printf("%s",array[x]);
}
}
int main(){
char * array[] = {"Hello World\n","This is a array test\n"};
int i = sizeof(array) / sizeof(array[0]);
void (*lies)(char**,int);
lies = &list;
lies(array,i);
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment