Skip to content

Instantly share code, notes, and snippets.

@msikma
Created September 27, 2015 11:11
Show Gist options
  • Save msikma/a49762d296c0367b941c to your computer and use it in GitHub Desktop.
Save msikma/a49762d296c0367b941c to your computer and use it in GitHub Desktop.
// small test (compiled with DJGPP for MSDOS)
#include <stdio.h>
int main(int argc, char *argv[])
{
int a;
char *arg;
if (argc == 0) {
printf("No command line arguments.\n");
return 0;
}
printf("Checking command line arguments.\n");
for (a = 1; a < argc; ++a) {
arg = argv[a];
printf("arg: %s\n", arg);
}
// crashes here:
printf("Checking character at index 1 of the command line arguments.\n");
for (a = 1; a < argc; ++a) {
arg = argv[a];
printf("arg: %s\n", arg[1]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment