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. C++ Newbie question

C++ Newbie question

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasec++help
7 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.
  • K Offline
    K Offline
    kaminem
    wrote on last edited by
    #1

    hi all Can you please help me with this basic pb I have a structure struct NameAndCode { char fName[10] ; long fCode ; } ; after an sql query I get a list of NameAndCode NameAndCode **list How can I add a new NameAndCode in the end of the list ? :doh: :doh: Thanks for help

    T S 2 Replies Last reply
    0
    • K kaminem

      hi all Can you please help me with this basic pb I have a structure struct NameAndCode { char fName[10] ; long fCode ; } ; after an sql query I get a list of NameAndCode NameAndCode **list How can I add a new NameAndCode in the end of the list ? :doh: :doh: Thanks for help

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      do you use any STL containers by any chance ? also, why do you use a pointer of pointer if you have a simple "list" ? see if you can use std::vector<NameAndCode> instead

      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      K 1 Reply Last reply
      0
      • K kaminem

        hi all Can you please help me with this basic pb I have a structure struct NameAndCode { char fName[10] ; long fCode ; } ; after an sql query I get a list of NameAndCode NameAndCode **list How can I add a new NameAndCode in the end of the list ? :doh: :doh: Thanks for help

        S Offline
        S Offline
        Saurabh Garg
        wrote on last edited by
        #3

        Can you tell us what "list" are you using? -Saurabh

        K 1 Reply Last reply
        0
        • S Saurabh Garg

          Can you tell us what "list" are you using? -Saurabh

          K Offline
          K Offline
          kaminem
          wrote on last edited by
          #4

          Hi it's a pointer of pointer (NameAndCode **list)

          M 1 Reply Last reply
          0
          • T toxcct

            do you use any STL containers by any chance ? also, why do you use a pointer of pointer if you have a simple "list" ? see if you can use std::vector<NameAndCode> instead

            [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

            K Offline
            K Offline
            kaminem
            wrote on last edited by
            #5

            Hi STL seems more familar for me but does it mean, it's impossible to add a structure at the end of a pointer of pointer ? hope you see my pb thx for help

            T 1 Reply Last reply
            0
            • K kaminem

              Hi it's a pointer of pointer (NameAndCode **list)

              M Offline
              M Offline
              markkuk
              wrote on last edited by
              #6

              That's not a list. It might be a pointer to an array of pointers. You need to see the documentation of whatever API that gives you that pointer to ponter.

              1 Reply Last reply
              0
              • K kaminem

                Hi STL seems more familar for me but does it mean, it's impossible to add a structure at the end of a pointer of pointer ? hope you see my pb thx for help

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                there are several points I don't get. first, you didn't answered my previous question : why do you use a pointer of pointer if you have a simple "list" ? also, if you're familiar with STL, why not using it ? and to answer your question (which I don't think is the good design to follow though), no it's impossible to litteraly "add a structure at the end of a pointer to pointer". for that, you'll have to allocate a new area with a size of "last array"+1, then copy every old pointers address into the new "list", and add the pointer to your new struct at the end of the list. at last, don't forget to delete the old array. but I still think you'd better use a vector. the std::vector::push_back() function will do this transparently for you...

                [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                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