Skip to content

Instantly share code, notes, and snippets.

@0rbianta
Last active December 4, 2021 07:08
Show Gist options
  • Save 0rbianta/9f6494247892ca37e45337461f125dc8 to your computer and use it in GitHub Desktop.
Save 0rbianta/9f6494247892ca37e45337461f125dc8 to your computer and use it in GitHub Desktop.
Overflow-safe string input for C
#include <stdio.h>
#include <string.h>
void stdinputs(char *strbuff, int len)
{
char *usr;
scanf("%ms", &usr);
strncpy(strbuff, usr, len);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment