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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:59:54+00:00 2026-06-02T17:59:54+00:00

I have an issue comparing a const char to a string… If I use

  • 0

I have an issue comparing a const char to a string… If I use Com_Printf (“%s”, value);
It returns what I want (0.3c), but how can I convert value to a string and compare that to 0.3c? This is what I have:

value = SearchInfostring(msg, "shortversion");
if (value != "0.3c")
{
    Com_Printf (MSG_WARNING,
            Com_Printf (MSG_WARNING,
                "> WARNING: Value: Should be 0.3c, is:  %s \n",
                value);
//Run stuff
}

That returns:
WARNING: Value: Should be 0.3c, is: 0.3c

  • 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-02T17:59:55+00:00Added an answer on June 2, 2026 at 5:59 pm

    If value is of type const char*, expression

    value != "0.3c"
    

    is comparing two pointers (addresses), not strings. You want to compare string and a string literal so can use strcmp:

    if(strcmp(value, "0.3c"))
    {
       // strings are not equal
    }
    else
    {
       // strings are equal
    }
    

    Bear in mind that preferred string type in C++ is std::string.

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

Sidebar

Related Questions

I have a really weird issue that I can't figure out with comparing objects
i have issue with comparing NAN value in C++, Visualstudio. I need to handle
Share your ideas please! I have issue to check the folder and convert a
I am having an issue with comparing text input with the values I have
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
We are new to ROR, We have issue in creating Login/Logout process in ROR
I have an issue with an open source C++ project that I have been
I have an issue. One of my JS scripts needs Facebook SDK and Twitter
I have an issue when playing video while using the c willRotateToInterfaceOrientation function. Initially,
I have one issue with retrieval Parent/Child relationship of type Folder Hierarchy Ideally, in

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.