-1
\$\begingroup\$

how what am i supposed to make cout so the changes i make show up as the out put because putting a just shows the original string

#include <iostream>

using namespace std;

int main()
{
string a = "w is the time for all good people to come to the aide of their country.";

for (int i = 0; a[i] != '\0'; i++)
{
    switch (a[i])
    {
    case 'a':a[i] = '#';
        break;
    case 'e':a[i] = '#';
        break;
    case 'i':a[i] = '#';
        break;
    case 'o':a[i] = '#';
        break;
    case 'u':a[i] = '#';
        break;
    {
for (unsigned int l = 0; l < a.length(); l++)
{
    a[l] = toupper(a[l]);
}
}

    }
    cout <<  << endl;
 return 0;
}
}
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information. \$\endgroup\$
    – Edward
    Feb 2, 2021 at 22:11
  • \$\begingroup\$ You can spot your error easily if you use good indentation. \$\endgroup\$ Feb 3, 2021 at 0:25
  • \$\begingroup\$ PS. It still does not compile. Please just make sure the code works before you post. Make sure the code is formatted nicely. This will solve 90% of your issues. \$\endgroup\$ Feb 3, 2021 at 0:27

1 Answer 1

1
\$\begingroup\$

I just want to show you your code when it has been correctly formatted:

#include <iostream>

using namespace std;

int main()
{
    string a = "w is the time for all good people to come to the aide of their country.";

    for (int i = 0; a[i] != '\0'; i++)
    {
        switch (a[i])
        {
            case 'a':a[i] = '#';
                     break;
            case 'e':a[i] = '#';
                     break;
            case 'i':a[i] = '#';
                     break;
            case 'o':a[i] = '#';
                     break;
            case 'u':a[i] = '#';
                     break;
                     {
                         for (unsigned int l = 0; l < a.length(); l++)
                         {
                             a[l] = toupper(a[l]);
                         }
                     }

        }
        cout <<  << endl;
        return 0;
    }
}

I think the errors jump out at you because you can see that the printing is at the wrong level of indentation.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.