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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:58:39+00:00 2026-05-31T01:58:39+00:00

I encountered a problem in c++. I read some codes,but there was a very

  • 0

I encountered a problem in c++. I read some codes,but there was a very wired usage of pointer. The code is following:

   double* marginalProbability =
   new double [10 * sizeof(marginalProbability[0])];
   memset( marginalProbability, 0, 10 * sizeof(double) );
    //................
            //.................
   if(marginalProbability>0)
        printf("larger");
   else
        printf("smaller");

The question I’m asking is what does it mean that if(marginalProbability>0). It is a pointer greater than zero. I think that in a normal compiler, there are no addresses which will be equal to zero. Or are there any other meanings of that? Otherwise, this line seems meaningless. Thanks.

  • 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-31T01:58:41+00:00Added an answer on May 31, 2026 at 1:58 am

    a pointer with the value of zero is a null pointer. A pointer to nothing. Checking that it is not zero (p!=0 is more common that p>0 although p!=nullptr is most correct) means that it is not null.

    The code you have listed is also wrong. if the new operation fails it will not return a null pointer but throw an exceptions which will no be caught.

    this is what it should be.

    try{
        std::vector<double> marginalProbability (10, 0.0);
    }catch(const std::bad_alloc& e){
        std::cerr << "no memory" << std::endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encountered a problem when running some old code that was handed down to
I encountered a problem dealing with UTF-8, XML and Perl. The following is the
The following code adds tasks that perform some processing on files from the blobstore,
In many embedded applications there is a tradeoff between making the code very efficient
We encountered a problem with using Subversion on Windows. A developer committed a file
I recently encountered a problem where a value was null if accessed with Request.Form
I've encountered a problem when retrieving a JSONP response from a server in a
I've encountered a problem with my Netbeans 6.1 IDE. After an unsuccessful update, Netbeans
I have encountered a problem that I have not come accross yet when setting
I recently encountered a problem with my Profile provider: it wouldn't retrieve profiles correctly

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.