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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:49:39+00:00 2026-05-17T23:49:39+00:00

In C++, how to deal with NULL values in a context where we might

  • 0

In C++, how to deal with NULL values in a context where we might expect a string or an integer?

Typically, the context would be when retrieving data from a database, e.g. with a LEFT JOIN where some non-existing values in some column would be represented by a NuLL value instead of the expected string or integer.

Strong casting in C++ makes this type of scenario much more difficult to deal with than with PHP.

In PHP, we can easily have a if/else switch using the === operator:

if ($value === NULL) {
  // No data.
} else {
  // We have some valid data.
}

What would the equivalent look like in C++?

I’ve searched and couldn’t find a C++ relevant question.

The question is valid in general. In my particular case, I am using the dbixx SQL library.

  • 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-17T23:49:39+00:00Added an answer on May 17, 2026 at 11:49 pm

    It may sound like a general concept, but there is no general answer for C++. The language itself does not have a truly general “NULL” value that can by used with all types to distinguish from having been set to an actual value.

    So the answer in any situation entirely depends on the library or whatever that you’re working with and how it has been designed to indicate “NULL” values. The return values of functions used to access the data may perhaps indicate whether the data is NULL or otherwise. Or there may be something like a separate IsNull() function. Or the library may use some other different scheme. There are many possibilities.

    The only possible general answer is: read the documentation of the library to find out how they specifically deal with it.

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

Sidebar

Related Questions

In my database application I sometimes have to deal with null strings in the
What is the best way to deal with null values in Linq. I have
I have a great deal of data to keep synchronized over 4 or 5
How should one deal with an MVC controller returning a null ViewResult? As an
Allowing NULL values on a column is normally done to allow the absense of
Some tables I am dealing with have null values and are throwing errors. So
How do you deal with source control management and automated deployment (configuration management) of
I have to deal with text files in a motley selection of formats. Here's
In my work I deal mostly with C# code nowadays, with a sprinkle of
I'm about to deal with managing and running my first Internet connected Apache webserver

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.