0
I would like to know what the problem is with my string inside the function, it goes through the string and when I find an uppercase letter turn it into a lowercase letter (I have tried using the tolower
and isupper
, but it did not work) and when you find a point, exclamation, question, two points and point and comma should replace them by a space and return it to the main, but it is not being changed, follows below the code of the function:
char* diminuieretira(char** p, int r)//Declaração de função que converte as letras maiusculas em minusculas e adiciona no lugar das pontuações o espaço
{
int i = 0;
for(i = 0; i < r; i++)
{
if((*p[i]) >= 65 && (*p[i]) <= 90) //Se o caracter for maisculo
(*p[i]) + 32; //Converto-o para minusculo
else if((*p[i]) == 46 || (*p[i]) == 44 || (*p[i]) == 59 || (*p[i]) == 58 || (*p[i]) == 33 || (*p[i]) == 63); //Se o caracter for um ponto de exclamação, ponto, interrogação, dois pontos ou ponto e virgula
(*p[i]) = 32; //Essa pontuação é substituida por um espaço
}
printf("%s", (*p)); //Imprimo na tela a strign modificada
return (*p); //Retorno para a main a string modificada
}
And to replace the values with space, it would be wrong to make *p[i] = 32???
– Gabriel Vinicius
This one’s all right, but I’d use it
*p[i] = ' '
to make clear what you are doing (idem to(*p[i]) == 46 || (*p[i]) == 44 || …
)– user25930
It keeps going wrong, the mask is used properly by me??
– Gabriel Vinicius
If you don’t want to make it explicit like @ctgPi spoke, you can leave the commented line explaining what each value is. The custom of writing comments is very useful for yourself and for future people who will see your code, sometimes you can go a while without seeing the code and when you need it will not remember what each value means.
– Maicon Carraro
If I withdraw "*", the compiler accuses incompatibility of arguments
– Gabriel Vinicius
I tried to use the for but the problem too
– Gabriel Vinicius