So I was told if you use
Code:
char whatever[BUFSIZE +1]
you could prevent buffer overflow. However on compiling a test program, it returned BUFSIZE to be have 513 bytes max. Doesn't that mean if you go over 514 then you can have a buffer overflow.
Or does it make a difference if you use or to get the user inputs.
Here is my code to determine BUFSIZ
Code:
/* scanfTEST.c */
#include <stdio.h>
#include <ctype.h>
#define PRAISE "My that is a nice name"
int main (void)
{
char name[BUFSIZ+1];
int size, nameLEN;
printf("What is your name?\n");
scanf(" %s", name); /* ignores leading whitespace but not the following whitespace */
size = sizeof (name);
nameLEN = strlen(name);
printf("Hello, %s. %s\n", name, PRAISE);
printf("Your name can hold max %d bytes. But its is now of %d charaters\n", size, nameLEN);
system("pause");
return (0);
}