字符串输出

C Primer Plus 第11章 字符串和字符串函数 11.3 字符串输出

假如想象 提交于 2019-11-29 03:45:34
11.3.1 puts( )函数 puts( )函数的使用很简单, 只需要给出字符串参数的地址。 程序清单11.8列出了输出字符串的多种方式。 程序清单11.8 put_out.c程序 /*put_out.c 使用puts( )函数*/ #include<stdio.h> #define DEF "I am a #define string." int main(void) { char str1[80]="An array was initialized to me."; const char * str2 ="A pointer was initialized to me."; puts("I'm an argument to puts( ). "); puts(DEF); puts(str1); puts(str2); puts(&str1[5]); puts(str2+4); return 0; } 输出如下: I'm an argument to puts( ). I am a #define string. An array was initialized to me. A pointer was initialized to me. ray was initialized to me. inter was initialized to me. 注意