自学string 发现了问题但是不知道错在哪里了

问题描述

自学string 发现了问题但是不知道错在哪里了

自学string 发现了问题但是不知道错在哪里了
#include
#include
#include
#include
using std:: string;
using namespace std;
int main()
{
string str("some string");
for( auto c:str)
cout << c << endl;
return 0;
}

解决方案

你的编译器版本是多少? auto是c++11的新特性, 需要vs2013以上的版本

解决方案二:

你是错哪了? 你要说出来啊! 是编译不通过吗? 你是用C++11的语法写的,编译器要开C++11

解决方案三:

string类可以直接用 string str("balala"); cout<<str ; 不需要循环输出的

解决方案四:

直接cout<<str;就行了。

时间: 2024-09-19 08:57:31

自学string 发现了问题但是不知道错在哪里了的相关文章

c-链队列不对 不知道错在哪里

问题描述 链队列不对 不知道错在哪里 #include#includetypedef struct Node { int number; char name[20]; Node *next;}Qnode;typedef struct { Qnode *front; Qnode *rear;}LinkQueue;void Enqueue(LinkQueue *q){ int n; scanf_s(""%d"" &n); for (int i = 1;i <

html-这个验证跳转总是失败,实在不知道错在哪,可以帮我看看吗?

问题描述 这个验证跳转总是失败,实在不知道错在哪,可以帮我看看吗? 主页登陆<br> function check() {<br> if (document.forms(0).name.value == "123" && document.forms(0).pw.value == "123456") {<br> window.location = "body.html";<br> }

代码-我的JS实行不了跳转,不知道错在哪

问题描述 我的JS实行不了跳转,不知道错在哪 regist.php中的一行 <dd class=""face""><img src=""images/1.jpg"" alt=""头像选择"" id=""faceimg""/></dd> JS文件中的代码 window.onload=function(){ var

c++-C++友元的问题。不知道错在哪里。弄得恼火了。。求助。

问题描述 C++友元的问题.不知道错在哪里.弄得恼火了..求助. 先不要管它干什么用,要怎样修改才可以运行呢?为什么要这样修改? void set_input(){input=(input==TV)? DVD : TV;} void settings() const; void ch_h(Remote &t); void input_ch_h(Remote &t); private: int state; int volume; int maxchannel; int channel; i

string-求助大家,请问下面的错误提示是不是说明我的String转Int出错了,错在哪里?

问题描述 求助大家,请问下面的错误提示是不是说明我的String转Int出错了,错在哪里? 注:其中pid变量是从另一个页面传过来的整数 解决方案 两个可能,pid这个参数不存在,或者它为空字符串.带有空格或者别的不能转换为数字的情况 int pid = Integer.parseInt(request.getParameter("pid")); 解决方案二: 下个断点调试下. 解决方案三: 我怎么没看到图,图呢?

报错-我刚学Qt,能帮我改改代码吗?不知道错哪了

问题描述 我刚学Qt,能帮我改改代码吗?不知道错哪了 解决方案 第一个源代码缺少 include "mydilaog.h"

malloc-小弟谢了一个简单的字符串求最大子串的程序不知道错哪里,請大神帮忙回答下

问题描述 小弟谢了一个简单的字符串求最大子串的程序不知道错哪里,請大神帮忙回答下 程序要求如下: 一个字符串,字符连续的部分为子串(不含带数字的部分) 下面是我写的程序 #include using namespace std; char* BiggestStr(char* str) { char* pStr = (char*)malloc(sizeof(str)+1); //申请一个空间存最大子串 int nCount = 0; //用于记录最大子串的长度 int J_nCount=0; ch

vs2012-我的C程序VS2013报错,都不知道错哪了,请大神指教

问题描述 我的C程序VS2013报错,都不知道错哪了,请大神指教 hash函数名和数组next都定义了,都不知道哪错了 解决方案 感觉是标准库的某些内容重复了. std::next是里的template, std::hash是里的template. 都是c++ 11定义的. 解决方案二: 自己重新定义一下名字,这几个名字已经在类库中存在了 解决方案三: 你的定义重复了,如果你的代码没有重复定义它们,可能是和你包含的库文件冲突了,那么换个名字看看 解决方案四: hash和next重复定义了. 你可

c语言 数据结构-用c写了一个舞伴配对,却不知道错在哪,求解

问题描述 用c写了一个舞伴配对,却不知道错在哪,求解 #include #include #include #define OK 1 #define ERROR 0 #define OVERFLOW -2 #define MAXSIZE 100 typedef int Status; typedef struct { char name[20]; char sex; }Person,QElemType; typedef struct Qnode { QElemType data; struct