This is a code for removing spaces from a string, I've been asked to do this without using any standard library functions like isspace
or '\b'
. I've been trying for a lot of time but it always gives the same error
Error : Cannot convert 'char' to "char *"
Here is the code :
void string :: rem_spc()
{
int i,j,l;
l = strlen(str);
for(i=0; str[i]!='\0';i++)
{
if(str[i] == " ")
str[i] = str[i+1];
}
for(i = 0; i<l; i++)
{
cout<<str[i];
}
}