Skip to content

Instantly share code, notes, and snippets.

@oatmealraisin
Created April 20, 2018 20:14
Show Gist options
  • Save oatmealraisin/6967a26acf3b5bde5a95b6c30e84ab67 to your computer and use it in GitHub Desktop.
Save oatmealraisin/6967a26acf3b5bde5a95b6c30e84ab67 to your computer and use it in GitHub Desktop.
#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