Convert character

Asked

Viewed 46 times

-3

char converte_minusculo (char *s) // porque esta errada
{
    int posicao = 0;
    while (s[posicao] != '\0')
    {
      if(s[posicao] >= 65 && s[posicao] <= 90)
        return s[posicao] + 32;
      else
          return s[posicao];
      posicao++;
    }
}

You’re not returning any value to me; I’m not sure that’s the kind of job either. I need you to return the converted values to the main().

  • If you’re not returning any value, you’re probably not entering while.

  • 1

    What was this function supposed to do? Convert a whole string into minuscule ?

2 answers

0

char converte_minusculo (char *s[30])
{
    int posicao = 0;

    while (s[posicao] != '\0')
    {
        if(s[posicao] >= 65 && s[posicao] <= 90)
        {
            s[posicao] + 32;
        }

        posicao++;
    }
    return s;
}
  • While this may resolve the problem, include a comment explaining the solution or what was wrong is welcome.

0

void converte_minusculo(char s[]) {
    int posicao = 0;
    while (s[posicao] != '\0') {
        if (s[posicao] >= 'A' && s[posicao] <= 'Z') {
            s[posicao] = s[posicao] - 'A' + 'a';
        }
        posicao++;
    }
}
  • While the answer may resolve the problem, any comment explaining the solution would be welcome.

Browser other questions tagged

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