Removing spaces from a string
Remove() takes 2 parameters as its input parameter: first is the character array (string) and the second is the character to remove.It returns the string without the specificed character.
If the input string is “Saad Bin Saulat”, and the characetr to remove is ‘a’,then it will return “SdBinSult”.
Summary of Remove()
A for loop starts from the 0th index of the string and iterates till end. The end of the string is indicated by the NULL character ‘\0’ which is present at the end of every string. At each iteration of the for loop, the character is checked – if the character is equal to the character to remove, then the whole string is shifted one index back by the second for loop.
After the end of for loop the string in str is returned from the function.
String at start : Saad Bin Saulat
String after removal of character ' ' : SaadBinSaulat
String after removal of character 'a' : SdBinSult