Skip to content

Instantly share code, notes, and snippets.

@badboy
Created March 4, 2020 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badboy/b5613a387084e5cfb4e3eaebe97efd93 to your computer and use it in GitHub Desktop.
Save badboy/b5613a387084e5cfb4e3eaebe97efd93 to your computer and use it in GitHub Desktop.
❯ cat t.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
char *s = malloc(13);
strcpy(s, "is it there?");
s[12] = 0;
printf("str: %s\n", s);
free(s);
printf("str: %s\n", s);
return 0;
}
[~]
❯ clang t.c
[~]
❯ ./a.out
str: is it there?
str: is it there?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment