Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <string>
- #include <cstdio>
- int main() {
- FILE* fp = fopen("notes.txt", "w+");
- setlocale(LC_ALL, ".1251");
- int counter = 0;
- char buf[30];
- struct Note {
- char surname[30] = "Aliaksandr D.Hrakovich";
- char phone[20] = "+375339043057";
- char birth_date[11] = { "19.11.2001" };
- char zodiac[15] = "Scorpio";
- };
- struct Note notes[20];
- struct Note tmp;
- for (int i = 1; i < 5; i++) {
- fwrite(¬es,sizeof(Note),1,fp);
- }
- printf("Surname:\t\t\t\tPhone:\t\t\t\tBirth_date:\t\t\tZodiac:\t\t\t\t\n");
- fclose(fp);
- FILE* fr = fopen("notes.txt", "r");
- while (!feof(fr)) {
- fread(&tmp, sizeof(Note), 1, fr);
- printf("%s\t\t\t", tmp.surname);
- printf("%s\t\t\t", tmp.phone);
- printf("%s\t\t\t", tmp.birth_date);
- printf("%s\n", tmp.zodiac);
- }
- fclose(fr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement