C Programming - C Preprocessor - Discussion
Discussion Forum : C Preprocessor - Find Output of Program (Q.No. 4)
4.
What will be the output of the program?
#include<stdio.h>
#define JOIN(s1, s2) printf("%s=%s %s=%s \n", #s1, s1, #s2, s2);
int main()
{
char *str1="India";
char *str2="BIX";
JOIN(str1, str2);
return 0;
}
Discussion:
35 comments Page 3 of 4.
Durga dutt said:
1 decade ago
isn't an error if we use ";" at the end of macro expansion?
Rohit said:
1 decade ago
To concatenate we use dobule hash but single can also do this
Prasad Shinde said:
1 decade ago
# means a concatenation operator in C.
It concats 2 strings.
It concats 2 strings.
Vishal said:
1 decade ago
I am not getting it. Any one can explain it properly please.
Nandini said:
1 decade ago
#is name of the variable. So, if #str1 gives str1 content.
Nachiyappan said:
2 decades ago
Is it possible to print value through pre-processor ?
Vasuuma said:
2 decades ago
# mean to variable name. so #s1 gives output as str1
Neeraja said:
1 decade ago
Please give clarity what #s1 #s2 means?
Omkar said:
1 decade ago
Can anyone explain @Sunil's program ?
Vimala said:
1 decade ago
# defines that name of the variable.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers