评论公正地解释了这一切。帮帮我?字符串矩阵的sizeof
string aZOM[][2] = {{"MoraDoraKora", "PleaseWorkFFS"},{"This is a nother strang.", "Orly?"}};
cout << sizeof("MoraDoraKora") <<" \n";
//Obviously displayes the size of this string...
cout << sizeof(aZOM[0][0]) << " \n";
//here's the problem, it won't display the size of the actual string... erm, what?
string example = aZOM[0][0];
cout << example << " \n";
cout << aZOM[0][1] << " \n";
//Both functions display the string just fine, but the size of referencing the matrix is the hassle.
注意;对于第一个你得到一个const char *的大小? – Skeen 2013-03-23 00:30:34
这似乎是更好的解释。 :) – scones 2013-03-23 00:31:18
@Skeen你得到数组的大小,因为数组不会经历数组到指针的转换作为'sizeof'的操作数。 – 2013-03-23 00:31:48