char str[] = {"hello world"}以及字符串终止符'\0'辨析
来源:互联网 发布:土石方调配软件 编辑:程序博客网 时间:2024/06/05 14:37
自己试试下就能弄得非常明白了(vc6.0下测试)
#include <stdio.h>#include <string.h>int main(){char str1[] = {"hello world"};//数组有12个元素,包括'\0'char str2[12] = {"hello world"};//数组有12个元素,包括'\0'char str3[11] = {'h','e','l','l','o',' ','w','o','r','l','d'};////数组有11个元素,不包括'\0'printf("%s\n%s\n%d\n",str1,str2,strlen(str2));//可以正常打印printf("%s\n",str3);//看情况,若数组后面的内存区域中有终止符,则能正常打印,但会出现乱码等意想不到的情况printf("%d\n",strlen(str3));//看情况而定return 0;}
- char str[] = {"hello world"}以及字符串终止符'\0'辨析
- char str[] = "hello world";和char *str = "hello world";区别
- char str[] = "hello world";和char *str = "hello world";区别
- char * str="hello"
- char str[]="hello"; sizeof(str)是多少?
- char *ptr = hello world
- char str[]="hello" 与 char *str="hello" 不是等价的
- C中char str[] = "hello word";与char *str = "hello word";
- 字符串赋值问题 char *str="abc4Efg";
- char p[] = "hello world" 与 char *p = "Hello world" 的差异
- 关于 char p[]="hello world";与char *p="hello world";
- char *myString = "Hello-World!";和 char myString[] = "Hello-World!";
- char p[] = "hello world" 与 char *p = "Hello world"
- char p[] = "hello world" 与 char *p = "Hello world" 的区别
- 关于char* arr="hello world"与char arr[]="hello world"
- 字符串反转引发的char str[]="abc"和char *str="abc"思考
- char *p="hello world"有什么问题
- 关于笔试题 "在函数里char p[] = "hello world" 与 char *p = "Hello world""
- UVa 10765 - Doves and bombs(割点,双连通分量)
- IOS-按钮风格style(plain、bordered、done)辨析
- ios 消息传递 内部调用
- SpringMVC 简单实例
- Python3.3中的urllib
- char str[] = {"hello world"}以及字符串终止符'\0'辨析
- C++ 用libcurl库进行http 网络通讯编程
- IOS UITableView中行的操作
- JavaScript:继承和原型链(译)
- 推荐免费的远程桌面工具Teamviewer!
- partial
- 插入光栅图纸(Raster Image)
- 界面设计模式(第2版)(全彩)
- Content is not allowed in trailing section.