为什么string sentence,s1; cin>>sentence; n=sizeof(sentence)/2; sentence输入"price>30000",n=8.输入"price>30",n也为8.
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/26 17:03:01
![为什么string sentence,s1; cin>>sentence; n=sizeof(sentence)/2; sentence输入](/uploads/image/z/11844571-67-1.jpg?t=%E4%B8%BA%E4%BB%80%E4%B9%88string+sentence%2Cs1%3B+cin%3E%3Esentence%3B+n%3Dsizeof%28sentence%29%2F2%3B+sentence%E8%BE%93%E5%85%A5%22price%3E30000%22%2Cn%3D8.%E8%BE%93%E5%85%A5%22price%3E30%22%2Cn%E4%B9%9F%E4%B8%BA8.)
x͐J@_%teahl
I]4DfIWZ1ijQknؗi%.p)5$cҞӱMr8D7*I0c7՟1f٦nMY5DڭwRXiaROg,C7*{R-c>>KթexޫlYEl&1!Z.?Gpmįg<4CYr!"SN9
ұv ^&4"
为什么string sentence,s1; cin>>sentence; n=sizeof(sentence)/2; sentence输入"price>30000",n=8.输入"price>30",n也为8.
为什么string sentence,s1; cin>>sentence; n=sizeof(sentence)/2; sentence输入"price>30000",n=8.
输入"price>30",n也为8.
为什么string sentence,s1; cin>>sentence; n=sizeof(sentence)/2; sentence输入"price>30000",n=8.输入"price>30",n也为8.
sizeof(sentence) 等同于写成 sizeof(string),它的结果是与sentence的内容无关的一个定值,这个值在程序编译阶段已经固定,由编译器给出,而不是运行时计算的.