Created
November 27, 2014 02:41
-
-
Save fjorgemota/2ef0a6c9745202bdcddf to your computer and use it in GitHub Desktop.
Removedor simples de acento em C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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