最近刚刚开始回到编程,并开始做一些练习,但我一直刚开一个错误,应该是简单的解决,但不能似乎解决它......串字符被分配到一个char
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
int numberInts = 3;
int strSize = 0;
char interator = 'o';
string source[3];
string strTest ("this is a test");
//source = (string*) malloc (3+1);
source[0] = "(a+(b*c))"; //abc*+
source[1] = "((a+b)*(z+x))";
source[2] = "((a+t)*((b+(a+c))^(c+d)))";
for(int i=0;i<numberInts;i++)
{
strSize = source[i].size();
for(int j = 0; j < strSize; j++)
{
iterator = strTest[0];
if(source[i][j] == '\(')
{
cout<<"\(";
}
}
cout << "\n";
}
return 0;
}
行“iterator = strTest [0];”给我一个缺少模板参数错误,我不能真正弄明白为什么不能我分配到一个char返回一个字符的字符串的位置...
感谢
当错误似乎没有道理时,仔细检查您的变量名称。 ;) – Vache
在标准库中使用非常常用的词避免变量名是明智的,例如,迭代器。你会得到一个更明显的错误信息。 –
不惜一切代价避免使用名称空间标准;编译器会给你一个非常有用的错误消息,但是你的命名空间指令。 –