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. while(memory_address)

while(memory_address)

Scheduled Pinned Locked Moved C / C++ / MFC
performance
5 Posts 3 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.
  • T Offline
    T Offline
    tongc
    wrote on last edited by
    #1

    Hi i have the following piece of code temp= some_memoryAddress while(temp) { doSmth(); temp = anotherMemoryAddress } what does the expression while(temp) do, i never seen memory address as an condition in the while loop. Thanks

    D D 2 Replies Last reply
    0
    • T tongc

      Hi i have the following piece of code temp= some_memoryAddress while(temp) { doSmth(); temp = anotherMemoryAddress } what does the expression while(temp) do, i never seen memory address as an condition in the while loop. Thanks

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      This is equal to:

      temp= some_memoryAddress
      while(temp != 0)
      {
      doSmth();
      temp = anotherMemoryAddress
      }

      Clippy: It seems you're mantaining someone else's code, who knew C++ better than you. Good luck! lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik

      1 Reply Last reply
      0
      • T tongc

        Hi i have the following piece of code temp= some_memoryAddress while(temp) { doSmth(); temp = anotherMemoryAddress } what does the expression while(temp) do, i never seen memory address as an condition in the while loop. Thanks

        D Offline
        D Offline
        Dominik Reichl
        wrote on last edited by
        #3

        doSmth should do something and change anotherMemoryAddress, otherwise this code doesn't make any sense. some_memoryAddress should be initially non-NULL. The while loops until anotherMemoryAddress is NULL. This is normally the case when doSmth fails or doSmth has enumerated all memory addresses of anything. :-D -Dominik

        T 1 Reply Last reply
        0
        • D Dominik Reichl

          doSmth should do something and change anotherMemoryAddress, otherwise this code doesn't make any sense. some_memoryAddress should be initially non-NULL. The while loops until anotherMemoryAddress is NULL. This is normally the case when doSmth fails or doSmth has enumerated all memory addresses of anything. :-D -Dominik

          T Offline
          T Offline
          tongc
          wrote on last edited by
          #4

          great! this is the answer i need!!! ;) The while loops until anotherMemoryAddress is NULL so this equals to while(memory_address != NULL) { DoSomth(); } Regard,

          D 1 Reply Last reply
          0
          • T tongc

            great! this is the answer i need!!! ;) The while loops until anotherMemoryAddress is NULL so this equals to while(memory_address != NULL) { DoSomth(); } Regard,

            D Offline
            D Offline
            Dominik Reichl
            wrote on last edited by
            #5

            Exactly :-D -Dominik

            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