i need help removing spaces from a string..how do i go about this?? i have to report back the number of spaces too but ive been able to do that
thnx
(i dont want to use any of the string functions in the string library)
#include <iostream>
int stripspaces(char *str);
using namespace std;
int main()
{
char ar[100];
cout<<"Enter a sentence and I will strip out the spaces:"<<endl;
cin.getline(ar, 99);
cout<<"Your sentence without spaces is "<<stripspaces(ar)<<endl;
return 0;
}
int stripspaces(char *str)
{
int spacecounter = 0;
char *p= str;
while(*p)
{
if(*p == ' ')
{
//dont know how to set this up for removing spaces
spacecounter++;
}
p++;
}
return spacecounter;
}