what I want to do is replace the spaces inputted to '~10' text.
I input a string a1.
I change the string to a char array names SA so I can go through each char.
if the char is a space, I want to append ~10 to the sa string.
if the char is anything else, I would like to append the character.
The program works fine until I hit spaces.
if I input something like: hello world
the output will be hello+Garbage.
This is the best I came up with.
Thanks for taking your time to help an uber n00b :)
sa & sa1 are strings
SA is a char[50]
cin>>sa1;
strcpy(SA, sa1.c_str());
int i=0;
for(i;i<49;i++){
if (SA[i]==' '){
sa+="~10";
}
else
sa+=SA[i];
}
sa[49]='\0';
sa+=SA[49];
cout<<sa;