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 6149697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:29:49+00:00 2026-05-23T19:29:49+00:00

what is the difference between some == some\0 and strcmp(some,some\0) in c++? Why if(some

  • 0

what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++?

Why if("some" == "some\0") returns false and if(!strcmp("some","some\0")) returns true ?

  • 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-05-23T19:29:50+00:00Added an answer on May 23, 2026 at 7:29 pm

    See the following diagram. It shows two strings in memory, their content is in the box, beside the box you’ll see the address of each one.

    string content and addresses

    When you’re doing if("some" == "some\0") you are comparing the addresses. It is translated into if (0xdeadbeef == 0x0badcafe) which is obviously false.

    When you use strcmp, you compare the content of each box until you reach \0 in each of them. That’s why the second test returns true.

    If you change the first test to if("some" == "some") then a compiler may potentially see that they are the same strings and will store them only once. Which means that your test will transform into if (0x0badcafe == 0x0badcafe) which is obviously true.

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

Sidebar

Related Questions

What the difference between Application(some-object) and Cache(some-object) in ASP.NET?
What is the difference between encrypting some data vs signing some data (using RSA)?
Can some one explain to me the difference between categories and inheritance in Objective
Can anyone explain the difference between the types mentioned above and some sample usage
Have seen some similar questions: What is the difference between a JavaBean and a
Can some one shed some light on the difference between XML and XMI? Can
What is the difference between XML and SOAP? I've been reading some introductory articles
Is there some difference between the way that bundle resources can be accessed on
What are some key Difference between ASP.Net 3.5 and 4.0
Is there a difference between Integrated Security = True and Integrated Security = SSPI

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.