Question: Could I get some help writing this code? The final code should be in C and allow for both user input as well as using

Could I get some help writing this code? The final code should be in C and allow for both user input as well as using testinput as a file at the bottom of this problem by running "./lab1 . Please use the lab1.c section as a template and do not use math.h as -lm cannot be used for compiling!

Could I get some help writing this code? The final code should

be in C and allow for both user input as well as

using testinput as a file at the bottom of this problem by

lab1.c:

#include #include #include

/otice there is no semi-colon at the end of a #define #define MAXLINE 100 #define MINNUM 10 #define MAXNUM 100 #define MINSIZE 6 #define MAXSIZE 12 #define MINKEY 1 #define MAXKEY 5

int main() { char line[MAXLINE]; int msgsize; int keyvalue;

/* You are REQUIRED to use fgets() and sscanf(). * Use of scanf() is prohibited! */ fgets(line, MAXLINE, stdin); sscanf(line, "%d", &msgsize); printf(" Msgsize is set to %d. ", msgsize); printf(" KeyValue is set to %d. ", keyvalue);

// Use one of the following prints // you must use exactly these prints and you cannot change the text

//printf(">> No more message received. Program exit. "); printf(">> Msg: I'm safe, all good. "); printf(">> Msg: Mission Success. Agent ID: %d. ", id); printf(">> Msg: Mission Failed. Agent ID: %d. ", id); printf(">> Msg: Don't contact me. "); printf(">> Msg: No Content. "); // or printf(">> Corrupted Message. "); printf("No waveform detected "); printf(" >> Agent Center is not safe now. Go find a safe place. Program exited. ");

exit(0); }

testinput:

8 3 11 12 13 14 15 16 17 18 19 20 21 22 50 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 3 43 44 45 46 47 48 49 -2

Background: Our special agents use secret messages to communicate their status to Headquarters. Here at HQ, we de-crypt the messages sent by the agents. The decryption algorithm works as follows: a. 1. A message consists of a sequence of numbers between 10 and 100 (10>Minimum Required Output for the Sample Input: 6 (the size of each subsequent message) 2 (the key to be used for all messages) 11 (first message begins here) 12 13 14 15 16 >>Mission Success. Agent ID: 16. 13 13 13 12 14 18 >>Don't contact me. 22 23 25 26 22 23 >>I'm safe, all good. 8 12 13 14 15 16 >> Corrupted Message. -2 >> Agent Center is not safe now. Go find a safe place. Program exited. You compile your code using: $ gcc -Wall -g labi.c -o labi Background: Our special agents use secret messages to communicate their status to Headquarters. Here at HQ, we de-crypt the messages sent by the agents. The decryption algorithm works as follows: a. 1. A message consists of a sequence of numbers between 10 and 100 (10>Minimum Required Output for the Sample Input: 6 (the size of each subsequent message) 2 (the key to be used for all messages) 11 (first message begins here) 12 13 14 15 16 >>Mission Success. Agent ID: 16. 13 13 13 12 14 18 >>Don't contact me. 22 23 25 26 22 23 >>I'm safe, all good. 8 12 13 14 15 16 >> Corrupted Message. -2 >> Agent Center is not safe now. Go find a safe place. Program exited. You compile your code using: $ gcc -Wall -g labi.c -o labi

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!