Hi!!!Here is a function,which deletes the spaces of a string...
char *removespaces(char *s1)
{
Could you explain me why I have to initialize the pointer *s2 with the first element of the array s1...???If I don't initialize the pointer,or initialize it with something else,I get a segmentation fault... :frown:Code:char *s2=s1;
int i,j=0;
for (i = 0; i<strlen(s1); i++){
if (s1[i]!=' ') {
s2[j]=s1[i];
}else {
j--;
}
j++;
}
s2[j]=0;
return s2;
}