Created
April 20, 2018 20:14
-
-
Save oatmealraisin/6967a26acf3b5bde5a95b6c30e84ab67 to your computer and use it in GitHub Desktop.
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 <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
char *foo() { | |
char *home = getenv("HOME"); | |
char *result = malloc(strlen(home) + strlen("/foo") + 1); | |
strcpy(result, home); | |
result = strcat(result, "/foo"); | |
return result; | |
} | |
int main() { | |
printf("%s\n", foo()); | |
printf("%s\n", foo()); | |
printf("%s\n", foo()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment