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. what is zed doing here?

what is zed doing here?

Scheduled Pinned Locked Moved C / C++ / MFC
databasequestion
11 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.
  • A Alex Sturza

    in this code?from where i need to understand that is deleting something? void Database_delete(struct Connection *conn, int id) { struct Address addr = {.id = id, .set = 0}; conn->db->rows[id] = addr;

    CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #2

    As far as I know, this is not valid C++ code.

    THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

    In testa che avete, signor di Ceprano?

    A 1 Reply Last reply
    0
    • CPalliniC CPallini

      As far as I know, this is not valid C++ code.

      THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

      A Offline
      A Offline
      Alex Sturza
      wrote on last edited by
      #3

      this is C code!!!

      CPalliniC 1 Reply Last reply
      0
      • A Alex Sturza

        in this code?from where i need to understand that is deleting something? void Database_delete(struct Connection *conn, int id) { struct Address addr = {.id = id, .set = 0}; conn->db->rows[id] = addr;

        J Offline
        J Offline
        jeron1
        wrote on last edited by
        #4

        This[^] thread might help. It looks as though there are members of the Address struct one called set and it's getting initialized to 0, and another called id and it's getting initialized to the given integer id.

        "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst

        A 1 Reply Last reply
        0
        • J jeron1

          This[^] thread might help. It looks as though there are members of the Address struct one called set and it's getting initialized to 0, and another called id and it's getting initialized to the given integer id.

          "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst

          A Offline
          A Offline
          Alex Sturza
          wrote on last edited by
          #5

          yes,but by the name of function says(database_delete),this function must delete something,and i don't know how it is deleting something

          J 1 Reply Last reply
          0
          • A Alex Sturza

            yes,but by the name of function says(database_delete),this function must delete something,and i don't know how it is deleting something

            J Offline
            J Offline
            jeron1
            wrote on last edited by
            #6

            Just a guess, perhaps set is some kind of flag marking a record as inactive or something, as opposed to actually deleting a record. What a functions name is and what it actually does may be two different things. What's needed here I believe is some useful comments.

            "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst

            A 1 Reply Last reply
            0
            • J jeron1

              Just a guess, perhaps set is some kind of flag marking a record as inactive or something, as opposed to actually deleting a record. What a functions name is and what it actually does may be two different things. What's needed here I believe is some useful comments.

              "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst

              A Offline
              A Offline
              Alex Sturza
              wrote on last edited by
              #7

              can i give you the entire code?maybe you will find my answer:)

              1 Reply Last reply
              0
              • A Alex Sturza

                in this code?from where i need to understand that is deleting something? void Database_delete(struct Connection *conn, int id) { struct Address addr = {.id = id, .set = 0}; conn->db->rows[id] = addr;

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #8

                This ties into the code you posted below. Specifically, it's related to this method:

                void Database_set(struct Connection *conn, int id, const char *name, const char *email)
                {
                struct Address *addr = &conn->db->rows[id];
                if(addr->set) die("Already set, delete it first");

                addr->set = 1;

                Basically, it looks like it's controlling whether or not you've already set the value in this row - so, to set a value here, you would call Database_delete first, which changes the value in id from 1 to 0, which means that the rest of Database_set can continue.

                A 1 Reply Last reply
                0
                • A Alex Sturza

                  this is C code!!!

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #9

                  Yes, you are right. :-O

                  THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

                  In testa che avete, signor di Ceprano?

                  1 Reply Last reply
                  0
                  • P Pete OHanlon

                    This ties into the code you posted below. Specifically, it's related to this method:

                    void Database_set(struct Connection *conn, int id, const char *name, const char *email)
                    {
                    struct Address *addr = &conn->db->rows[id];
                    if(addr->set) die("Already set, delete it first");

                    addr->set = 1;

                    Basically, it looks like it's controlling whether or not you've already set the value in this row - so, to set a value here, you would call Database_delete first, which changes the value in id from 1 to 0, which means that the rest of Database_set can continue.

                    A Offline
                    A Offline
                    Alex Sturza
                    wrote on last edited by
                    #10

                    i understand now,thank you very much!

                    P 1 Reply Last reply
                    0
                    • A Alex Sturza

                      i understand now,thank you very much!

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #11

                      You're welcome. :-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