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. programm crashes wenn retrieving a CString

programm crashes wenn retrieving a CString

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelptutorialquestionannouncement
6 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.
  • W Offline
    W Offline
    Willem B
    wrote on last edited by
    #1

    hi, i've developed a program that puts a struct into a linked list... Wenn i put the new record into my list, and i read it after that, the program crashes(wenn getting the CString)... the problem is that my list is not updated at all... if i read a number that is inserted with the value 3, it has the value -2421523832 wenn retreiving it... now i want to know how to update my list, not that i don't know it at all but my way is not working. i get the pointer(Leverancier) to my struct in the function that updates the list... NewLeverancier = new CLeverancierStruct; NewLeverancier = Leverancier; m_LeveranciersLijst.AddTail(NewLeverancier); should this work? []D [] []D []

    J I 2 Replies Last reply
    0
    • W Willem B

      hi, i've developed a program that puts a struct into a linked list... Wenn i put the new record into my list, and i read it after that, the program crashes(wenn getting the CString)... the problem is that my list is not updated at all... if i read a number that is inserted with the value 3, it has the value -2421523832 wenn retreiving it... now i want to know how to update my list, not that i don't know it at all but my way is not working. i get the pointer(Leverancier) to my struct in the function that updates the list... NewLeverancier = new CLeverancierStruct; NewLeverancier = Leverancier; m_LeveranciersLijst.AddTail(NewLeverancier); should this work? []D [] []D []

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Hi Willen, I asked this very question a couple of days ago. Didn't you undesrstand my reply? If so, I'll gladly try to make myself clearer, if you're so kind as to tell me what you didn't get. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      W 3 Replies Last reply
      0
      • W Willem B

        hi, i've developed a program that puts a struct into a linked list... Wenn i put the new record into my list, and i read it after that, the program crashes(wenn getting the CString)... the problem is that my list is not updated at all... if i read a number that is inserted with the value 3, it has the value -2421523832 wenn retreiving it... now i want to know how to update my list, not that i don't know it at all but my way is not working. i get the pointer(Leverancier) to my struct in the function that updates the list... NewLeverancier = new CLeverancierStruct; NewLeverancier = Leverancier; m_LeveranciersLijst.AddTail(NewLeverancier); should this work? []D [] []D []

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        You need to give us some more information. From the code above it looks like you have a pointer which you set to a new struct instance. You then point it to a previous instance which you add to the list...? It may already be in! You mention strings and numbers without giving us actual facts / definitions. Try something like the following (if you like MFC):

        struct Foo
        {
        int nBar;
        };

        CTypedPtrList FooList;

        Foo *f1 = new Foo;
        Foo *f2 = new Foo;

        f1->nBar = 3;
        f1->nBar = 17;

        FooList.AddTail (f1);
        FooList.AddTail (f2);

        Foo *f = FooList.GetHead ();
        TRACE1("nBar=%i\n", f->nBar);
        f = FooList.GetHead ();
        TRACE1("nBar=%i\n", f->nBar);

        ...

        There are STL equivalents to the above code, but I'm not so confident with STL to rattle out a chunk of code off the top of my head. Iain.

        1 Reply Last reply
        0
        • J Joaquin M Lopez Munoz

          Hi Willen, I asked this very question a couple of days ago. Didn't you undesrstand my reply? If so, I'll gladly try to make myself clearer, if you're so kind as to tell me what you didn't get. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          W Offline
          W Offline
          Willem B
          wrote on last edited by
          #4

          well it didn't work... i made the the struct then i send the pointer to that struct towards the function to safe it in the list... than after that i just want to put it into the linked list... so: you say i have to do this: NewLeverancier /* witch is the new pointer */ = new CLeverancierStruct(*Leverancier /* witch is the pointer to the struct */); m_LeveranciersLijst/* witch is the list */.AddTail(NewLeverancier); []D [] []D []

          1 Reply Last reply
          0
          • J Joaquin M Lopez Munoz

            Hi Willen, I asked this very question a couple of days ago. Didn't you undesrstand my reply? If so, I'll gladly try to make myself clearer, if you're so kind as to tell me what you didn't get. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

            W Offline
            W Offline
            Willem B
            wrote on last edited by
            #5

            okey, i tried it one more time, and it does copy the values of the struct but the problem with the CString still remains.... []D [] []D []

            1 Reply Last reply
            0
            • J Joaquin M Lopez Munoz

              Hi Willen, I asked this very question a couple of days ago. Didn't you undesrstand my reply? If so, I'll gladly try to make myself clearer, if you're so kind as to tell me what you didn't get. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

              W Offline
              W Offline
              Willem B
              wrote on last edited by
              #6

              oke... I'm getting pretty crazy here... it was all a compiler fault... i rebuilt my hole project and guess what: problem solved.... damn those debug files.... thanx for helping me out... []D [] []D []

              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