1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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,276
    Likes Received:
    364
    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