Description
This example shows how to replace the spaces in a c string by a given character.
Copyright © 1997-2002 Rodolfo A. Frino. All rights reserved.
char* TForm1::Replace_SpacesIn_C_str( char* s, char c )
{
char sNoSpaces[500];
int i = 0;
int j = 0;
while (s[j] != '\0')
{
if (s[j] == ' ')
sNoSpaces[i] = c;
else
sNoSpaces[i] = s[j];
i++;
j++;
}
sNoSpaces[i] = '\0'; //PUT THE TERMINATOR
return sNoSpaces;
}