Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h> //brchkalebis magivrad shegidzlia <>c
- #include <string.h>
- //studentis struqtura
- struct STUD
- {
- char name[100];
- char surname[100];
- char date[100];
- int age;
- int gpa;
- __int64 id;
- };
- #define REGISTRATION 1 //preprocesoria, mexsierebashi arafers ar vwert
- #define SEARCH 2 //preprocesori nishnavs kompilatortan rom vmushaobt
- //# includes dros exe failis damzadebisas includedan rasac vigeb zedmets
- // gadakris kompilatori da rac schirdeba im funqciebs chaakerebs
- //
- //a.name ar chamoshlis tu ertxel mainc ar build an compile
- void main() {
- char[100] filename = "sdb.qnt";
- int state = 0;
- struct STUD a;
- memset((void*)&a, 0, sizeof(struct STUD));
- state = REGISTRATION;
- if (state == REGISTRATION) {
- strcpy(a.name, "saxeli");
- strcpy(a.surname, "gvari");
- strcpy(a.date, "12/12/2012");
- a.age = 17;
- a.gpa = 57;
- FILE *hf = 0;
- hf = fopen(filename, "a");
- for (int k = 0; k < 10000; k++)
- {
- sprintf(a.name, "sax_%d", k);
- sprintf(a.surname, "gvari_%d", k);
- sprintf(a.date, "%d/%d/%d", k % 30, k % 12, 1990 + k % 10);
- a.id = 1000000 + k;
- a.gpa = 40 + k % 50;
- a.age = 1990 + k % 10;
- fwrite(&a, sizeof(struct STUD), 1, hf);
- //fwrite("2423423", 7, 1, hf);
- //ujra aigos iqedan
- //struqturas gadavcemt. vadzlevt struqturis misamarts da veubnebit ramdeni
- }
- fclose(hf);
- }
- else if (state == SEARCH)
- {
- hf = fopen(filename, "r");
- //fileendoffile - sanam faili ar damtavrdeba
- while (!feof(filename)) {
- //1 bit aris chveni sazomi, 1,..
- fread(&a, sizeof(a), 1, h);
- if (a.age > 18) {
- // %s - strikoni, &I64D - __int64
- printf("%s &s &I64D", a.name, a.surname, a.id);
- }
- }
- fclose(hf);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement