Skip to content

Instantly share code, notes, and snippets.

@doylecnn
Last active September 9, 2015 19:56
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 doylecnn/39d4b40d5c61198eed9d to your computer and use it in GitHub Desktop.
Save doylecnn/39d4b40d5c61198eed9d to your computer and use it in GitHub Desktop.
tiny demo to understand double star pointer
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv){
for(int i=0;i<argc;i++){
printf("%s ",argv[i]);
}
printf("\n");
char** params = malloc(argc*sizeof(char*));
char** p = params;
for(int i=0;i<argc;i++){
//*p=malloc(strlen(argv[i])*sizeof(char));
//strcpy(*p, argv[i]);
*p=argv[i];
p+=1;
}
for(int i=0;i<argc;params++,i++){
printf("%s %lu\n",*params,strlen(*params));
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment