Macro/preprocessor handling

Discussion in 'C' started by arangasoft, Nov 27, 2004.

  1. arangasoft

    arangasoft New Member

    Joined:
    Sep 13, 2004
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Trichy, Tamizh nadu
    Hai everybody

    i have one question. ie how to define the macro/preprocessor which replace to code whatever string input is given.

    for example
    if the program like this
    Code:
    #include<stdio.h>
    #define MACRO(_)  (____________________)
    main()
    {
    char a[3][]={
                          "int a,b;",
                          "a=10;b=20;",
                          "printf("a=%d,b=%d",a,b);"
                      };
    MACRO(s[0])
    MACRO(s[1])
    MACRO(s[2])
    }
    
    the output will be.....
    a=10,b=20

    If anyone know the answer please tell me soon.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I dont think anything like that is possible but would like to be proved wrong by some other C/C++ guys.
     
  3. elec.shabnam

    elec.shabnam New Member

    Joined:
    Feb 13, 2008
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    sir macros receive values in compile time,so in run time we cannot change,is it right.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice