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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:43:59+00:00 2026-05-14T14:43:59+00:00

I do not understand the termination parameter of this for loop. What does it

  • 0

I do not understand the termination parameter of this for loop. What does it mean? Specifically, what do the ?, ->, and : 0 represent?

for( i = 0; i < (sequence ? sequence->total : 0); i++ )
  • 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-14T14:44:00+00:00Added an answer on May 14, 2026 at 2:44 pm

    This: (sequence ? sequence->total : 0) (it’s called a “ternary if”, since it takes three inputs) is like saying:

    if (sequence)
        replaceEntireExpressionWith(sequence->total);
    else
        replaceEntireExpressionWith(0);
    

    -> is a dereferencer, just like *, but it makes user data-types like structs easy to use.

    sequence->total means sequence is a pointer to a one of those data types, and you are accessing the total property of what it is pointing to. It’s exactly the same as:

    (*sequence).total;
    

    So the loop:

    for( i = 0; i < (sequence ? sequence->total : 0); i++ )
    

    exits when sequence evaluates to false, since 0 == false.

    The ternary if construction is used to make sure they aren’t dereferencing (->) a null pointer, because if they just put sequence->total as the condition, they would be dereferencing it every time. Unhappy! =(

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

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer IDEA will understand parallel JUnit tests only since version 10.… May 16, 2026 at 2:05 pm
  • Editorial Team
    Editorial Team added an answer Found it! Here is the proof: As you can see,… May 16, 2026 at 2:05 pm
  • Editorial Team
    Editorial Team added an answer serialize and unserialize are pretty watertight functions with one notorious… May 16, 2026 at 2:05 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I do not understand autoincrementing letters in Perl. This example seems perfectly understandable: $a
Environment: Linux C++ / Qt 4x I do not understand why the following downcast
I read the article on wikipedia but could not understand what exactly are NP
This is probably simple but I do not seem to get it to work.
Coming from Java and Python, I am not so well versed in memory management,
[Edit1:] For the seqName, I declare it as a global parameter at the beginning
I cannot seem to understand the behavior of GC.Collect() under the presence of a
I am using the code snippet below, however it's not working quite as I
That has been hours i am tracking a Moose::Util::TypeConstraints exceptions, i don't understand where
I want to terminate a process group by sending SIGTERM to processes within it.

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.