当我声明字符串数组时,C如何计算偏移地址
发布时间:2020-12-16 10:32:23 所属栏目:百科 来源:网络整理
导读:虽然字符串是动态的,所以它没有任何确定的大小,所以当我在s [0]之前得到s [1]时,C将如何计算其偏移地址. 例如int a [2] 0000:1000 a[0]0000:1004 a[1] 程序: #includeiostream#includevectorusing namespace std;int main(){ string s[2]; cins[1]; couts[1
虽然字符串是动态的,所以它没有任何确定的大小,所以当我在s [0]之前得到s [1]时,C将如何计算其偏移地址.
例如int a [2] 0000:1000 a[0] 0000:1004 a[1] 程序: #include<iostream> #include<vector> using namespace std; int main() { string s[2]; cin>>s[1]; cout<<s[1]<<endl; cin>>s[0]; cout<<s[0]<<endl; } 解决方法
字符串数组是一个字符串对象数组,它们具有固定大小,并且有效地包含字符串实际驻留的其他位置的指针.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |