Skip to content

Instantly share code, notes, and snippets.

@obelisk68
Last active August 24, 2017 12:44
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 obelisk68/e7a9a2deee2d96f6670354d6d5aac0c4 to your computer and use it in GitHub Desktop.
Save obelisk68/e7a9a2deee2d96f6670354d6d5aac0c4 to your computer and use it in GitHub Desktop.
関数内で宣言した配列変数をreturnしてはいけない
#include <stdio.h>
char *keyboard_linein() {
char buf[1000];
fgets(buf, 1000, stdin);
printf("%s\n", buf);
return buf;
}
int main() {
char *s;
s = keyboard_linein();
printf("%s\n", s);
return 0;
}
//絶対に実行してはいけません。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment