title: 7-Segment display with printf and multidimensional array in C
body: <p>So my problem lies with my process_digit function I believe. The cases I don't think are indexing properly through each iteration of the 1's and 0's and so when I type in an input such as 4 i get an incorrect output. I'm not sure if the case
  statements are backwards or what's happening but essentially I think they are not correct.</p>
  
  <pre><code>//input is 1 2 3 4 5 6 7 8 9 0
  //output should be        _   _        _   _   _   _   _   _
  //                     |  _|  _|  |_| |_  |_    | |_| |_| | |
  //                     | |_   _|    |  _| |_|   | |_|   | |_|
  //output is              _    _        _   _    _  _    _   _
  //                     | _|   _|  |_|  |_  |_   |  |_|  |_| ||
  //                     | |_   _|  |    _|  |_|  |  |_|  _|  |_|
  //
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#include &lt;stdio.h&gt;
  #define MAX_DIGITS 10
  
  void clear_digits_array(void);
  void process_digit(int digit, int position);
  void print_digits_array(void);
  char digits[3][MAX_DIGITS*4];
  const int array[MAX_DIGITS][7]={{1,1,1,0,1,1,1},{0,0,1,0,0,1,0},{1,0,1,1,1,0,1},{1,0,1,1,0,1,1},{0,1,1,1,0,1,0},{1,1,0,1,0,1,1},{1,1,0,1,1,1,1},{1,0,1,0,0,1,0},{1,1,1,1,1,1,1},{1,1,1,1,0,1,1},};
  
  
  void clear_digits_array(void){
      int j=0,i=0;
      for(i=0;i&lt;3;i++){
          for(j=0;j&lt;MAX_DIGITS*4;j++){
              digits[i][j]='\0';
          }
      }
  }
  
  void process_digit(int digit, int position){
      int i=0;
      for(i=0;i&lt;7;i++){
          if(array[digit][i]==1){
              switch(i){
                  case 0: digits[0][1+position*4]='_';
                      break;
                  case 1: digits[1][0+position*4]='|';
                      break;
                  case 2: digits[1][2+position*4]='|';
                      break;
                  case 3: digits[1][1+position*4]='_';
                      break;
                  case 4: digits[2][0+position*4]='|';
                      break;
                  case 5: digits[2][2+position*4]='|';
                      break;
                  case 6: digits[2][1+position*4]='_';
                      break;
              }
          }
      }
  }
  void print_digits_array(void){
      int a=0,b=0;
      printf("                                                                                       ");
      for(a=0;a&lt;3;a++){
          printf("                                                                                       ");
          for(b=0;b&lt;MAX_DIGITS*4;b++)
              printf("%c",digits[a][b]);
          printf("                                                                                       ");
      }
      printf("                                                                                       ");
  }
  int main(void) {
      char character_number='\0';
      int a=0;
      
      clear_digits_array();
      printf("Enter a number:");
      while ((character_number=getchar())!='\n') {
          int number=MAX_DIGITS;
          switch(character_number){
              case '0': number=0;
                  break;
              case '1': number=1;
                  break;
              case '2': number=2;
                  break;
              case '3': number=3;
                  break;
              case '4': number=4;
                  break;
              case '5': number=5;
                  break;
              case '6': number=6;
                  break;
              case '7': number=7;
                  break;
              case '8': number=8;
                  break;
              case '9': number=9;
                  break;
              default: printf("%c ignored", character_number);
          }
          if(a==0){
              process_digit(number,a);
              a++;
          }
      }
      print_digits_array();
      return 0;
  }</code></pre>
  </div>
  </div>
  </p>