Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct note
- {
- char name[30];
- int bday[3];
- long tele;
- };
- int main()
- {
- FILE *f1;
- struct note blocknote[8];
- int i, check=0;
- char buff[3];
- long num;
- if(f1 = fopen("f1.txt", "r"))
- {
- printf("File is open.\n");
- for(i=0; i<8; i++)
- {
- printf("======================================\n");
- fgets(blocknote[i].name, 30, f1);
- printf("Name: ");
- puts(blocknote[i].name);
- fscanf(f1, "%d %d %d", &blocknote[i].bday[0], &blocknote[i].bday[1], &blocknote[i].bday[2]);
- printf("Birthday: %d.%d.%d ", blocknote[i].bday[0], blocknote[i].bday[1], blocknote[i].bday[2]);
- fscanf(f1, "%li", &blocknote[i].tele);
- printf("\nTelenumber: +7(961)_%li\n", blocknote[i].tele);
- fgets(buff, 2, f1);
- printf("======================================\n");
- }
- }
- printf("All persons: \n");
- for(i=0; i<8; i++)
- {
- printf("%d\n", blocknote[i].tele);
- }
- printf("Find person (throghout num): ");
- scanf("%li", &num);
- printf("======================================\n");
- for(i=0; i<8; i++)
- {
- if(num == blocknote[i].tele)
- {
- printf("Name: ");
- puts(blocknote[i].name);
- printf("Birthday: %d.%d.%d ", blocknote[i].bday[0], blocknote[i].bday[1], blocknote[i].bday[2]);
- printf("\n");
- check = 1;
- }
- }
- if(check==0)
- {
- printf("Not exist.\n");
- }
- printf("======================================\n");
- return 0;
- }
Add Comment
Please, Sign In to add comment