格式说明符对于字符串的妙用

代码如下

#include<stdio.h>
#define CNBLOG "I love CnBlog"

int main(void)
{
printf("/%2s/\n",CNBLOG);
printf("/%24s/\n",CNBLOG);
printf("/%24.5s/\n",CNBLOG); //只显示五个字符 剩余19个是空格
printf("/%-24.5s/\n",CNBLOG);
}

 

显示如下

你可能感兴趣的:(格式说明符对于字符串的妙用)