Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Unix question I just don't know how to start that problem... I do have pieces of ideas, but cannot connect them... So I need some

Unix question

I just don't know how to start that problem... I do have pieces of ideas, but cannot connect them... So I need some hints or ideas so that I can have some thoughts solving that problem. Thanks. The question provide me some secret codes, and I should translate it to words.

Here is it:

Yes, it's in a secret code. But, you know the secret. Each character in the message equals some bits in the output string. Your code is this:

Code Bits
g 000
F 001
U 010
V 011
J 100
p 101
A 110
n 111
1 00
= 01
+ 10
* 11

Each character becomes some bits. For example, supposed you got the codes for these bits: 010 010 00 01 10 010 101 101 100 01 101 100 011 011 110. If you think of those as sequential bits, most significant bit first, you can group them in groups of 8 and you get this: 01001000 01100101 01101100 01101100 01101111 0. Those turn out to be the ASCII codes for "Hello". All you have to do is read the code one character at a time, and generate the bits for the decoded output as a character string.

The function you will fill in will be this:

/** * Decode an encoded string into a character stream. * @param encoded The input string we are decoding * @param decoded The output string we produce * @param maxLen The maximum size for decoded */ void decoder(const char *encoded, char *decoded, int maxLen) { } 

Here is a simple main program to test that your solution works. Note that this does not test every possible way the program may be used, but if your solution works you will get an output string that is English, not gibberish.

int main() { const char *encoded="\ U+g=J+p*F1A+g*g=V+g=A=J+g1n+U*V*V+p=A=g+g1A+g*g=V=A=J+F*F+U1\ g*p*V=F=p+F+A1U1g*J*V=g=J1p+p+A=U=g1V1F=p*F+U1U1g*U1V1p1p+g+\ g1n=g*V*V=n1p+g+g1n=A*U=V=J=p+g+g1A=g*U=V1p1J1g1A+g+J*p=V=A=\ J+F+U+n1J=g1V*F=p*p*U+n1J=g1V=V=p*F+J+A=J*F=F=A1J1F1g+U1g*F+\ V1p=A*J+g1n1J*F=V=p=J1p+J+A*J*U=V=A=J*J+g1A*U*U=V=A=A+p*U1A=\ U*J*F1g=J1p*F1A=U=g1V1F=p+F+A1U1g1V=g=U=n1p+n+n=U=g1V=g=J1p*\ V1A=U=V+F1g=g=F+U+A1A*g=V+p=A=p+U+U1g*p*V=g=J+p+n1U1g*p1V=g=\ J+J+g1A1U*g*V=F=J+g+g1n1J*F=V1F=J=p+J1A=U*J*F1g=p1F+J+A*U=V1\ F1g=p1F+U+U1g*p*V=F=p+F+A1U1g1V=g=U=p1F+g+n=J*F=F1g=J1J+g1A=\ J*g=V1V=J+J+g1A*g*U=V=V=J+J+g1A*U*U=V=A=J+J+g+"; char decoded[1000]; decoder(encoded, decoded, sizeof(decoded)); printf("%s", decoded); return 0; } 

It does not take much code, but it does require some thought about what bits and bytes really mean.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions