5. What does the following program do?
/* ex02-05.c */
#include <stdio.h>
#include <string.h>
int main(void)
{
char buffer[256];
printf("Enter your name and press <Enter>:\n");
gets(buffer);
printf("\nYour name has %d characters and spaces!", strlen(buffer));
return 0;
}
This program prompts the user to enter his or her name, and then prints the number of characters and spaces in the given string to the standard output. It then exits normally.
This program raises the possibility of a buffer overflow.
No comments:
Post a Comment