Write a program that accept the string, removes all empty space in the string, and replace all character ‘a’ to ‘A’ by display a new string. The program needs to write using array.
*Refer the output below:
Type your Story:
aminah works as a medical assistant at HRPB. She performed her duties as a dedicated frontliner throughout the covid19 outbreak. #stayathome. #staysafe.
Display a new string:
AminahworksAsAmedicalAssistantAtHRPB.SheperformedherdutiesAsAdedicAted frontlinerthroughoutthecovid19outbreAk.#stAyAthome.#stAysAfe.
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
    const int N=4096;
    char str[N];
    char ch;
    int i=0;
    cout << "Type your Story:" << endl;
    while (i<N-1 && cin) {
        cin >> ch;
        if (iswspace(ch)) {
            continue;
        }
        if (ch == 'a') {
            ch = 'A';
        }
        str[i++] = ch;
    }
    str[--i] = '\0';
    cout << "A new string:" << endl;
    cout << str << endl;
}
Comments