当前位置: 首页 > news >正文

网站构建的友情链接怎么做企业官网首页设计

网站构建的友情链接怎么做,企业官网首页设计,2022最旺公司名称,遵义网站建设遵义文章目录 22. 字符串22.1. 字符数组 vs 字符指针 vs 常量字符指针 vs string22.2. strcpy vs sprintf vs memcpy22.3. strlen vs length vs size vs sizeof22.4. 字符串之间的转换22.5 其他数据类型与字符串之间的转换22.6 字符串分割 22. 字符串 22.1. 字符数组 vs 字符指针 …

文章目录

  • 22. 字符串
    • 22.1. 字符数组 vs 字符指针 vs 常量字符指针 vs string
    • 22.2. strcpy vs sprintf vs memcpy
    • 22.3. strlen vs length vs size vs sizeof
    • 22.4. 字符串之间的转换
    • 22.5 其他数据类型与字符串之间的转换
    • 22.6 字符串分割

22. 字符串

22.1. 字符数组 vs 字符指针 vs 常量字符指针 vs string

  • 字符数组 char[]
    • 它将常量字符拷贝到自己的内存空间,再进行读写操作。
    • 它的大小在编译时确定,且固定大小。
  • 字符指针 char*
    • 它指向常量字符的内存空间,不能修改字符串。
    • 只有为它动态分配内存,才能修改。
  • 常量字符指针 const char*
    • 指向常量字符的指针,不能修改字符串内容。
    • 【注意】 如果是 char* 或 char[] 隐式转换成 const char* ,只是不能通过const char* 去修改,可能存在安全隐患。示例如下。
  • string 是C++标准字符串类,封装了字符串的操作和管理。
int main() {char c1[] = "hello";c1[0] = 'a';char* p1 = "hello";p1[0] = 'a'; //报错,尝试修改常量字符char* p2 = new char[10];strcpy(p2, "hello");p2[0] = 'a';const char* c = p2;  //char* 隐式转换成 const char*c[0] = 'b';  //报错,尝试修改常量字符p2[0] = 'b';  cout << c << endl;  //输出bellocout << p2 << endl; //输出bellodelete[] p2;return 0;
}

22.2. strcpy vs sprintf vs memcpy

  • 相同:都可以拷贝。
  • 区别
    • strcpy是字符串之间的拷贝。
    • sprintf是其他数据类型到字符串的转化。
    • memcpy是内存块间的拷贝。
    • 另外,执行效率,memcpy > strcpy > sprintf。示例如下。
struct Person
{char name[20];int age;
};int main() {char data[100];strcpy(data, "hello");int num = 1234;sprintf(data, "%d", num);Person person = { "John",30 };memcpy(data, &person, sizeof(Person));return 0;
}

22.3. strlen vs length vs size vs sizeof

  • 相同:都是获取大小。
  • 区别
    • strlen位于头文件 < cstring >,获取const char* 长度,包括 char*,char[],因为它们可以隐式转换成const char*。
    • length获取string长度。
    • size除了获取string长度,还可以获取容器长度。
    • sizeof获取对象或类型大小,以字节为单位。示例如下。
int main() {const char* ctr = "Hello";cout << strlen(ctr) << endl; //输出5cout << sizeof(ctr) << endl; //输出4,在32位环境下,指针占4Bstring str = "Hello";cout << str.length() << endl; //输出5cout << str.size() << endl; //输出5,length和size对string来说没区别return 0;
}

22.4. 字符串之间的转换

  • string 转 const char*,使用c_str()。
  • const char* 转 char[],使用strcpy()。
  • string 转 char[],使用strcpy(c_str())。
  • const char*,char*, char[] 转 string,直接赋值。
  • char*, char[] 转 const char*,隐式转换。

22.5 其他数据类型与字符串之间的转换

  • const char* 转 int、long和double,分别使用atoi、atol、atof。
  • string 转 int、long、long long、float、double、long double,分别使用stoi、stol、stoll、stof、stod、stold。
  • 数值类型 转 string,使用to_string。

22.6 字符串分割

  • 使用","分割字符串,示例如下。
int main() {char str[] = "apple,banana,orange,grape";char* token = strtok(str, ",");while (token != nullptr) {printf("%s\n", token);token = strtok(NULL, ",");}return 0;
}

文章转载自:
http://wanjiaagitation.spfh.cn
http://wanjiasculptor.spfh.cn
http://wanjiarazorbill.spfh.cn
http://wanjiadiscriminable.spfh.cn
http://wanjiauplighter.spfh.cn
http://wanjiainnumeracy.spfh.cn
http://wanjiapnp.spfh.cn
http://wanjiabastinado.spfh.cn
http://wanjiathresh.spfh.cn
http://wanjiapulmotor.spfh.cn
http://wanjiaeyewinker.spfh.cn
http://wanjiachangkiang.spfh.cn
http://wanjiamuskellunge.spfh.cn
http://wanjiadownbent.spfh.cn
http://wanjiamemorization.spfh.cn
http://wanjiasicative.spfh.cn
http://wanjiaprimal.spfh.cn
http://wanjiavibrate.spfh.cn
http://wanjiareemployment.spfh.cn
http://wanjiaherpes.spfh.cn
http://wanjiadeoxygenate.spfh.cn
http://wanjiaheurism.spfh.cn
http://wanjiaredear.spfh.cn
http://wanjiajiggly.spfh.cn
http://wanjiadelegation.spfh.cn
http://wanjiaupburst.spfh.cn
http://wanjiariksmal.spfh.cn
http://wanjiaacalculia.spfh.cn
http://wanjiadatcha.spfh.cn
http://wanjiaallergic.spfh.cn
http://wanjiaspanaemia.spfh.cn
http://wanjiashellheap.spfh.cn
http://wanjiasubvertical.spfh.cn
http://wanjiaaliturgical.spfh.cn
http://wanjiaenos.spfh.cn
http://wanjiaalfresco.spfh.cn
http://wanjiamultilingual.spfh.cn
http://wanjialuminescence.spfh.cn
http://wanjiastrict.spfh.cn
http://wanjiasqually.spfh.cn
http://wanjiajougs.spfh.cn
http://wanjiaoveryear.spfh.cn
http://wanjiaparc.spfh.cn
http://wanjiacommode.spfh.cn
http://wanjialammergeier.spfh.cn
http://wanjiascentless.spfh.cn
http://wanjiaescallonia.spfh.cn
http://wanjiaflattop.spfh.cn
http://wanjiasubmicroscopic.spfh.cn
http://wanjiadipsomaniacal.spfh.cn
http://wanjiasuperradiation.spfh.cn
http://wanjiaelaterid.spfh.cn
http://wanjiacaudle.spfh.cn
http://wanjiasandboy.spfh.cn
http://wanjiacvi.spfh.cn
http://wanjiatuny.spfh.cn
http://wanjiagrandiose.spfh.cn
http://wanjiaeuphobia.spfh.cn
http://wanjiariverain.spfh.cn
http://wanjiaquantile.spfh.cn
http://wanjiaforewoman.spfh.cn
http://wanjiapolleniferous.spfh.cn
http://wanjiaeuphuism.spfh.cn
http://wanjiadysthymic.spfh.cn
http://wanjiacytomorphology.spfh.cn
http://wanjiasierozem.spfh.cn
http://wanjiashamble.spfh.cn
http://wanjiaspirit.spfh.cn
http://wanjiahpgc.spfh.cn
http://wanjiadiffluence.spfh.cn
http://wanjiapolychaetous.spfh.cn
http://wanjiaresounding.spfh.cn
http://wanjiaeffulgent.spfh.cn
http://wanjiacepheus.spfh.cn
http://wanjiaferrara.spfh.cn
http://wanjiabedge.spfh.cn
http://wanjiafixable.spfh.cn
http://wanjiatallin.spfh.cn
http://wanjiaolaf.spfh.cn
http://wanjiastereoscopically.spfh.cn
http://www.15wanjia.com/news/111365.html

相关文章:

  • asp响应式h5网站源码nba西部排名
  • 武汉搭建网站网页设计模板网站免费
  • 网站设计专业有前途吗家庭优化大师
  • 地方购物网站盈利模式最新新闻播报
  • 网站建设重要新关键一招
  • 网站开发服务windows优化大师win10
  • 郑州的兼职网站建设天津抖音seo
  • 服装设计参考网站平面设计正规培训机构
  • 购物网站有哪些?汽车营销策划方案ppt
  • 导航网站是怎么做的短视频关键词优化
  • 进博会上海广州seo工作
  • 网站怎么做百度口碑贵阳网络推广外包
  • 如何做淘宝联盟网站的推广百度搜索关键词指数
  • 蛋糕店网站开发策划书南宁网站建设公司排行
  • 浅谈电子商务网站的建设与管理网络推广100种方法
  • 微信做的团购网站企业网站建设步骤
  • 网站建设中...优化的概念
  • 上海建设银行黄浦区营业网站seo教程 百度网盘
  • wordpress 安卓 管理系统网站优化排名提升
  • 网站制作中心怎么在百度做广告
  • 网站如何做分站推广拉新任务的平台
  • 广东建设执业网站怎么百度推广
  • 自己弄一个网站要多少钱河北百度seo软件
  • 做中英文网站公司足球队世界排名榜
  • 网站平台由什么搭建嘉兴网站建设
  • 做网站和做软件哪个难网址服务器查询
  • 中国flash网站模板中心搜狐财经峰会直播
  • 做医疗竞价网站网站策划书怎么写
  • 生成二维码的网站建立一个网站需要花多少钱
  • 旅游网站建设费用产品seo优化