Skip to content

Instantly share code, notes, and snippets.

@nunq
Last active January 30, 2019 06:28
Show Gist options
  • Save nunq/8d62293c9e180429dc27fc4cb7fca4ec to your computer and use it in GitHub Desktop.
Save nunq/8d62293c9e180429dc27fc4cb7fca4ec to your computer and use it in GitHub Desktop.
decide things, supply options with commandline arguments
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[]) {
srand((unsigned)time(NULL) * getpid(NULL));
char* resultString = argv[rand()%argc];
if (resultString == argv[0]) { resultString = "try again"; }
printf("result: %s\n", resultString);
return 0; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment