Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Simple problem with a list!

Simple problem with a list!

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael101
    wrote on last edited by
    #1

    Hi people, I've got an If statement in my code that needs to check the last element of a list. Like follows: if (Remainder == 1 && TesterIterator != Mersenne.end()) This doesn't work the way I would like because the .end() command takes you to one element past the end of the list :'(. I would like to construct an if statement that would like to go to the last element minus one. This is one that I tried but it didn't work :( if (Remainder == 1 && TesterIterator != (Mersenne.end()--)) Does anyone have any ideas? I am very appreciative for all your help in advance. Michael :)

    S 1 Reply Last reply
    0
    • M Michael101

      Hi people, I've got an If statement in my code that needs to check the last element of a list. Like follows: if (Remainder == 1 && TesterIterator != Mersenne.end()) This doesn't work the way I would like because the .end() command takes you to one element past the end of the list :'(. I would like to construct an if statement that would like to go to the last element minus one. This is one that I tried but it didn't work :( if (Remainder == 1 && TesterIterator != (Mersenne.end()--)) Does anyone have any ideas? I am very appreciative for all your help in advance. Michael :)

      S Offline
      S Offline
      santhoshv84
      wrote on last edited by
      #2

      Hi, try like this. if (Remainder == 1 && TesterIterator != (Mersenne.end()-1))

      Thanks and Regards. SANTHOSH V

      M 1 Reply Last reply
      0
      • S santhoshv84

        Hi, try like this. if (Remainder == 1 && TesterIterator != (Mersenne.end()-1))

        Thanks and Regards. SANTHOSH V

        M Offline
        M Offline
        Michael101
        wrote on last edited by
        #3

        Thank you very much

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups