Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

461
Visualizações
Using switch function to check for character ' in C

I have to make a program that allows the user to input characters then prints its decimal character code. One of the characters is ' but when I go to check for this character it says it is missing the terminating ' character.

case ''':
            printf("039");
            break;

How do I check for ' as a charcter?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You can use an escape sequence.

case '\'':
            printf("039");
            break;
over 4 years ago · Santiago Trujillo Relatório

0

You should use a backslash(\) before using ' . Because ' is a special character. So, you should use as follows,

case '\'':
            printf("039");
            break;
over 4 years ago · Santiago Trujillo Relatório

0

You should use the \ character before the '. This is because in c the character ' is used as a opener or closer for a character value. This means you need to tell the compiler to treat it as a normal character by adding \ before it. The same thing goes for " and \ (if you want to use a backslash in a string instead of the purposes listed above.)

Using this method your case statement should look like this: case '\'':

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda