training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

assprot.c (492B)


      1 /* Exercise 8.37 */
      2 
      3 #include <stdio.h>
      4 #include <string.h>
      5 
      6 #define NUMBERS 9
      7 
      8 int main(void)
      9 {
     10    char import[NUMBERS] = { 0 };
     11    int n = NUMBERS;
     12 
     13    printf("Give me the import: ");
     14    gets(import);
     15    while( (int)strlen(import) > NUMBERS ) {
     16       printf("Error: too many numbers\n");
     17       printf("Give me the import: ");
     18       gets(import);
     19    }
     20 
     21    printf("Protect number: ");
     22    n -= (int)strlen(import);
     23    while(n--)
     24       printf("*");
     25 
     26    printf("%s\n", import);
     27 
     28    return 0;
     29 }
     30