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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Pointers in C/C++

Pointers in C/C++

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++learning
4 Posts 4 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
    tgsb
    wrote on last edited by
    #1

    Hello....I am learning C and C++ and I find pointer as a very tough topic. Its really very hard to understand its key points. I want to know is there any difference in pointers of C and C++? And also how can I learn this topic easily.Thanks.

    L J enhzflepE 3 Replies Last reply
    0
    • T tgsb

      Hello....I am learning C and C++ and I find pointer as a very tough topic. Its really very hard to understand its key points. I want to know is there any difference in pointers of C and C++? And also how can I learn this topic easily.Thanks.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Pointers are the same in both versions of the language; they point to elements or objects. In reality a pointer is merely a convenient way of addressing a portion of memory. for example:

      char someArray[256]; // allocate an array of characters
      char* pItemOfArray = someArray; // create a pointer that 'points' to the first element of the array

      // do something to fill the array with data

      while (*pItemOfArray != '\0') // repeat some code while the array item contains some non-zero value
      {
      // do something with the item that the pointer points to, for example
      *pItemArray = *pItemArray + 1; // add 1 to the item
      pItemArray++; // update the pointer to point to the next item
      } // and continue the loop

      Veni, vidi, abiit domum

      1 Reply Last reply
      0
      • T tgsb

        Hello....I am learning C and C++ and I find pointer as a very tough topic. Its really very hard to understand its key points. I want to know is there any difference in pointers of C and C++? And also how can I learn this topic easily.Thanks.

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        akstgsb wrote:

        nd I find pointer as a very tough topic. And also how can I learn this topic easily.

        You can't. You are already finding it tough so it is going to be tough until you finally (hopefully) get it. It might help to find different sources and read different explanations of it. Or not. If it helps any when I first encountered pointers it took me about a year to really get them.

        1 Reply Last reply
        0
        • T tgsb

          Hello....I am learning C and C++ and I find pointer as a very tough topic. Its really very hard to understand its key points. I want to know is there any difference in pointers of C and C++? And also how can I learn this topic easily.Thanks.

          enhzflepE Offline
          enhzflepE Offline
          enhzflep
          wrote on last edited by
          #4

          Simple. Learn ASM - then pointers will be the least of your concerns! No, on a serious note (although, I am only 1/2 joking) - as jschell says, they're a tricky topic for most. There really isn't a direct counterpart in the physical world. You either get them, or you dont. (or you think you do, but dont :laugh: ) One way to think of them may be to consider a pointer as a single entry in either the Table Of Contents or Index of a book. The pointer in itself doesn't tell you what the data is, it merely tells you where to find it. - The analogy breaks-down however, when you consider that the pointer doesn't tell you what it holds. Whereas the book-based counterparts tell you where to find the information, and give you a good clue as to what they hold. An image of linked-lists may help for the concept of pointers to take root in your mind.

          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