YES, that's right...
I screw-up on my own code.

Really thanks for your answer

Saludos ;)
German 

-----Mensaje original-----
De: Bob Withers [mailto:[EMAIL PROTECTED]
Enviado el: Viernes, 25 de Julio de 2003 02:24 p.m.
Para: Palm Developer Forum
Asunto: RE: convert #define number to const char*


#define CAT_CONTROL 7
#define STR1(x) #x
#define STR(x) STR1(x)

int main(void)
{
     printf("The value is %s\n", STR(CAT_CONTROL));
     return(0);
}

When I run this I get:

The value is 7

Bob



At 12:50 PM 7/25/2003 -0300, you wrote:
>Thanks for your answer Bob, but I have a little problem becouse with
#define
>STR1(x) #x the statement becomes "#7"
>
>I tired:
>
>#define STR1(x)  [EMAIL PROTECTED]
>
>It's works fine but only with single digit values.
>And '7' isn't a const char *   :-(
>
>Can you help me?
>
>Thanks again.
>German
>
>-----Mensaje original-----
>De: Bob Withers [mailto:[EMAIL PROTECTED]
>Enviado el: Viernes, 25 de Julio de 2003 12:02 p.m.
>Para: Palm Developer Forum
>Asunto: Re: convert #define number to const char*
>
>
>You need two levels, i.e.
>
>#define CAT_CONTROL     7
>
>#define STR1(x) #x
>#define STR(x)  STR1(x)
>
>printf("%s", STR(CAT_CONTROL));
>
>Bob
>
>At 11:36 AM 7/25/2003 -0300, you wrote:
> >Hi,
> >
> >I have this constant, #define CAT_CONTROL   7
> >
> >I want to convert CAT_CONTROL to const char * and I don't want to do
this:
> >
> >char cAux[2];
> >itoa(CAT_CONTROL ,cAux,10);
> >
> >I try to use a preprocessor operator:
> >
> >#define STR(x)     #x
> >
> >But that doesn't work, because I obtain "CAT_CONTROL" like result.
> >
> >Any help would be greatly.
> >
> >Best Regards,
> >German
> >
> >--
> >For information on using the Palm Developer Forums, or to unsubscribe,
> >please see http://www.palmos.com/dev/support/forums/
>
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe,
>please see http://www.palmos.com/dev/support/forums/
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe, 
>please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to