C++ C++;字符串声明
我已经用VB工作了一段时间了。现在我给出了C++的一个镜头,我遇到了字符串,我似乎找不到一种声明字符串的方法。 例如,在VB中:C++ C++;字符串声明,c++,string,C++,String,我已经用VB工作了一段时间了。现在我给出了C++的一个镜头,我遇到了字符串,我似乎找不到一种声明字符串的方法。 例如,在VB中: Dim Something As String = "Some text" 或 什么是C++中的代码? 感谢您的帮助。使用标准标题 std::string Something = "Some Text"; C++提供了一个类,可以这样使用: #include <string> #include <iostream> int main()
Dim Something As String = "Some text"
或
什么是C++中的代码?
感谢您的帮助。使用标准
标题
std::string Something = "Some Text";
C++提供了一个类,可以这样使用:
#include <string>
#include <iostream>
int main() {
std::string Something = "Some text";
std::cout << Something << std::endl;
}
#include <string>
using namespace std;
int main()
{
string str1("argue2000"); //define a string and Initialize str1 with "argue2000"
string str2 = "argue2000"; // define a string and assign str2 with "argue2000"
string str3; //just declare a string, it has no value
return 1;
}
#包括
#包括
int main(){
std::string Something=“一些文本”;
STD::C++中的Couth首选字符串类型是String <代码>,定义在命名空间<代码> STD<代码>中,在页眉<代码>中,你可以像这样初始化它:例如:
#include <string>
int main()
{
std::string str1("Some text");
std::string str2 = "Some text";
}
#包括
int main()
{
std::string str1(“一些文本”);
std::string str2=“一些文本”;
}
<> P> C++中,你可以找到这样的字符串:
#include <string>
#include <iostream>
int main() {
std::string Something = "Some text";
std::cout << Something << std::endl;
}
#include <string>
using namespace std;
int main()
{
string str1("argue2000"); //define a string and Initialize str1 with "argue2000"
string str2 = "argue2000"; // define a string and assign str2 with "argue2000"
string str3; //just declare a string, it has no value
return 1;
}
#包括
使用名称空间std;
int main()
{
string str1(“argue2000”);//定义一个字符串并用“argue2000”初始化str1
string str2=“argue2000”;//定义一个字符串并将str2分配给“argue2000”
string str3;//只声明一个字符串,它没有值
返回1;
}
嘿!那char.array呢?char str[30];