string,char,char*,char a[] 占字节数, 以及sizeof,strlen(),str.length()的用法
来源:互联网 发布:java ssh项目 编辑:程序博客网 时间:2024/04/25 04:35
-
-
-
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
-
- int main(int argc, char* argv[])
- {
-
- cout<<"char,char*,string 在C++中的占几个字节: -------------------------"<<endl;
- cout<<"sizeof(char) = "<<sizeof(char)<<endl;
- cout<<"sizeof(char*) = "<<sizeof(char*)<<endl;
- cout<<"sizeof(string) = "<<sizeof(string)<<endl;
- cout<<"----------------------------------------------------------------"<<endl;
- cout<<endl;cout<<endl;
-
- string str;
- str = "12345678912";
- cout<<"the size of str = "<<sizeof(str)<<endl;
- cout<<"the length of str = "<<str.length()<<endl;
- cout<<"----------------------------------------------------------------"<<endl;
- cout<<endl;cout<<endl;
-
-
- char* ch = "12345678912";
- cout<<"the size of ch = "<<sizeof(ch)<<endl;
- cout<<"the length of ch = "<<strlen(ch)<<endl;
- cout<<"----------------------------------------------------------------"<<endl;
- cout<<endl;cout<<endl;
-
-
-
- char a[]="12345678912";
- cout<<"the size of a = "<<sizeof(a)<<endl;
- cout<<"the length of a = "<<strlen(a)<<endl;
- cout<<"----------------------------------------------------------------"<<endl;
- cout<<endl;cout<<endl;
-
-
- char chr[12]="12345678912";
- cout<<"the size of chr = "<<sizeof(chr)<<endl;
- cout<<"the length of chr = "<<strlen(chr)<<endl;
- cout<<"----------------------------------------------------------------"<<endl;
- cout<<endl;cout<<endl;
-
-
- char chrr[100]="12345678912";
- cout<<"the size of chrr = "<<sizeof(chrr)<<endl;
- cout<<"the length of chrr = "<<strlen(chrr)<<endl;
- cout<<"----------------------------------------------------------------"<<endl;
- cout<<endl;cout<<endl;
-
-
- char strr[8]={'a'};
- cout<<"the size of strr = "<<sizeof(strr)<<endl;
- cout<<"the length of strr = "<<strlen(strr)<<endl;
- cout<<"----------------------------------------------------------------"<<endl;
- cout<<endl;cout<<endl;
-
- return 0;
- }
- string,char,char*,char a[] 占字节数, 以及sizeof,strlen(),str.length()的用法
- string,char,char*,char a[] 占字节数, 以及sizeof,strlen(),str.length()的用法
- string,char,char*,char a[], sizeof,strlen(),str.length()...
- sizeof strlen string.lenth()之例子 string,char,char*,char a[], sizeof,strlen(),str.length()...
- strlen(char *)和str.length()以及str.size()的区别
- char字符串数组与string之间的转换,以及sizeof,strlen,length的区别
- sizeof strlen() char * char []
- char char* char[] sizeof strlen
- 由strcat函数引发的对char *a和char a[]以及sizeof和strlen
- char *s和char s[]的区别与联系以及strlen()和sizeof()的用法
- Java String,int,Integer,char 类型转换 ,sizeof,strlen,length的区别 .
- char*,char a[ ],char*a[]学习、sizeof、位与字节
- int strlen(const char *str)
- sizeof(char*)几个字节?
- char[]:strlen和sizeof的区别
- char*中sizeof和strlen的区别
- strlen(char*)与sizeof()的区别
- char *str和char str[]的区别
- 红帽企业Linux产品文档
- Android 系统Dimension和间距参数详解
- RAC安装时需要执行4个脚本及意义
- Lucene.Net 2.3.1开发介绍 —— 简介
- 精心挑选的12款优秀 jQuery Ajax 分页插件和教程
- string,char,char*,char a[] 占字节数, 以及sizeof,strlen(),str.length()的用法
- java socket编程
- 海里的鱼虾什么的,再也不要带回家了
- Web Service之AXIS定制发布
- 局域网内共享打印机win7和xp都可
- rac安装clusterware遇到:Failed to upgrade Oracle Cluster Registry configuration
- android广播事件和权限
- ios6.x 插件介绍及常用源
- python学习教程(七)sqlalchemy框架的配置