0
My goal in this function is to have a void function that changes a string so as to cut all spaces before and after the sentence, for example: transform the string " I went shopping " in the string "I went shopping". My current result is to receive exactly the same string I started with.
#include <stdio.h>
#include <string.h>
void trimmer(char frase[]){
int i=0,a=0,p=0,b=0,posb, len;
len=strlen(frase);
while(b=0) {
if(frase[len-i] = ' '){
i=i+1;
}else
{
posb= len-i;
printf("%i", posb);
b=1;
}
}
while(p <= posb, p++){
if(frase[i] != ' ') {
a=1;
}
if(a=1){
frase[p]= frase[i];
i++;
p++;
}
}
}
int main(){
char frase[]=" Eu nao fui a escola! ";
printf("%s %lu\n",frase,strlen(frase));
trimmer(frase);
printf("%s %lu\n",frase,strlen(frase));
return 0;
}
What you have already achieved and what you have achieved so far?
– Woss
I forgot, I’ve already updated.
– Bernardo