The Gateway to Computer Science Excellence
+3 votes
233 views
#include<stdio.h>
#define decode(s,t,a,m,p,e,d)m##s##u##t
#define begin decode(a,n,i,m,a,t,e)
int begin()
{
    printf("hello");
}
in Programming by | 233 views
0
If s,t,a,m,p,e,d is decoded to m s u t then how a,n,i,m,a,t,e is decoded to m a i n.
I think there is some typo error.

2 Answers

+1 vote
There is no error. ## does string concatenation in a macro. So, macro will expand as follows:

begin -> decode(a,n,i,m,a,t,e) -> m##a##i##n -> main

So, the function name becomes main and program prints "hello"
by
0 votes
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,345 questions
60,513 answers
201,930 comments
95,354 users