0

Hi,

I need to sort a string of symbols and numbers in to two different strings, first one with numbers, second with symbols. I have written the following code, but it only passes the first type into its string and gives random characters for the second type. Example: if i type "1234abc" it return Numbers:1234 Symbols:random stuff. Same goes for opposite if i type "abc1234" it will return Numbers:random stuff Symbols:abc. Can someone please help me with this. Code is bellow.

```
#include <cstdlib>
#include <iostream>
#include <cctype>
#define n 99
#define m 99
#define b 99
using namespace std;
int main()
{
char x[n],y[m],z[b];
int k,s=0,d=0;
cout<<"Type in your characters: ";
cin.getline(x,n);
k=strlen(x);
for (int i=0; i<k; i++){
if(x[i]>='0' && x[i]<='9'){
y[i]=x[i];
s++;
}else{
z[i]=x[i];
d++;
}
}
cout<<"Numbers: ";
for (int i=0; i<s; i++){
cout<<*(y+i);
}
cout<<endl<<"Symbols: ";
for(int i=0; i<d; i++){
cout<<*(z+i);
}
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
```