Running code with gets from the command line. I get a warning that gets is unsafe. Did I unknowingly switch to the hated microsoft? What's with the warning? Should I turn it off? How? or reprogram with scanf?
Running code with gets from the command line. I get a warning that gets is unsafe. Did I unknowingly switch to the hated microsoft? What's with the warning? Should I turn it off? How? or reprogram with scanf?
a = 'Y';
date = (char*) calloc(10, sizeof(char));
do
{
printf("input date xx/xx/xx\n");
fgets(date,8,stdin);
fflush(stdin);
if(strlen(date) == 8)
{
printf("Is this the right date Y or N? %s\n", date);
a = getc(stdin);
fflush(stdin);
}
else
{
printf("wrong format for date\n");
a = 'N';
}
}
while((a == 'N') || (a == 'n'));
char * safe_gets( char * str, int size );
The previous discussion was not about fgets and the command line. I tried fgets in various ways; it doesn't work as well as gets.