如何包含字符串标题? [英] How do I include the string header?
问题描述
我正在尝试了解 string
s,但是不同的资料告诉我包括不同的标头。
I'm trying to learn about string
s, but different sources tell my to include different headers.
有人说使用< string.h>
,但其他人提到 apstring.h
。我可以使用 apstring
做一些基本的事情,但有人告诉我另一个更强大。当我包含< string.h>
并尝试声明一些字符串变量时,出现错误。正确的用法是什么?
Some say to use <string.h>
, but others mention "apstring.h"
. I was able to do some basic stuff with apstring
, but I've been told the other one is more powerful. When I include <string.h>
and try to declare some string variables, however, I get errors. What is the proper usage?
推荐答案
您要包含< string>
并使用 std :: string
:
#include <string>
#include <iostream>
int main()
{
std::string s = "a string";
std::cout << s << std::endl;
}
但是您真正需要做的是获取入门级书籍。您不会以其他任何方式正确学习,当然也不会在网上获取信息。
But what you really need to do is get an introductory level book. You aren't going to learn properly any other way, certainly not scrapping for information online.
这篇关于如何包含字符串标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!