Question: #include #include /* * The isnumber() function examines the character given as its first * argument and returns true if and only if the character

#include
#include
/*
* The isnumber() function examines the character given as its first
* argument and returns true if and only if the character represents
* an number. This helper function should be relatively short.
*
* Returns true if the given character represents an number, false
* otherwise.
*/
bool isnumber(char c);
/*
* The decode() function takes a run-length encoded string as its
* argument, parses every integer n preceding every character in
* the string, and prints each character n times. For example, if
* the string passed to decode() is "1a3b", decode() will print
* "abbb". It returns an integer that represents the summed value
* of the amount of characters printed; in this example, decode()
* would return the integer 4.
*
* This function must also handle malformed run-length encoded strings.
* A malformed string is any string which does not adhere to the RLE
* implementation described in the handout. If a malformed string is
* encountered, it should cease printing the decoded string, print an
* error message, and return -1.
*
* Returns the integer value of the total amount of characters printed,
* or -1 if the run-length encoded string is malformed.
*/
int decode(char *str);
/*
* The main function is where C programs begin.
*
* This function parses its arguments and returns the value they
* represent. In this assignment, the only valid argument is a
* run-length encoded string. Any extra arguments in excess of
* this single valid argument make the invocation of your program
* invalid.
*
* Remember that the argument in argv[0] is the name of the program, so
* a program passed exactly one argument on the command line will
* receive _two_ arguments: its name in argv[0] and the provided
* argument in argv[1].
*
* Arguments:
* argc - The number of arguments received
* argv - The arguments received as an array of C strings
*
* Returns 0 if the argument is well-formed and the string could
* be decoded, non-zero otherwise.
*/
int main(int argc, char *argv[]) {
/* Your main program logic should go here, with helper logic in the
* functions isnumber() and decode(), which you can place below
* the closing brace of main() */
return 0;
}
/* You should implement isnumber() and decode() here */

Note that there is a C library function that could perform the role of isnumber() called isdigit(), and several C library functions that can parse the integers in the RLE string into C integers, including atoi() and strtol(). but you can not use that on it . !!!!!!!!!

input could be like 431a34b4c or just 2a3b2c those are valid but 0a2b no!!!!

using c programming language to do this run length decoding ....

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!