int main()
{
string word[2]= { "hi","word" };
cout << word[0] << endl; //word[0]访问的是第0个单词
system("pause");
return 0;
}

*****************************************************
int main()
{
string word[2]= { "hi","word" };
cout << word[0][0] << endl; //word[0][0]访问的是第0个单词中第0个字母
system("pause");
return 0;
}

这篇博客展示了两个简单的C++程序,分别输出字符串数组的第一个单词和第一个单词的首字母。通过`string word[2]`定义字符串数组,并使用`cout<<word[0]`和`cout<<word[0][0]`来访问和打印元素。
624

被折叠的 条评论
为什么被折叠?



