Question: how to implement this with a getchar function Your program must extract the secret message from the input file. The message is hidden inside the
how to implement this with a getchar function
Your program must extract the secret message from the input file. The message is hidden inside the file using the following scheme. The message is hidden in binary notation, as a sequence of 0s and 1s. Each block of 8-bits is the ASCII encoding of a single character in the secret message. Your program will scan the input, and for each period (aka, dot) encountered, your program will count the number of spaces (ASCII 0x20) that immediately follow the dot. If the number of spaces is 0, then your program will ignore that dot completely. If the number of spaces is 1, then that corresponds to a single 0 bit of the secret message. If the number of spaces is 2, then that corresponds to a single 1 bit of the secret message. Finally, if the number of spaces is 3 or more, then that indicates that there are no more characters in the secret message. Your program must scan the input file, and output to stdout the plain text secret message. If your program successfully completes its task, then the program should return an exit status of 0 to the operating system. If the number of bits in the message is not a multiple of 8 (8 bits for each ASCII character), then your program should return an exit status of 1. If the input file does not containing the message over signal, i.e., a dot followed by 3 or more spaces, then your program should return an exit status of 2.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
