Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7901761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:19:00+00:00 2026-06-03T09:19:00+00:00

I have the following: int findPar(char* str) { int counter=0; while (*str) { if(str[0]

  • 0

I have the following:

int findPar(char* str)
{
int counter=0;

while (*str) 
{
    if(str[0] == "(") <---- Warning
    {
        counter++;
    }
    else if (str[0]== ")") <---- Warning
    {
        counter--;
    }
    if (counter<0) 
    {
        return 0;
    }
    str++;
}

if (counter!=0) 
{
    return 0;
}
return 1;
}

The warning i get is comparison between an int and a char.

I tried to do the comparison (first char in the string vs. given char) also with strcmp like this:

    if (strcmp(str, ")")==0) { stuff }

but it never goes in to ‘stuff’ even when the comparison (should) be correct.

how should i do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:19:02+00:00Added an answer on June 3, 2026 at 9:19 am

    If str is a C string (null-terminated array of chars), then str[0] is a char.

    Note that the type of quotes matters! ')' is a char, while ")" is a string (i.e. a ')' char followed by a null terminator).

    So, you may compare two chars:

    str[0] == ')'
    

    or you may compare two strings

    strcmp(str, ")") == 0
    

    naturally, (the second works if str string really only contains that parenthesis).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So...I have the following code: int main(void) { const char *s=hello, world; cout<<&s[7]<<endl; return
I have the following code int ParseData(unsigned char *packet, int len) { struct ethhdr
I have the following code: int main(int argc, char** argv) { onelog a; std::cout
Lets say I have the following: int i = 1; String str(abc); Would str
I have the following application. #include <FWWindow.h> #include <FWApplication.h> int main(int /*argc*/, char */*argv*/[])
So I have the following program: int main(){ char* one = computer; char two[]
I have the following code : int *edges[500]; char arr[] = {'c','d'}; edges[0] =
Suppose you have the following code: int main(int argc, char** argv) { Foo f;
I have the following function: int strpos(const char *needle, const char *haystack) { int
I have the following code: int get_int(void) { char input[10]; fgets(input, 10, stdin); //

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.