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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:35:32+00:00 2026-06-18T01:35:32+00:00

I need to ignore an uninitialized variable in C++ when I reach the end

  • 0

I need to ignore an uninitialized variable in C++ when I reach the end of my grid.

         pointMapIt++;
         float nextPointRow;
         if (pointMapIt != grid.points.end())
         {
             nextPointRow = 3.0;
             pointMapIt--;
         }

         if (point.dr != nextPointRow)
             //Do stuff

pointMapIt is an iterator passing through my grid points. It checks against nextPointRow every iteration. The program will crash at the final iteration, because nextPointRow will not have been set.

I cannot set nextPointRow to 0.0, because 0.0 is an actual valid input. In fact, I really have no way of telling what nextPointRow will be. So what I really need is to be able to (initialize nextPointRow to and) check nextPointRow against NULL, like so:

         if (nextPointRow != null && point.dr != nextPointRow)

Is there a way I can do this or circumvent the issue altogether?

  • 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-18T01:35:34+00:00Added an answer on June 18, 2026 at 1:35 am

    The easiest might be setting nextPointRow to NAN.

    Alternatively, have a boolean flag alongside nextPointRow that would indicate whether the latter contains a valid value.

    Yet another option is to rearrange your code like so:

         pointMapIt++;
         if (pointMapIt != grid.points.end())
         {
             float nextPointRow = 3.0;
             pointMapIt--;
             if (point.dr != nextPointRow) {
                 //Do stuff
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to ignore routes matching this schema /{controller}/edit/undefined {controller} - could be any
I have a situation where I need to ignore parts of page load sub
I have a situation where I need NHibernate to ignore its caches and just
I need split string by commas and spaces, but ignore the inside quotes, single
Using Mercurial, I need to ignore all files and directories except directories tests and
I have two different questions(on both questions need to ignore spaces) How to print
I am running into a problem with jQuery Validation and need to ignore some
Assume I have this: Regex.Replace(aa cc bbbb,aa cc,,RegexOptions.IgnoreCase); But I also need to ignore
I read from file some strings, and I need to ignore strings that I
I need to ignore bin folders except the one placed in the root. Here

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.