我正在绞拧一个简单的代码来学习更多关于字符串的知识。当我运行我的代码时,它不会显示我的姓氏。有人能解释为什么吗?我使用了字符串短语来存储它,它似乎只存储了我的名字。这是代码。字符串短语在空格处结束?
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
cout << "Exercise 3B" << endl;
cout << "Kaitlin Stevers" << endl;
cout << "String arrays" << endl;
cout << endl;
cout << endl;
char greeting[26];
cout << "Please enter a greeting: " << endl;
cin >> greeting;
cout << "The greeting you entered was: " << greeting << endl;
string phrase;
cout << "Enter your full name " << endl;
cin >> phrase;
cout << greeting << ", how are you today " << phrase << "?" << endl;
return 0;
}
它适用于我。你确定你没有看到所需的输出? – GMichael
是的。也许我的编译器没有需要做字符串的文件。你会张贴你的出来的照片请。 –
在我的编译器中,字符串甚至不会亮起另一种颜色。如果它工作正确,不是吗? –