Jump to content
Fórum Script Brasil
  • 0

Programa abortando depois de passar pela funcao


Question

Eu fiz uma função em C que substitui os acentos que determinada palavra passada pelo parâmetro tem. O código funciona e substitui os caracteres com acento, mas o programa em si é abortado quando executa. Quem puder me ajudar com melhorias ou sugestões eu agradeço. Segue o código:

void retiraAcentos(char str[]) {
    char *pch;
    pch = strstr(str,"Á");
    if (pch != NULL)
        strncpy(pch,"A",6);
    pch = strstr(str,"À");
    if (pch != NULL)
        strncpy(pch,"A",6);
    pch = strstr(str,"Â");
    if (pch != NULL)
        strncpy(pch,"A",6);
    pch = strstr(str,"Ã");
    if (pch != NULL)
        strncpy(pch,"A",6);
    pch = strstr(str,"Ä");
    if (pch != NULL)
        strncpy(pch,"A",6);
    pch = strstr(str,"É");
    if (pch != NULL)
        strncpy(pch,"E",6);
    pch = strstr(str,"È");
    if (pch != NULL)
        strncpy(pch,"E",6);
    pch = strstr(str,"Ê");
    if (pch != NULL)
        strncpy(pch,"E",6);
    pch = strstr(str,"Ë");
    if (pch != NULL)
        strncpy(pch,"E",6);
    pch = strstr(str,"Í");
    if (pch != NULL)
        strncpy(pch,"I",6);
    pch = strstr(str,"Ì");
    if (pch != NULL)
        strncpy(pch,"I",6);
    pch = strstr(str,"Î");
    if (pch != NULL)
        strncpy(pch,"I",6);
    pch = strstr(str,"Ï");
    if (pch != NULL)
        strncpy(pch,"I",6);
    pch = strstr(str,"Ó");
    if (pch != NULL)
        strncpy(pch,"O",6);
    pch = strstr(str,"Ò");
    if (pch != NULL)
        strncpy(pch,"O",6);
    pch = strstr(str,"Ô");
    if (pch != NULL)
        strncpy(pch,"O",6);
    pch = strstr(str,"Õ");
    if (pch != NULL)
        strncpy(pch,"O",6);
    pch = strstr(str,"Ö");
    if (pch != NULL)
        strncpy(pch,"O",6);
    pch = strstr(str,"Ú");
    if (pch != NULL)
        strncpy(pch,"U",6);
    pch = strstr(str,"Ù");
    if (pch != NULL)
        strncpy(pch,"U",6);
    pch = strstr(str,"Û");
    if (pch != NULL)
        strncpy(pch,"U",6);
    pch = strstr(str,"Ü");
    if (pch != NULL)
        strncpy(pch,"U",6);
    pch = strstr(str,"Ç");
    if (pch != NULL)
        strncpy(pch,"C",6);
}

 

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing


  • Forum Statistics

    • Total Topics
      149279
    • Total Posts
      645643
×
×
  • Create New...