Question: Please finsh this program[C]: Here are the assignment instructions. Below the instructions is the incomplete program. Please add to this to finish the program .
Please finsh this program[C]:
Here are the assignment instructions. Below the instructions is the incomplete program. Please add to this to finish the program.
I. Programming Instructions:
1. Header files that you need to include unless you prefer to implement some necessary functions by yourself: #include
2. Functions you might need to use: malloc(); // function defined in stdlib.h free(); // function defined in stdlib.h strtok(); // function defined in string.h strlen(); // function defined in string.h toupper(); // function defined in ctype.h isalpha(); // function defined in ctype.h isdigit(); // function defined in ctype.h scanf(); // function defined in stdio.h gets(); // function defined in stdio.h printf(); // function defined in stdio.h
3. Essential knowledge that will be used: struct, pointer, array, dictionary, string tokenization, if statement, while statement, function call/definition
II. Morse Code Instructions: 1. Separating letters within one word using one space; 2. Separating words within one sentence using three spaces; 3. The conversion table is as follow:
![Please finsh this program[C]: Here are the assignment instructions. Below the instructions](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2feab52f63_93866f2feaaddc21.jpg)
Test Instructions:
1. Input: One sentence consisting of a few words(both uppercase and lowercase) and numbers. For example, Go 2017; 2. Output: Corresponding Morse codes of the input in accordance with the conversion table below. For example, --. --- ..--- ----- .---- --...;
Started Program:
#include #include #include char * lookup(char *p); void init(); #define SIZE 36 /* define the struct for the morse conversion table */ typedef struct { char character; // either letter or digit char code[6]; // corresponding morse code } conversion; conversion records[SIZE]; // 26 letters plus 10 digits int main () { // first thing: we need to create and initialize the table init(); // get the sentence from the user char sentence[5000]; gets(sentence); // once we get the sentence, we need to split it char *p; // temp pointer to store the return value from strtok p = strtok(sentence, " "); // fisrt call while (p != NULL) { // print out the corresponding morse code // printf("%s ", p); printf("code: %s ", lookup(p)); p = strtok(NULL, " "); // the following call } return 0; } char * lookup(char *p) { char *ans; int isFound = 0; int i = 0; while (!isFound && i TUVWXYZ 1 2 3 4 5 6 7 8 9 0 ABCD"E F G H I J K L M N O P Q R S Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
