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

  • SEARCH
  • Home
  • 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 9093377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:05:07+00:00 2026-06-16T23:05:07+00:00

Based on an answer of the following question: How do I transform an IF

  • 0

Based on an answer of the following question: How do I transform an IF statement with 2 variables onto a switch function using C?

I want to develop SWITCH and CASE macros to use it (like switch and case) for strings.

Some thing like that:

char buf[256];

SWITCH (buf) {
    CASE ("abcdef"):
        printf ("A1!\n");
        BREAK;
    CASE ("ghijkl"):
        printf ("B1!\n");
        BREAK;
    DEFAULT:
        printf ("D1!\n");
        BREAK;
}

what could be SWITCH and CASE and BREAK and DEFAULT here ?

  • 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-16T23:05:08+00:00Added an answer on June 16, 2026 at 11:05 pm
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #define SWITCH(S) char *_S = S; if (0)
    #define CASE(S) } else if (strcmp(_S, S) == 0) {switch(1) { case 1
    #define BREAK }
    #define DEFAULT } else {switch(1) { case 1
    
    int main()
    {
        char buf[256];
    
        printf("\nString - Enter your string: ");
        scanf ("%s", buf);
    
        SWITCH (buf) {
            CASE ("abcdef"):
                printf ("B1!\n");
                BREAK;
            CASE ("ghijkl"):
                printf ("C1!\n");
                BREAK;
            DEFAULT:
                printf ("D1!\n");
                BREAK;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the following question, I am looking for an answer that is based on
This question is based on this answer . What does the following sentence mean?
I found and am using the following stackoverflow question and answer here . I'm
based on the following question/answer CodeIgniter session class not working in Chrome I had
Based on the answer for this question What's the difference between CompositionBatch and catalogs?
Based the accepted answer to this question I've setup a NetBeans/tomcat environment. In testing
This is a further question based on this answer: How can I implement a
This question is based on my previous question which I got a working answer
Following up on this GWT-RPC question (and answer #1) re. field size checking ,
I have a query based on the answer to this question: Handling ties when

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.