C++使用string和string string textstring files
这两个是不同的数据类型。
string是C++中的一个类,用于表示字符串,可以用于存储和操作文本数据。
string[]是一个数组,用于存储一组字符串。它表示一个字符串数组,可以通过下标访问数组中的元素。
例如,以下代码定义了一个字符串变量text和一个字符串数组files:
string text = "Hello World";
string files[] = {"file1.txt", "file2.txt", "file3.txt"};
可以通过以下方式访问它们:
cout << text << endl;
cout << files[0] << endl;
cout << files[1] << endl;
cout << files[2] << endl;
输出结果为:
Hello World
file1.txt
file2.txt
file3.txt
原文地址: https://www.cveoy.top/t/topic/g89E 著作权归作者所有。请勿转载和采集!