Created
July 24, 2014 13:28
-
-
Save kaworu/35642f625a6bab1ba635 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 <stdlib.h> | |
#include <string.h> | |
struct s { | |
char *str; | |
}; | |
int | |
main(int argc, char **argv) | |
{ | |
struct s *x; | |
size_t len = strlen(argv[0]); | |
x = malloc(sizeof(struct s) + len + 1); | |
x->str = (char *)(x + 1); | |
(void)memcpy(x->str, argv[0], len + 1); | |
(void)printf("voila: %s\n", x->str); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment