Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9260399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:52:55+00:00 2026-06-18T12:52:55+00:00

Hey take a look at the code: #define SUFFIX(n) (switch(n) \ { \ case

  • 0

Hey take a look at the code:

#define SUFFIX(n)  (switch(n)                                               \
                   {                                                        \
                        case 1: printf("st\n");                             \
                        break;                                              \
                                                                            \
                        case 2: printf("nd\n");                             \
                        break;                                              \
                                                                            \
                        case 3: printf("rd\n");                             \
                        break;                                              \
                   }                                                        \
                   )                                                        

calling the above macro in main:

int main()
{
    printf("%s", suffix(1));
}

But when I call this I get a error message:

expected expression before switch

But what expression am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:52:57+00:00Added an answer on June 18, 2026 at 12:52 pm

    What you’re trying to do won’t work. switch is a statement but printf requires an expression.

    Option 1:

    Remove the brackets () from your #define and simply say SUFFIX(1) without the printf.

    #define SUFFIX(n)  switch(n)                                               \
                       { case 1: printf("st\n"); break;                        \
                         case 2: printf("nd\n"); break;                        \
                         case 3: printf("rd\n"); break;                        \
                       }
    int main()
    {
        SUFFIX(1);
    }
    

    Option 2:

    #define SUFFIX(n) ( n == 1 ? "st" : (n == 2 ? "nd" : (n == 3 ? "rd" : "")) )
    int main()
    {
      printf("%s", SUFFIX(1));
    }
    

    Option 3 and 4:

    Make one of the above a function. The first returns void, the second returns char *.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, take a look at this, maybe you can help me. This code
Hey guys, please take a look at my code and see what's wrong here.
Hey everyone, take a look at the code below and appreciate how messy the
Hey guys take a look at this program. /* The craps game, KN king
For this code i need to take a string like <b>hey</b> more text<b>hey2</b> other
Hey if you take a look at this link below http://www.thesun.co.uk/sol/homepage/showbiz/4491771/Cheryls-been-married-she-may-hurt-my-son-Tre.html You will notice
Hey I'm trying to take a String input from the user (in this case
Hey I would like to know if there is a way to only take
hey I have a string as such: 357902||190||RUE RACHELLE||ST|||LES CÈDRES|J7T1J9|QC I wish to take
Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.