ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • C Program Student Database Using Structures
    카테고리 없음 2020. 2. 29. 13:41

    Sam1Sam1struct student.ptr; - We declared 'ptr' as a pointer to the structure student.ptr = &stud; - We made our pointer ptr to point to the structure variable stud. Thus, 'ptr' now stores the address of the structure variable 'stud'.This is the same which we do while defining a pointer to any other variable.cout name rollno operator to access the members of a structure using a pointer to that structure.Structure to FunctionWe can also pass a structure to a function.There are two methods by which we can pass structures to functions. Passing by Value. Passing by ReferencePassing by ValueIn this, we pass structure variable as an argument to a function. Let's see an example to make it clearer. Roll no: 4Name: RonPhone no: 888888In this example, we are printing roll number, name and phone number of a student using a function. We first declared a structure named student with rollno, name and phone number as its members and 's' as its variable.

    1. C Program Using Functions
    2. Student Database Maharashtra

    C Program Using Functions

    StudentC Program Student Database Using Structures

    Then we assigned the values of roll number, name and phone number to the structure variable s. Just as we pass any other variable to a function, we passed the structure variable 's' to a function 'display'.Now, while defining the function, we passed a copy of the variable 's' as its argument with 'struct student' written before it because the variable which we have passed is of type structure named student. Finally, in the function, we printed the name, roll number and phone number of the structure variable.

    Passing by ReferenceIn passing by reference, the address of a structure variable is passed to a function. In this, if we change the structure variable which is inside the function, the original structure variable which is used for calling the function changes. This was not the case in calling by value. Roll no: 4Name: RonPhone no: 888888This case is similar to the previous one, the only difference is that this time, we are passing the address of the structure variable to the function. While declaring the function, we passed the pointer of the copy 'st' of the structure variable 's' in its parameter. Since the pointer is of a variable of type structure named student, we wrote 'struct student' before the name of the pointer in the argument of the function. In the function, we accessed the members of the pointer using - sign as discussed before.Try to change the value of the variables inside the function in both the cases and see the changes in the real variables.

    Do you have an OS there? If you do, check if there are any native solutions available.

    Mysql, postgresql, sqlite. If there's anything there - check out their docs.If you are on bare metal, read on.I think the best way to start is using a simple hash table, so that you'll have fast query times.U-boot's hashtable may serve you as a good start.Next, you'll need to store that in flash. I'd keep at least two copies of your data for the sake of protection from power outage during write.

    Student Database Maharashtra

    To achieve that you'll need some checksumming to add to your data structure, e.g. See this:Finally, if you have a lot of data and (not so much) flash you'd want to compress the data somehow. I really recommend using heatshrink compression algorithm. It's simple and works even on atmel avrs.

Designed by Tistory.