Skip to content

Instantly share code, notes, and snippets.

@2jiwon
Created February 12, 2018 08:56
Show Gist options
  • Save 2jiwon/9d1190ad5f6cc18b004904a185d94695 to your computer and use it in GitHub Desktop.
Save 2jiwon/9d1190ad5f6cc18b004904a185d94695 to your computer and use it in GitHub Desktop.
Take command-line arguments and make them reverse output
#include <stdio.h>
int
main (int argc,
char* argv[])
{
int num;
if (argc >= 1)
num = argc;
char* stack[num];
char** sp = NULL;
int i;
for (i = 0; i < num; i++)
{
stack[i] = argv[i];
}
i--;
while (num--)
{
sp = &(stack[i]);
printf ("argument %d: %p %s\n", i, *sp, *sp);
i--;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment