Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

456
Views
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 answers
Answer question

0

You can use an escape sequence.

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

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!