字符串常量和字符串变量的区别
#include
#include
using namespace std;
int main(){
string s1 = “abc”;//字符串变量
char* s2 = “abc”;//字符串常量,先在常量区存储"abc",s2直接指向常量区的"abc"
char s3[] = “abc”;//字符数组,先在常量区存储"abc",然后在栈区申请内存空间,将"abc"复制过来,s3指向栈区...
转载
2018-12-01 23:11:44 ·
6751 阅读 ·
0 评论