i have to do a code that takes the word from the user and seperate them from uppercase and lowercase.
i had done the code, but the words that are printed out are not as aspected (symbols)

#include<iostream>
#include <ctype.h>
using namespace std;

int main(){

int i=0;
int total_char=0;
cout<<"enter number of characters: ";
cin>>total_char;
char str[total_char];
char uppercase[total_char];
int num_upper=0;
char lowercase[total_char];
int num_lower=0;
char x;

cout<<"enter word: ";
cin>>str;


for(i=0;i<=total_char;i++)
{
    x=str[i];
    if(isupper(x))
    {uppercase[i]=x;
    num_upper++;}
    else
    {lowercase[i]=x;
    num_lower++;}

    }

cout<<"uppercase character: ";
for(i=0;i<num_upper;i++)
cout<<uppercase[i];

cout<<endl<<endl;

cout<<"lowercase character: ";
for(i=0;i<num_lower;i++)
cout<<lowercase[i];

cout<<endl<<endl;

system("pause");
}

Being a human and not a computer, it helps to give details. What is input? What should be output? What is actually output?

the input word: COdes

should output:

uppercase characters: CO
lowercase characters: des

but it output something like this:

uppercase characters: CO
lowercase characters: >Nd

When you test each character do you really want to use i to save the result?

thanks bro.... your my hero!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.