using the cctype

Hello guys. I was asked to write a programme which involves using the toupper() and tolower() functions.

But every time I run the programme I end up with some garbage characters at the middle or at the end of my actual string.

Please some should help point out where I went wrong.

Here is the code

1
2
3
4
5
6
7
8
9
  char man[50] = "Misbahu Abubakar Kofar Atiku Area Sokoto";
char woman[50];
for (int i = 0; man[i] != '\0'; i++)
{
        woman[i] = toupper(man[i]);
}


cout << woman << endl;


Looks like the toupper() function is doing something messy with the ' '. Please help. Thanks

You have forgot to write a null termination character '\0' to mark the end of the woman string.
oh!! that seems to solve my problem. thank you peter87
Topic archived. No new replies allowed.