Created
March 14, 2022 10:41
-
-
Save webgtx/c048daa5c1c09231d6a3f8fcf156ba98 to your computer and use it in GitHub Desktop.
Secure input read in C
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
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