Created
June 20, 2014 18:21
-
-
Save gsora/6d8cdaf82519c47fae19 to your computer and use it in GitHub Desktop.
This is why gets() is unsafe
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
| #include <stdio.h> | |
| #define BUF 5 | |
| int main(void) { | |
| int a = 2; | |
| char word[BUF]; | |
| printf("Declaread an integer a = 2, and a string.\nThis is where the gets kicks in.\nThe string where gets() will write is big 5, try to write someting > 5 and see what appends!\ngets: "); | |
| gets(word); | |
| printf("\nString:%s\na = %d\n", word, a); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment