Thursday, 15 January 2015

c - How can I tell the difference between an initialized struct and an uninitialized struct? -


I am sending student records to sockets. The database sends the number of students to the list to the customer and then sends a record at a time. The problem I am facing is that when there is no student, this list starts with a provisional record. I had thought of adding a new area for those records that if they had a new record or were filled, but this would mean changing a lot of code

to see if it was a record An easy way to check is whether it has been filled or not. Below is the structure for student records.

  typedef struct student {char lname [10], initial, fname [10]; Unsigned long sid; Float GPA; } SREC; Type df structure node {srec student; Ent deleted; Structure node * left; Structure node * correct; } NODE;   

This is started for the initial empty node.

  NODE * lname = calloc (1, sizeof (NODE)); Lname-> Left = null; Lname-> Right = NULL; Lname-> Deleted = 0;   

  1. If your system has zero pointer, zero bit pattern (And this probably does), you do not need any of that code after the caller .

  2. You can track whether a record is started by looking at any area that does not contain a valid zero-zero value. Maybe the lname or cid field?

No comments:

Post a Comment