howdy,
this code snip is from an example i found in a Borland C++ book. i wrote it in GNU emacs and compiled from there using g++. when compiled i receive an error -
"in function 'int menu_select(void) the gets() function is dangerous and should not be used"
____________________code______________________
int main(void)
{
char choice;
init_list(); /* initialize the structure array*/
for(;;) {
choice = menu_select();
switch (choice) {
case 1: enter();
break;
case 2: del();
break;
case 3: list();
break;
case 4: return 0;
}
}
}
/*initialize the structure array*/
void init_list(void)
{
register int t;
for(t=0; t<MAX; ++t) inv_info[t].item[0] = '\0';
}
/*input the user's selection*/
int menu_select(void)
{
char s[80];
int c;
printf ("\n");
printf ("1. Enter An Item\n");
printf ("2. Remove An Item\n");
printf ("3. List The Inventory\n");
printf ("4. Quit\n");
do{
printf ("Enter Your Choice: ");
gets(s);
c = atoi(s);
} while (c<0 || c>4);
return c;
}
.
.
.
_________________code__________________
i tryed getchar() - error to many arguments
what would the correct way be to capture the single digit response and retun it to main?
or
am i getting excited about a meaningless warning?
M.R.