[ORIGINAL CREATION] undown tact and skill in C programming

###

*ptr++          55555~~ i always forget ++ has a high priority than *.

###
The number-sign or "stringizing" operator (#) converts macro parameters (after expansion) to string constants
#define paster( n ) printf( "token" #n " = %d", token##n )

int token9 = 9;

paster( 9 );

//那么在编译时,上面的这句话被扩展为:
printf( "token" "9" " = %d", token9 );

###. :

char s[0xff];
scanf( "%[0-9]", s);   /* %[ is scarcely known. */
 
int n;
scanf("%d", &n);     /*   %d cannot interpret input number beginning with 0x(HEXADECIMAL) or 0(OCTAL) */
scanf("%i", &n);      /* %i can read integer in base 16 if it begins with 0x or 0X, in base 8 if it begins with 0,  and in base 10 otherwise. */

### :
introduced by C99
#define My_Macro(...)
For replacement, the variable arguments(including the separating commas) r collected into one single extra argument that can be referenced as __VA_ARGS__ within the macro's replacement list.
e.g.  #define my_printf(fmt, ...) printf(fmt, __VA_ARGS__)
this is a wrapper of standard C library function printf().

###. :
introduced by C99
void user_fun ()
{
    printf("%s", __func__ );              //  this function will print the function name: usr_fun
}

### :
introduced by C99
#include <stdbool.h>
_Bool b = true;  // or false

### :
introduced by C99: flexible array member. Structs: the last member may have an incomplete array type.

struct flexible_struct
{
    int type;
    int ary[];
}*fap1, *fap2;                           // NOTICE: sizeof(flexible_struct) = sizeof(int) = 4

fap1 = malloc(sizeof(struct flexible_struct) + 2*sizeof(int));
fap2 = malloc(sizeof(struct flexible_struct) + 3*sizeof(int));

...
*fap1 = *fap2;             // Only copy the member type, but not the ary with variable length.

###
g, G   The double argument is converted in style f or e (or F or E for G conversions).  ---printf()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值