/* fgets.c Ilustrates use of fgets() to avoid buffer overflow vulnerability by passing in limit */ #include #include #include #define BUF_CAP 10 int main() { int i; char buffer[BUF_CAP]={'\0'}; /* init first char to null */ printf("Enter your first name "); fflush(stdout); fgets(buffer, BUF_CAP, stdin); printf("Your name is: %s\n", buffer ); printf("\n char ascii\n"); for (i=0 ; i