Created
January 2, 2021 19:45
-
-
Save sidewinder040/2f12c90b7729f7705fdbe1a4d288e4e8 to your computer and use it in GitHub Desktop.
A safer way to get user data, limited to size of Buffer
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
// A safer way to get user data, limited to size of Buffer | |
#include <stdio.h> | |
#define BUFFER_SIZE 15 | |
int main(int argc, char const *argv[]) | |
{ | |
printf("Please enter your name: "); | |
char name[BUFFER_SIZE]; | |
fgets(name, sizeof(name), stdin); | |
printf("Hello %s", name); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment