Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define STORE_MODE 1
- #define CHECK_MODE 0
- #define BUF_NOTES 500
- #define BUF_TOPIC 30
- #define BUF_SUBJECT 4
- #define BUF_KEY 10
- #define L1 0
- #define L2 1
- #define STR 0
- #define INT 1
- enum subjects { ALOG, VLSI, EDC, CTRL, EMT, SIG, COMM, NET };
- typedef struct {
- int mode ;
- int level;
- char subject[BUF_SUBJECT], topic[BUF_TOPIC], notes[BUF_NOTES], key[BUF_KEY];
- } operation;
- int main(int argc, const char *argv[])
- {
- operation *temp_op=NULL;
- temp_op = (operation *) malloc(sizeof(operation));
- temp_op->mode=2;
- int flag=0,i=0;
- char *temp;
- if (strcmp("st",argv[1]) == 0) {
- temp_op->mode=STORE_MODE;
- printf("\n In store mode");
- }
- else
- if(strcmp("ch",argv[1])==0) {
- temp_op->mode=CHECK_MODE;
- printf("\n In check mode");
- }
- if (temp_op->mode == 2) {
- printf("Usage: key [st|ch] <options>\nWrong switch given. Must be either st or ch");
- return 1;
- }
- if( temp_op->mode ) {
- switch (argc) {
- case 2: printf("\nEnter the subject code: ");
- while(fgets(temp_op->subject, BUF_NOTES, stdin)==NULL);
- case 3: printf("\nEnter the topic: ");
- while(fgets(temp_op->topic, BUF_TOPIC, stdin)==NULL);
- case 4: printf("\nEnter the Level: ");
- flag = fscanf(stdin,"%d",&temp_op->level);
- case 5: printf("\nEnter the Answer Key: ");
- while(fgets(temp_op->key, BUF_KEY, stdin)==NULL);
- case 6: printf("\nEnter any additional notes(optional): ");
- while(fgets(temp_op->notes, BUF_NOTES, stdin)==NULL);
- break;
- default:printf("\nExcess Arguments");
- }
- }
- else {
- //code for CHECK_MODE
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment