I have written this piece of code which removes spaces in string,its working perfectly, but the other thng that I need is to pass string to left trim function and remove spaces, the new string should returned to the main program, the new string should be passed to the right trim function and remove any
spaces at the end of the string. Return the trimmed string. Output the trimmed string. There should be some break point in string like "/" or "*" to divide left and rignt side of string. Could anyone help me with this???Please.Thanks a lot.
here's the code:
#include <iostream>
#include <iomanip>
#include <string>
#include <stdio.h>
using namespace std;
int main(void)
{
char s[50];
cout << "\nEnter String to Remove Spaces from: " << endl;
gets(s);
int len = strlen(s),j=0;
for(int i=0;i<len;i++)
{
if(isspace(s[i]))
{
j=i;
for(;j<len-1;j++)
s[j] = s[j+1];
if(i!=j)
{
s[j] = '\0';
len--;
}
}
}
cout << "\n\nNew Sting After Removing Spaces: " << s << endl;
system("pause");
}