Created
November 11, 2014 03:59
-
-
Save JIghtuse/ee178936b0c7e80f56a2 to your computer and use it in GitHub Desktop.
%m length specifier allocates as many memory as needed to place input
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 <unistd.h> | |
| #ifdef __GLIBC__ | |
| #if !(__GLIBC_PREREQ(2, 7)) | |
| #error %m is not available | |
| #endif | |
| #elif defined(_POSIX_VERSION) | |
| #if _POSIX_VERSION < 200809L | |
| #error %m is not available | |
| #endif | |
| #else | |
| #error Your C-library is not supported. | |
| #endif | |
| int main(void) | |
| { | |
| char *s; | |
| scanf("%ms", &s); | |
| printf("%s\n", s); | |
| free(s); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment