Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prints all arguments passed to main. Always returns successful exit code
/*
Guy Levin (@va_start)
prints all arguments passed to main
always returns successful exit code
*/
#include <stdio.h>
#include <stdlib.h>
#define INDENTATION " "
int main(int argc, char * argv[], char * envp[])
{
printf("argc:\n" INDENTATION "%d\n", argc);
printf("argv:\n");
int i = 0;
while(argv[i])
{
printf(INDENTATION "%s\n", argv[i]);
i++;
}
printf("envp:\n");
i = 0;
while(envp[i])
{
printf(INDENTATION "%s\n", envp[i]);
i++;
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.