Hello!
I written a procedure that is supposed to only include one blank
where there are more thatn one space.
Example "A' ' ' 'D' ' 'E' 'FG' 'R' 'G' ' 'T"
should be "A D E FG R G T"
(' ' stands for space )
It works in turbo c but not in linux
I get segmentation fault all the time.
What have i done wrong
Here is the code
Code:char *noDoublespace(char str[]){ int flag_isspace=0; int i=0,y=0; while(str[i]){ if(str[i]==' ' && !flag_isspace){ flag_isspace=1; str[y]=str[i]; y++; } else if(str[i]!=' '){ flag_isspace=0; str[y]=str[i]; y++; } i++; } str[y]='\0'; }