[chbot] C Challange #6

Yani Dubin yani.dubin at gmail.com
Thu Sep 22 22:39:05 BST 2011


I would assume it printed "20 20". But then that seems too obvious and
I must be missing some sort of tricky business around preprocessor
operator precedence causing something funky?

On Fri, Sep 23, 2011 at 9:12 AM, Andre Renaud <andre at bluewatersys.com> wrote:
> Unfortunately, as I don't tend to attend the local meetings I won't be
> able to back this up with a Chocolate Fish. However, who can give the
> correct output for the following C program, with an explanation for why.
>
> #include <stdio.h>
> #include <string.h>
> #define xmod(s) mod(s)
> #define mod(s) #s
> #define foo 20
>
> int main(int argc, char *argv[])
> {
>  char buffer[20], buffer2[20];
>
>  strcpy(buffer, mod(foo));
>  strcpy(buffer2, xmod(foo));
>
>  printf("%s %s\n", buffer, buffer2);
>  return 0;
> }
>
> Regards,
> Andre
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Web site: http://kiwibots.org
> Meetings 3rd Monday each month at Tait Radio Communications, 175 Roydvale Ave, 6.30pm
>
> When replying, please edit your Subject line to reflect new content.
>



More information about the Chchrobotics mailing list