|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
如题 程序如下- #include <stdio.h>
- int main(void){
- char c[6] = {'H','e','l','l','o','\n'};
- printf("%s",c);
-
- char d[] = {'a','b','c','\0','h'};
- printf("%s",d);
-
- char b[] = {"\n这是字符串!"};
- printf("%s\n",b);
-
- char a[]="这也是字符串";
- printf("%s\n",a);
-
-
-
-
- return 0;
- }
复制代码
如果一加注释(//)就会报错 报错信息如下
D:\学习\C语言 浙江大学\字符串输出.c In function 'main':
9 1 D:\学习\C语言 浙江大学\字符串输出.c [Error] expected expression before '/' token
12 16 D:\学习\C语言 浙江大学\字符串输出.c [Error] 'b' undeclared (first use in this function)
12 16 D:\学习\C语言 浙江大学\字符串输出.c [Note] each undeclared identifier is reported only once for each function it appears in
你复制我的代码试试看
- #include <stdio.h>
- int main(void){
- char c[6] = {'H','e','l','l','o','\n'}; //定义字符数组并赋值
- printf("%s",c); //输出
-
- char d[] = {'a','b','c','\0','h'}; // 定义字符数组并赋值
- printf("%s",d); //输出
-
- char b[] = {"\n这是字符串!"}; //定义字符数组并赋值
- printf("%s\n",b); //输出
-
- char a[]="这也是字符串";
- printf("%s\n",a); // 输出字符串
-
-
-
- return 0;
- }
复制代码
|
|