title: nested switch case not working
body: <p>I am trying to execute some commands using USART communication and reading some values using ATmega32-A. have a look at my code . My problem is i am trying to add some cases (nested switch case) but i am not getting what i want. I hope i am giving all most all information required to solve my problem.</p>
  
  <pre><code>void uniCom(void) {
  switch (Command) {
  /* ... */
  case (muxsel):
    printf(muxselection);
    switch (c) {
      case 1:
        printf("this is mux chaneel1");
        DDRB = 0b10111111;
        PORTB = 0b00000000;
        printf("adc Value", ReadAdc());
        Command = 0;
        break;
      case 2:
        /*-------------------*/
        break;
    }
    Command = 0;
  break;
  /* ... */
  default:
      Command = 0;
      break;
  }
  </code></pre>
  
  <p>}
  The problem is undefined c. And I don't see any declaration of muxselection, maybe missing "" ? Now the second approach.</p>
  
  <pre><code>void selcase(void) {
  unsigned char c;
  printf("muxselection");
  while (rx_counter0) {
   c = getchar();
  switch (c) {
    case 1:
      printf("this is mux chaneel1");
      DDRB = 0b10111111;
      PORTB = 0b00000000;
      printf("adc Value", ReadAdc());
      Command = 0;
      break;
    case 2:
      /*-------------------*/
      break;
  }
  }
  }
  void uniCom(void) {
  switch (Command) {
  /* ... */
  case (muxsel):
    printf(muxselection);
    selcase();
    Command = 0;
    break;
  /* ... */
  default:
      Command = 0;
      break;
  }
  }
  </code></pre>
  
  <p>My problem is i am executing all the commands as i declared but i want to select some more cases in one of the main switch case command "muxsel". for that i wrote nested switch case. if i select "muxsel" command on hyperteminal then it is printing like "muxselection" then if i enter 1 to select "case '1'"in second switch, nothing is printing. it is printing "command not found". what is the problem. I want execute nested switch but i am not able to do that using above code I have tried like this also.</p>
  
  <pre><code>void selcase(void) {
           unsigned char c;
           printf("muxselection");
           while (rx_counter0) {
           c = getchar();
  
           switch (c) {
                    case '1':
                      printf("this is mux chaneel1");
                      DDRB = 0b10111111;
                      PORTB = 0b00000000;
                      printf("adc Value", ReadAdc());
                      c= 0;
                      break;
                    case '2':
                    /*-------------------*/
                    break;
                   default;
                    break;
                 }
              }
            }
  </code></pre>
  
  <p>creating one function for nested switch case and calling in main switch case as shown below.</p>
  
  <pre><code>  void uniCom(void) {
        switch (Command) {
                   /* ... */
                     case (muxsel):
                            printf(muxselection);
                            selcase();
                            Command = 0;
                            break;
                       /* ... */
                       default:
                         Command = 0;
                         break;
           }
         }
  </code></pre>
  
  <p>this way also not working please suggest me how to overcome this problem. i want to select one of the command in main switch case such as "muxsel" after that i have select mux channels using case statement. any help appreciated.</p>
  
  <p>Thanks in advance.</p>
  
  <p>I have solved this problem.</p>