Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C language. #include #include #include int main( int argc, char *argv[]) { FILE *fin, *fout; int i, j, n; char line[102] = {0}; char
In C language.
#include
#include
#include
int main(int argc, char *argv[]) {
FILE *fin, *fout;
int i, j, n;
char line[102] = {0};
char key[50][102] = {0}, value[50][102] = {0}, input[102] = {0}, output[102] = {0};
fin = fopen(argv[1], "r");
fout = fopen(argv[2], "w");
fscanf(fin, "%d ", &n);
for (i = 0; i
fgets(line, 102, fin);
// Your code here
memset(line, 0, sizeof(line));
}
fgets(input, 102, fin);
input[strlen(input)-1] = 0;
// Your code here
// output format
fprintf(fout, "%s ", output);
fclose(fin);
fclose(fout);
return 0;
}
Question 3: Symbol Table and Hashed String (30\%) You are given the list of key:value pairs, and a hashed string. Recover the hashed string to its original text. Your program should read the input from the file, and output the answer to another file. The first argument is the input file name, while the second argument is the output file name. Name your program as "lab4-q3.c". Input file: A positive integer n(n50), indicating the number of key:value pairs in the symbol table. Following n lines, the key and value pairs are separated by a colon. Then, one more line for the hashed string. You can assume that the colon does not appear in the keys and the values. Each line has at most 100 characters. However, keys and values may contain spaces. Output file: Output the original texts. You can assume that the hashed string can be uniquely decoded. Sample Input: 4 1:I 01: Love 001:Data 000 : Structures 101001000 Sample Output: ILoveDataStructuresStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started