Created
September 7, 2013 13:04
-
-
Save khajavi/6475400 to your computer and use it in GitHub Desktop.
getenv example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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