Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Removedor simples de acento em C
#include <stdio.h>
#include <stdlib.h>
char* removeAcento(char *string){
int i=0;
int resultado = 0;
while(string[i] != '\0'){
if(!((string[i] < 97 || string[i] > 122) && (string[i] < 65 || string[i] > 90))) {
resultado++;
}
i++;
}
char *res = (char*) malloc(sizeof(char)*resultado);
int n = 0;
i = 0;
while(string[i] != '\0'){
if(!((string[i] < 97 || string[i] > 122) && (string[i] < 65 || string[i] > 90))) {
res[n] = string[i];
n++;
}
i++;
}
return res;
}
int main(int argc, char **argv){
int i;
for(i=1; i < argc; i++){
printf("- %s\n",removeAcento(argv[i]));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.