Skip to content

Instantly share code, notes, and snippets.

@fjorgemota
Created November 27, 2014 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjorgemota/2ef0a6c9745202bdcddf to your computer and use it in GitHub Desktop.
Save fjorgemota/2ef0a6c9745202bdcddf to your computer and use it in GitHub Desktop.
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