NO

Author Topic: Define - is stdin empty  (Read 14632 times)

vedro-compota

  • Guest
Re: Define - is stdin empty
« Reply #15 on: October 22, 2011, 03:41:28 PM »
last attempt - concrect problem is here  = http://fkn.ktu10.com/?q=node/150 (it's just collection of moments which we've discussed with  specific wording of the problem)

CommonTater , I totally agree with your advices about way of programming stading and i also "just get it" about scanf() and other - big thanks for this - especially for s standard pdf))
i'm really try to understand problems which may be not important  in current situation  - and mau be it isn't right or isn't good.

 ( scanf(" %c", ch) - will shut program down after few seconds of working  - compiler 'll show warning that the "ch" variable isn't in use - I don't understand  why it's so - but that's "other thread" as I understand )

i'm just want to understand as much as possible about with which i deal) The c standart will really help me with this = you've really helped me with this - big thanks)
« Last Edit: October 22, 2011, 03:44:15 PM by vedro-compota »

CommonTater

  • Guest
Re: Define - is stdin empty
« Reply #16 on: October 22, 2011, 06:30:09 PM »
Code: [Select]
int mainmenu(void)
  {   
     int ch;     
     char* mtext = " Please specify the number of the task. \n * You can choose on number from set = {1} \n * Specify \"0\" to exit\n" ;
    char* errmes = " Error(!) = Main menu does not support this command.\n Make sure that your task number is from menu set of commands and try again. " ;       

     printf("\n%s",mtext );     
     ch = getchar() ;
     while (getchar() != '\n');

     switch(ch)   
        {
           case '0':   
               printf("\nyou choise is item 0 \n" );
               break;
           case '1':
               printf("\nyou choise is item 1 \n" );
               break;       
           default:
              printf("\nInvalid choice\n");   
         }   
      return 0; 
}

Quote

scanf(" %c", ch) - will shut program down after few seconds of working  - compiler 'll show warning that the "ch" variable isn't in use - I don't understand  why it's so - but that's "other thread" as I understand

scanf (" %c", &ch);


« Last Edit: October 22, 2011, 09:30:06 PM by CommonTater »

vedro-compota

  • Guest
Re: Define - is stdin empty
« Reply #17 on: October 24, 2011, 04:14:54 PM »
thank you)