Guest User

Untitled

a guest
Oct 9th, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define STORE_MODE 1
  6. #define CHECK_MODE 0
  7.  
  8. #define BUF_NOTES 500
  9. #define BUF_TOPIC 30
  10. #define BUF_SUBJECT 4
  11. #define BUF_KEY 10
  12.  
  13. #define L1 0
  14. #define L2 1
  15.  
  16. #define STR 0
  17. #define INT 1
  18.  
  19. enum subjects { ALOG, VLSI, EDC, CTRL, EMT, SIG, COMM, NET };
  20.  
  21. typedef struct {
  22.     int mode ;
  23.     int level;
  24.     char subject[BUF_SUBJECT], topic[BUF_TOPIC], notes[BUF_NOTES], key[BUF_KEY];
  25. } operation;
  26.  
  27. int main(int argc, const char *argv[])
  28. {
  29.    
  30.     operation *temp_op=NULL;
  31.     temp_op = (operation *) malloc(sizeof(operation));
  32.     temp_op->mode=2;
  33.     int flag=0,i=0;
  34.     char *temp;
  35.    
  36.     if (strcmp("st",argv[1]) == 0) {
  37.         temp_op->mode=STORE_MODE;
  38.         printf("\n In store mode");
  39.     }
  40.     else
  41.         if(strcmp("ch",argv[1])==0) {
  42.             temp_op->mode=CHECK_MODE;
  43.             printf("\n In check mode");
  44.         }
  45.     if (temp_op->mode == 2) {
  46.         printf("Usage: key [st|ch] <options>\nWrong switch given. Must be either st or ch");
  47.         return 1;
  48.     }
  49.    
  50.     if( temp_op->mode ) {
  51.         switch (argc) {
  52.                 case 2: printf("\nEnter the subject code: ");
  53.                     while(fgets(temp_op->subject, BUF_NOTES, stdin)==NULL);
  54.                 case 3: printf("\nEnter the topic: ");
  55.                     while(fgets(temp_op->topic, BUF_TOPIC, stdin)==NULL);
  56.                 case 4: printf("\nEnter the Level: ");
  57.                     flag = fscanf(stdin,"%d",&temp_op->level);
  58.                 case 5: printf("\nEnter the Answer Key: ");
  59.                     while(fgets(temp_op->key, BUF_KEY, stdin)==NULL);
  60.                 case 6: printf("\nEnter any additional notes(optional): ");
  61.                     while(fgets(temp_op->notes, BUF_NOTES, stdin)==NULL);
  62.                     break;
  63.                 default:printf("\nExcess Arguments");
  64.             }
  65.  
  66.     }
  67.     else {
  68.         //code for CHECK_MODE
  69.     }
  70.    
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment