String characters disappear

Asked

Viewed 42 times

1

Good morning I’m doing the Problem 1234 from Uri, only that I made the code and saw that some characters disappear for some reason I don’t know, when I type a phrase that the site shows, some characters disappear, could help me

Follows the code

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char** argv)
{
  char nome[100], aux[100];
  int c = 0, cont = 0, tam;
  while(gets(nome) != NULL)
  {
     tam = strlen(nome);
     for(int i = 0; i < tam; i++)
     {
        if(!isspace(nome[i]))
        {
            cont++;
            if(cont % 2 == 0)
            {
                if(isupper(nome[cont]))
                {
                    aux[c++] = nome[cont];
                }
                else
                {
                    aux[c++] = toupper(nome[cont]);
                }
            }
            else
            {
                if(islower(nome[cont]))
                {
                    aux[c++] = nome[cont];
                }
                else
                {
                    aux[c++] = toupper(nome[cont]);
                }
            }
        }
    }
    aux[c] = '\0';
    printf("%s\n", aux);
    memset(aux, 0, sizeof(aux));
    c = 0, cont = 0;
  }
   return 0;
}
  • Write an input example you used in which you noticed errors. Posting an external link with Description problem may be bad in the future because not everyone has access or the link may go down.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.