Reputation: 37
I was writing a c++ code then encountered this error, how to resolve this ?
#include<iostream>
using namespace std;
int main(){
string str="([])[]({})";
char a[10];
int stk[10], total=0;
for(int i=0; i<10; i++){
a[i]=str[i];
cout<<a[i];
if(a[i]=="[" || a[i]=="{" || a[i]=="("){
}
}
}
Upvotes: 1
Views: 75
Reputation: 6049
Put single ticks around the items being compared: '['
instead of "["
. That way you are comparing char
to char
instead of char
to a string
Upvotes: 2