Skip to content

Instantly share code, notes, and snippets.

@louy2
Last active July 6, 2016 03:29
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 louy2/3af07d0ae92c21019499f2169c33fbcd to your computer and use it in GitHub Desktop.
Save louy2/3af07d0ae92c21019499f2169c33fbcd to your computer and use it in GitHub Desktop.
// test null-terminated number
if (sscanf(string, "%d%c", &number, &dummy) == 1)
// test \n-terminated number i.e. stdin
if (sscanf(string, "%d%c", &number, &dummy) == 2 || dummy == '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment