? Linux ?,gets()
????????????,????????????
fgets()
:?????????????(? stdin)???????????gets()
???,?????????????,??????????
char buffer[256]; fgets(buffer, sizeof(buffer), stdin);
getline()
:???????fgets()
,?????????????????????????????char *
????????size_t
??????????,????free()
?????
#include#include char *line = NULL; size_t len = 0; ssize_t read; read = getline(&line, &len, stdin); if (read != -1) { printf("Read line: %s", line); } free(line);
scanf()
:????????????????????????????%s
???????????,????????????????,??????????
char buffer[256]; scanf("%5s", buffer);
???,scanf()
??????????????????,?????????????????
??,??????????????????????????,fgets()
? getline()
???????,????????????????????