c-basic/echo.c

18 lines
628 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
int main() {
char s[100];
//gets(s);
/*
* Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and be
* cause gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break
* computer security. Use fgets() instead.
*
* For more information, see CWE-242 (aka "Use of Inherently Dangerous Function") at http://cwe.mitre.org/data/definitions/242.html
*
*/
fgets(s, sizeof(s), stdin);
printf("%s\n", s);
return 0;
}