Skip to content

Instantly share code, notes, and snippets.

@khajavi
Created September 7, 2013 13:04
Show Gist options
  • Save khajavi/6475400 to your computer and use it in GitHub Desktop.
Save khajavi/6475400 to your computer and use it in GitHub Desktop.
getenv example.
#include <stdlib.h> //getenv, atoi
#include <stdio.h> //printf
int main() {
char* reps_text = getenv("reps");
int reps = reps_text ? atoi( reps_text ) : 10;
char* msg = getenv( "msg" );
if (!msg) msg = "Hello.";
int i;
for (i = 0; i < reps; i++) {
printf("%s\n", msg);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment