文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>printf("%s", str) vs. printf(str)

printf("%s", str) vs. printf(str)

时间:2008-05-17  来源:剑心通明

printf("%s", str) vs. printf(str)
Created: Fang lungang 03-08-2007Modified: Fang lungang 03-08-2007 21:35>
从 The C Programming Language 2nd 看到的 printf 一个需要注意的细节:即使被打印的本身就只有一个字符串,最好也别直接打印,而要用格式符 %s。其它格式输出的函数应该也类似。
#include
int main()
{
        char* str= "a string with % may not workn";
        printf ("%s", str);
        printf (str);
        return 0;
}
[/home/lungangfang/tmp]gcc --version
gcc (GCC) 3.2.3 20030502 (Red Hat
[url=javascript:;]Linux[/url]
3.2.3-20)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[/home/lungangfang/tmp]./a.out
a string with % may not work
a string with Successay not work
[/home/lungangfang/tmp]


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载