The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+3 votes
186 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) | 186 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"
answered by Boss (18.2k points)
0 votes
answered by Loyal (9.5k points)

Related questions

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
49,430 questions
53,617 answers
185,969 comments
70,892 users