caskad caskad - 27 days ago 10
C++ Question

How to compare litere with an array of char with "("

I have problem to compare litere with an array of char with "(". I need a function to compare each array element with sign, but i don't know how to do it? Please help me.

#include<iostream>
using namespace std;

int v( const string &p )

{
int lvl=0;
int indeks=-1;
for(int i=0;i<=p.size();i++)
{
if(p[i]=="(")
lvl--;
// else if(p[i]=="}")
// lvl++;
// else if(p[i]=="+")
//indeks=i;
//cout<<p[i]<<'\n';
}
//cout<<lvl;




}

int main()
{
//string j;
string p;

cin>>p;

v(p);
getchar();
}

Answer

Compare with '('.

Single quote '' is used for character.

Double quote "" is used for strings.