The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+3 votes
172 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");
}
asked in Programming by Active (2.6k points) | 172 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.

1 Answer

+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"
answered by Boss (18.3k points)

Related questions

+1 vote
2 answers
1
+2 votes
2 answers
3


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

44,316 questions
49,814 answers
164,575 comments
65,868 users