exercises/ex02/adder.c
void check_numeric(char number[]) {

  int i = 0;

  while (1) {

    switch (number[i]) {

      //  End character means you've reached the end of the string
      case '\0': return;

      // These characters are okay
      case '0': case '1': case '2': case '3': case '4':
      case '5': case '6': case '7': case '8': case '9':
         break;

      // Retain EOF character if you want to exit.
      case 'D':
        number[0] = 'D';
        break;

      default:
         printf("Non-numeric input. Treating input as 0.\n");

         // Reset all of number to zeros
         for (int j = 0; j < 10; j++) {

           if (number[j] == '\0') return;
           number[j] = '0';

         }
    }
    i++;
  }
}
/*
   Makes sure that all items in number are numbers 0-9.
   If another character is found, number is reset to 0 and
   a warning message is given.

   number - pointer to char array
*/
Makes sure that all items in number are numbers 0-9.
If another character is found, number is reset to 0 and
a warning message is given.

pointer to char array
Makes sure that all items in number are numbers 0 - 9 . If another character is found number is reset to 0 and a warning message is given . pointer to char array
void check_numeric(char number[]) {
  int i = 0;
  while (1) {
    switch (number[i]) {
      case '\0': return;
      case '0': case '1': case '2': case '3': case '4':
      case '5': case '6': case '7': case '8': case '9':
         break;
      case 'D':
        number[0] = 'D';
        break;
      default:
         printf("Non-numeric input. Treating input as 0.\n");
         for (int j = 0; j < 10; j++) {
           if (number[j] == '\0') return;
           number[j] = '0';
         }
    }
    i++;
  }
}
void check_numeric ( char number [ ] ) { int i = 0 ; while ( 1 ) { switch ( number [ i ] ) { case ' \0 ' : return ; case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : break ; case ' ' : number [ 0 ] = ' ' ; break ; default : printf ( " \n " ) ; for ( int j = 0 ; j < 10 ; j ++ ) { if ( number [ j ] == ' \0 ' ) return ; number [ j ] = ' ' ; } } i ++ ; } }
Makes sure that all items in number are numbers 0-9.
Makes sure that all items in number are numbers 0 - 9 .
//  End character means you've reached the end of the string // These characters are okay // Retain EOF character if you want to exit. // Reset all of number to zeros