473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

whats happening here

#include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)

int main()
{
printf("%s\n",h(f(1,2)));
printf("%s\n",g(f(1,2)));
return 0;
}
Mar 25 '08 #1
2 1520
On Mar 25, 12:23 pm, "parag_p...@hotmail.com" <parag_p...@hotmail.com>
wrote:
#include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)

int main()
{
printf("%s\n",h(f(1,2)));
printf("%s\n",g(f(1,2)));
return 0;
}
f(1,2) ==12 because ## is a concatenating operator, which treats its
inputs a strings. So 1 and 2 are concatenated to form 12

h(a) is simply #a where # is stringisizing operator. So h(12)
becomes the string "12"

Since g(a) is simply #a, the input argument f(1,2) is thrown out as if
it were a string.
Mar 25 '08 #2
bdsatish wrote:
On Mar 25, 12:23 pm, "parag_p...@hotmail.com" <parag_p...@hotmail.com>
wrote:
>#include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)

int main()
{
printf("%s\n",h(f(1,2)));
printf("%s\n",g(f(1,2)));
return 0;
}

f(1,2) ==12 because ## is a concatenating operator,
Yes.
which treats its
inputs a strings.
No.

See WANG CONG's response.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Mar 25 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kevin Steffer | last post by:
Hi group I have a webform which I want to make an ftp connection for a filetransfer from. The thing is when I use the WebRequest class it says "The URI prefix is not recognized" and my URI is...
4
by: Affan Syed | last post by:
Can any body give me an idea what the heck is happening over here :) #define UARTOutput(__x,__y,__args...) do { \ static char __s PROGMEM = __y; \ if (debug_out) \ printf_P(__s, ## __args); ...
7
by: Alfonso Morra | last post by:
I have a class that contains a nested class. The outer class is called outer, and the nested class is called inner. When I try to compile the following code, I get a number of errors. It is not...
5
by: kernel.lover | last post by:
hello, I want to know if a fuction say malloc is declared as void *malloc() then whats the significance of void here. Does void * is used when function has the flexibility to return any type of...
3
by: Lucas Tam | last post by:
Does anyone have a good articles that describes the pros and cons of Web Services vs. Remoting Hosted in IIS? Is there a reason to use either or? With Remoting Hosting in IIS, is it possible...
4
by: sophie | last post by:
Whats going on here: Read in a number as a string: scanf("%s", &number); number = 12345, for arguements sake Print it like this its fine:
2
by: Abubakar | last post by:
Hi all, I'm writing an app in vc++ 2k5 (all native/unmanaged). This application does a lot of multithreading and socket programming. Its been months since I'm developing this application, at...
9
by: =?Utf-8?B?cm9nZXJfMjc=?= | last post by:
hey, I have some preliminary code in my program (check for a certain file, define a like 15 variables) and I put it in the form load. I recently got the idea to make a method for it, and do it in...
19
by: Steve | last post by:
I have to create 2 strings and then parse one string out to save the data into the database. My first string looks like this: ...
26
by: Muzammil | last post by:
whats the beauty of "malloc" over "new" why its helpful for programmer.for its own memory area.??
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.