type
status
category
date
slug
summary
tags
password
icon

📝 主旨内容

int转string
  • itoa(value,char *str,转换进制)
    • 三个参数 :int值,指向字符的指针,进制
    • itoa返回一个字符数组然后赋值给string对象,即可完成int到string的转化;
  • 最好用to_string(int i)
    • string str =to_string(10) str即为“10”
  • 无法使用itoa(val,str.c_str,进制)完成int到string对象的转化
    • 1.string str;str.c_str()返回的是 const char * ,是指向字符常量的指针;str[0]无法被变动,否则出错。
    • 2.一般用到c_str() 多用于无法直接printf 一个string对象输出 string str; printf("%s",str.c_str())可以输出整个string
  • atoi(char * str)返回一个int
    • 这里可以使用int a=atoi(itoa(val,char *str),8) 来完成val向8进制的转换
  • char ss[5]={"abcd"};
    • cout<<ss[2]<<endl; 打印出 c
    • cout<<ss<<endl; 打印出 abcd
  • 对字符数组的几种赋值
SQL 优化yindun_note
Guxi8086
Guxi8086
一个普通的干饭人🍚
公告
type
status
category
date
slug
summary
tags
password
icon
notion image
🎉NotionNext 🎉
👏欢迎更新体验👏