Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;字符串声明_C++_String - Fatal编程技术网

C++ C++;字符串声明

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()

我已经用VB工作了一段时间了。现在我给出了C++的一个镜头,我遇到了字符串,我似乎找不到一种声明字符串的方法。 例如,在VB中:

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];