Skip to content

Instantly share code, notes, and snippets.

@webgtx
Created March 14, 2022 10:41
Show Gist options
  • Save webgtx/c048daa5c1c09231d6a3f8fcf156ba98 to your computer and use it in GitHub Desktop.
Save webgtx/c048daa5c1c09231d6a3f8fcf156ba98 to your computer and use it in GitHub Desktop.
Secure input read in C
void lnrd(char * str) {
int idx = 0;
while (true) {
char ch = getchar();
if (ch == '\n')
break;
str[idx] = ch;
idx++;
}
str[idx++] = '\0';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment