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. Structures in VC

Structures in VC

Scheduled Pinned Locked Moved C / C++ / MFC
19 Posts 8 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.
  • J Jose Lamas Rios

    Try being more specific. How is the buffer declared? What's its content? In what format? How is the structure declared? Withouth such details, the answer can only be as vague as your question: Q: how do we copy data from a buffer to a structure? A: you extract pieces of data from the buffer and put them into the appropriate fields of the structure. :) -- jlr http://jlamas.blogspot.com/[^]

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

    now tell me how do we extract peices of data from buffer?

    T 1 Reply Last reply
    0
    • L Lost User

      now tell me how do we extract peices of data from buffer?

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

      see this[^] posted on the forum yesterday... it's quite similar as you extract datas from a buffer...


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      1 Reply Last reply
      0
      • L Lost User

        how do we copy data from a buffer to a structure

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

        we have character data in our main buffer and also we need to pack two bytes of data from our main buffer into 1 byte of data in our small buffer.how we'll do this:mad:

        T 1 Reply Last reply
        0
        • L Lost User

          we have character data in our main buffer and also we need to pack two bytes of data from our main buffer into 1 byte of data in our small buffer.how we'll do this:mad:

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

          hey hey hey, please calm down, otherwise, noboody will help you... moreover, you question is far from being clean... what are those buffers ? i've understood you had only one, and now, you talk of two buffers ! :omg: i think the best way to make us understand is to provide so little schemas (into <pre></pre> tags) and some code... explicit also you question clearly, with what you have, what you want, what don't work and what error messages are sent.


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          L 1 Reply Last reply
          0
          • T toxcct

            hey hey hey, please calm down, otherwise, noboody will help you... moreover, you question is far from being clean... what are those buffers ? i've understood you had only one, and now, you talk of two buffers ! :omg: i think the best way to make us understand is to provide so little schemas (into <pre></pre> tags) and some code... explicit also you question clearly, with what you have, what you want, what don't work and what error messages are sent.


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

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

            :(( actually i'm in office.....n m tensed as well...oki let me explain again that i've read a file and stored its data in buffer righttt! now i have to copy some specific bytes from that buffer to a structure.the thing is that the data in my file is stored in characters.means there is one character at each index.and i have to pick two characters at a time and store it in a structure....right now plzz tell me how we'l do this.......

            C M 2 Replies Last reply
            0
            • L Lost User

              :(( actually i'm in office.....n m tensed as well...oki let me explain again that i've read a file and stored its data in buffer righttt! now i have to copy some specific bytes from that buffer to a structure.the thing is that the data in my file is stored in characters.means there is one character at each index.and i have to pick two characters at a time and store it in a structure....right now plzz tell me how we'l do this.......

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #14

              If you could post your structure, this would help a little bit more. You have to understand that we cannot see what's on your screen so we have to guess what you want to do with the little clues you gave us. Ok, in which 'format' you want to store this two characters ? Is it an integer or a string ? If it is a string, you can simply do that: struct.MyString[0] = Buffer[Index]; struct.MyString[1] = Buffer[Index+1]; If it is an integer, you could do that: char Temp[3]; Temp[0] = Buffer[Index]; Temp[1] = Buffer[Index+1]; Temp[2] = '\0'; struct.MyInt = atoi(Temp); If it doesn't help, try to be more specific and POST CODE !!

              1 Reply Last reply
              0
              • L Lost User

                :(( actually i'm in office.....n m tensed as well...oki let me explain again that i've read a file and stored its data in buffer righttt! now i have to copy some specific bytes from that buffer to a structure.the thing is that the data in my file is stored in characters.means there is one character at each index.and i have to pick two characters at a time and store it in a structure....right now plzz tell me how we'l do this.......

                M Offline
                M Offline
                MailtoGops
                wrote on last edited by
                #15

                Nadia, Could you please provide us your structure prototype?. And I also intersteded in your buffer data?. How they are categorised/delimited from each item? What do you mean by big buffer and small buffer :)? " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan

                T 1 Reply Last reply
                0
                • M MailtoGops

                  Nadia, Could you please provide us your structure prototype?. And I also intersteded in your buffer data?. How they are categorised/delimited from each item? What do you mean by big buffer and small buffer :)? " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan

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

                  enough !!! :mad: there are too many posts on CP Forums that are just reposts of what's just been said right before... Cedric and I already asked what you just posted there. did you bother read the answers before making yours ?


                  TOXCCT >>> GEII power
                  [toxcct][VisualCalc]

                  M 1 Reply Last reply
                  0
                  • T toxcct

                    enough !!! :mad: there are too many posts on CP Forums that are just reposts of what's just been said right before... Cedric and I already asked what you just posted there. did you bother read the answers before making yours ?


                    TOXCCT >>> GEII power
                    [toxcct][VisualCalc]

                    M Offline
                    M Offline
                    MailtoGops
                    wrote on last edited by
                    #17

                    :) What you understood by all your post...:laugh: " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan

                    1 Reply Last reply
                    0
                    • C Cedric Moonen

                      That's a solution but you'll need to be sure that the data in the buffer has the same format as your structure. What I mean is that in your structure, the members will be aligned on a 8 bytes boundary (but you can change that). So, if it is not the case in your buffer, you will have some problems.

                      T Offline
                      T Offline
                      Tim Smith
                      wrote on last edited by
                      #18

                      Alignment can be adjusted and by default uses natual alignment up to 8 byte PODs. VC doesn't use 8 byte alignment. Tim Smith I'm going to patent thought. I have yet to see any prior art.

                      C 1 Reply Last reply
                      0
                      • T Tim Smith

                        Alignment can be adjusted and by default uses natual alignment up to 8 byte PODs. VC doesn't use 8 byte alignment. Tim Smith I'm going to patent thought. I have yet to see any prior art.

                        C Offline
                        C Offline
                        Cedric Moonen
                        wrote on last edited by
                        #19

                        Tim Smith wrote: Alignment can be adjusted and by default uses natual alignment up to 8 byte PODs Yes, that's what I said :). Tim Smith wrote: VC doesn't use 8 byte alignment :doh: Err, pretty sure that it does. I had a bug two years ago because of that (loading data from a file and memcpy it to a struct) and I spent a lot of time to solve it. And it was because of the member struct alignement that was to 8 by default.

                        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