-
stdin question
Code:
#include <stdio.h>
#define MAX=80
int main(void)
{
char puffer[MAX];
fgets(puffer,MAX-1,stdin);
return 0;
}
I´ve the following question:
If you enter more than MAX-1 characters, what does happen with the characters after MAX-1 then?
I know that they will stay in stdin and be read in with the next call of e.g. fgets(), but what is, if the string´s length is too long for stdin?
I was taught that there cannot be any buffer-overflow, when you use fgets() in the example above, but how is this been prevent?
And can you then tell me how to find out the stdin-puffer´s size?
Thank you!
klausi
-
You're simply telling fgets() to not pay attention to any number of characters greater than MAX-1. It pretty much is as simple as it looks.
starX
www.axisoftime.com
-
But the numbers of characters greater than MAX-1 are in stdin after calling it. If I call fgets() again it reads first these characters from stdin!
klausi