Question: Using C++ to program, read random contents from a file in the main have been written, requires to a function follow the steps: Given: decode_char(block)

Using C++ to program, read random contents from a file in the main have been written, requires to a function follow the steps:

Given:

decode_char(block) ret = 0 remaining = 8 // number of letters we are still looking for // Go through every character in the message for every character c in the block // Verify it is a letter, otherwise ignore it if c is an alphabetic letter decrement remaining // If it is upper case, that indicates a 1. // Otherwise we can ignore it if c is upper case set the remaining bit of ret to 1 // If we found all the bits we are looking for, stop if remaining == 0 break if we didn't find all the characters we needed throw en error return ret

find_boundary

// Count how many characters after start you need to travel to find 8 alphabetic characters // If not enough are found, return -1 find_boundary(message, start) offset = 0 remaining = 8 while there are remaining characters if start + offset >= length of message return -1; if message[start + offset] is an alphabetic character decrement remaining increment offset return offset

Write program for:

decode_string

decode_string(message) ret = "" start = 0 infinite loop block_length = find_boundary(message, start) 

rogram for:

 // Ensure we have enough to make a block if block_length == -1 throw an error block = substring of message starting at start, block_length characters in length c = decode_char(block) // Check for null terminator if c == '\0' break; append c to ret increment start by block_length return ret

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!