我该如何进行这项工作?
char stringw[]; //to hold the data user enters and then copy it to the string vector .. I didnt know any direct method
cin>>stringw;
directions.push_back(stringw); //directions is a <string> vector
我该如何做这样的检查?
if(directions[i][j])=="N") //I am getting an error
"error: expected primary-expression before '==' token"
编辑1: 错误解决 if(directions[i][j])=="N")
应该是 if(directions[i][j]=="N")
我意外关闭了括号
现在我们如何将字符串数据添加到字符串向量中?
编辑2: 解决!
实际上使用 char stringw
是数据类型 char * 并且我正在将 char *
推入一个字符串……它不是那样的。
原文由 brainst 发布,翻译遵循 CC BY-SA 4.0 许可协议