| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 593 人关注过本帖, 1 人收藏
标题:#define FORMAT "%s ! c is cool \n!"然后 printf(FORMAT,FORMAT);运行结果 ...
只看楼主 加入收藏
ye姗
Rank: 1
等 级:新手上路
帖 子:3
专家分:7
注 册:2014-10-14
结帖率:100%
收藏(1)
已结贴  问题点数:20 回复次数:1 
#define FORMAT "%s ! c is cool \n!"然后 printf(FORMAT,FORMAT);运行结果为什么是%
下面的程序的运行结果为什么是这样呢?求大神知道!
#include<stdio.h>
#define FORMAT "%s ! c is cool \n!"
int main(void)
{
  printf(FORMAT,FORMAT);
  return 0;
}
运行结果:
%s !c is cool!
! c is cool!
搜索更多相关主题的帖子: include return cool 
2014-10-14 11:37
yeuf
Rank: 2
等 级:论坛游民
帖 子:7
专家分:20
注 册:2014-10-14
收藏
得分:20 
printf (FORMAT,FORMAT);等于
printf ( "%s! C is cool!\n", "%s! C is cool!\n");
然后将第一个%s用"%s! C is cool!\n"代替,也就是打印
%s! C is cool!\n! C is cool!\n,即:
%s! C is cool!
! c is cool!
2014-10-14 12:56
快速回复:#define FORMAT "%s ! c is cool \n!"然后 printf(FORMAT,FORMAT);运 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023883 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved