I have to create a function to make the exchange of some character.
The exercise is this:
1. Build a function that receives a message, its size, and a
and remove all occurrences of this character in the message
putting * in its place. The function should return the total characters
retired.
And I did the following:
#include <stdio.h>
#include <string.h>
#include <locale.h>
void filtro(char msg[500] ,int tamanho, char c){
setlocale(LC_ALL,"portuguese");
char mensagem[500];
strcpy(mensagem,msg);
int i,r=0;
for (i=0; i<tamanho; i++){
if(mensagem[i]==c){
r++;
mensagem[i] = "*";
}
}
printf("\nMensagem modificada: \n %s", mensagem);
printf("\nCaracteres retirados: %d", r);
}
void main(){
setlocale(LC_ALL,"portuguese");
char msg[500], c;
printf("Escreva uma mensagem de até 500 caracteres\n");
gets(msg);
printf("Informe o caracter a ser removido: ");
scanf("%c", &c);
filtro(msg, strlen(msg), c);
}
But I get the following error message: [Warning] assignment makes integer from pointer without a cast
He even detects the letters and makes an exchange. But instead of putting the '*' it puts the following character: