#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
int main()
{
char tuna[6] = {'b', 'u', 'c', 'k', 'y', '\0'};
cout << tuna << endl;
char bacon[] = "bacon mmmm good";
cout << bacon << endl;
cout << strlen(bacon) << endl;
cin.get();
return 0;
}
本文展示了一个简单的C++程序,演示了如何使用字符数组来表示字符串,并利用标准库函数输出字符串及其长度。通过这个例子,读者可以了解基本的字符串初始化和处理方式。
1075

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



