A little knowledge of some of the macros in C language

Source: Internet
Author: User

A little knowledge of some of the macros in C language 1.# #和 #

C language, # #表示把两个宏参数贴合在一起, that is,
#define Call (x, y) x# #y, perform a call (x, y) result of XY, for example,
int x=2,y=5;
int xy=90;
printf ("%d\n", call (x, y));//result is 90

# #被称为连接符, used to concatenate two macro parameters into a single macro parameter.
The function of a single # is to string the macro arguments that follow it, simply by substituting a double quotation mark around the macro variable it refers to as a string.

The above quoted from Baidu know.

But it's like # #和 # can only be used in macro definitions

#include <iostream>#defineFun (b) a# #b#defineF (x) #xintMain () {intx =1; inty =2; intXY =5; Std::cout<<fun (x, y) <<"\ n"<<f (XY) <<":"<<xy<<Std::endl; Std::cin>>x; return 0;}

The result of the above code operation is:

5 XY: 5

Very interesting operator.

A little knowledge of some of the macros in C language

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.