Skip to content

Instantly share code, notes, and snippets.

@JIghtuse
Created November 11, 2014 03:59
Show Gist options
  • Select an option

  • Save JIghtuse/ee178936b0c7e80f56a2 to your computer and use it in GitHub Desktop.

Select an option

Save JIghtuse/ee178936b0c7e80f56a2 to your computer and use it in GitHub Desktop.
%m length specifier allocates as many memory as needed to place input
#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