T.Y.M.SAI
T.Y.M.SAI

Reputation: 37

Why this is showing error ? even though it seems all syntax is correct?

I was writing a c++ code then encountered this error, how to resolve this ? enter image description here

#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

Answers (1)

edtheprogrammerguy
edtheprogrammerguy

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

Related Questions