I need this done in C-Programming please! I need you to write a program rle that uses a simple method to compress strings. rle takes a single argument and looks for repeated characters. Each repeated sequence of a letter/punctuation mark is reduced to a single character plus an integer indicating the number of times it occurs. For example, “aa" becomes “a3" and “ab" becomes “albl". If the compressed string is longer than the original string, rle must print out the original string instead. If the input string contains numerical values, rle MUST print “error* and nothing else. Examples: $ /rle aaaaaa аб S Jrle aaabccc.a a3b1c4.2al $ /rle aaabab aaabab $ /rle alb2 Error

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

2. Can you please develop the code accordingly? It's not that long, I believe (relatively easy). Thanks in advance!

I need this done in C-Programming please!
I need you to write a program rle that uses a simple method to compress strings. rle takes a
single argument and looks for repeated characters. Each repeated sequence of a
letter/punctuation mark is reduced to a single character plus an integer indicating the number of
times it occurs.
For example, "aa" becomes "a3" and “ab" becomes "albl".
If the compressed string is longer than the original string, rle must print out the original string
instead. If the input string contains numerical values, rle MUST print “error" and nothing else.
Examples:
$ /rle aaaaaa
аб
$ /rle aaabccc..a
a3b1c4.2al
$ /rle aaabab
aaabab
$ /rle alb2
Error
Transcribed Image Text:I need this done in C-Programming please! I need you to write a program rle that uses a simple method to compress strings. rle takes a single argument and looks for repeated characters. Each repeated sequence of a letter/punctuation mark is reduced to a single character plus an integer indicating the number of times it occurs. For example, "aa" becomes "a3" and “ab" becomes "albl". If the compressed string is longer than the original string, rle must print out the original string instead. If the input string contains numerical values, rle MUST print “error" and nothing else. Examples: $ /rle aaaaaa аб $ /rle aaabccc..a a3b1c4.2al $ /rle aaabab aaabab $ /rle alb2 Error
Note:
1. rle prints that original string if its compression method results in a larger string than input
(third example above)
2. You MUST NOT assume that input strings have a max length. You must allocate space
to store the compressed string dynamically, based on the length of the input string.
3. You MUST NOT assume any maximum number of times a character will be repeated.
Rather than write your own integer to string function, you can use sprintf or snprintf with
an appropriate format string.
Transcribed Image Text:Note: 1. rle prints that original string if its compression method results in a larger string than input (third example above) 2. You MUST NOT assume that input strings have a max length. You must allocate space to store the compressed string dynamically, based on the length of the input string. 3. You MUST NOT assume any maximum number of times a character will be repeated. Rather than write your own integer to string function, you can use sprintf or snprintf with an appropriate format string.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education