【发布时间】:2015-07-26 19:36:02
【问题描述】:
我有一些代码:
#include <iostream>
#include <string>
using namespace std;
int main(){
char abc [20] = "Hello Hello Hi";
char* ptr = abc;
cout << (abc+3);
return 0;
}
为什么它从第三个字符开始打印,而不是简单的第三个字符?
-edit- 给标记它的人。它与 prinf() 不同,而是相同类型的概念。我只是不知道细微差别
【问题讨论】:
-
cout << abc;也不会仅打印第一个(第 0 个)字符,而是整个字符串...跳过 3 个字节不会改变这种行为。 -
为什么有
char* ptr = abc?