Write a program to remove all punctuation marks from an inputted message. The program should read an input message from a user into an array of characters; it should then modify the contents of the message, so that all punctuation marks are removed; and finally it should print out the modified message using a single printf statement. If the user types: Too, many, punctuation marks:; by far!! the program should output Too many punctuation marks by far For the purposes of this question, a punctuation mark is any one of the following seven characters !’?;:,. For example: Input Result Too, many, punctuation marks:; by far!! Too many punctuation marks by far Hyphen "-" survives ; why? as it is not one of the listed punctuation marks. Hyphen "-" survives why as it is not one of the listed punctuation marks

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Write a program to remove all punctuation marks from an inputted message. The program should read an input message from a user into an array of characters; it should then modify the contents of the message, so that all punctuation marks are removed; and finally it should print out the modified message using a single printf statement.

If the user types:

Too, many, punctuation marks:; by far!!

the program should output

Too many punctuation marks by far

For the purposes of this question, a punctuation mark is any one of the following seven characters !’?;:,.

For example:

Input Result
Too, many, punctuation marks:; by far!! Too many punctuation marks by far
Hyphen "-" survives ; why? as it is not one of the listed punctuation marks. Hyphen "-" survives why as it is not one of the listed punctuation marks

 

Code I was given:

 

#include <stdio.h>
#define MAX_MSG_LEN 256

int main(void)
{
  char msg[MAX_MSG_LEN+1];
  
  fgets(msg, MAX_MSG_LEN, stdin);
  
  /* write your solution here ... */

 
  
  return 0;
  
}

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT