Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define N 20
- struct str
- {
- char imie[N], nazw[N];
- int wiek;
- };
- int czy_dalej();
- int main()
- {
- FILE *fle;
- fle=fopen("t.txt","wt");
- while (czy_dalej())
- {
- struct str str1;
- //if (czy_dalej()){fclose(fle); return 0;}
- printf("\nPodaj imie: ");
- scanf("%s", str1.imie);
- realloc(str1.imie,strlen(str1.imie));
- printf("\nPodaj nazwisko: ");
- scanf("%s", &str1.nazw);
- realloc(str1.nazw,strlen(str1.nazw));
- printf("\nPodaj wiek: ");
- scanf("%d", &str1.wiek);
- fprintf(fle, "%s %s %d\n", str1.imie, str1.nazw, str1.wiek);
- }
- fclose(fle);
- return 0;
- }
- int czy_dalej() //cos zepsute (nie pozwala na wpisanie litery drugi raz)
- {
- char x;
- printf("Czy dalej? (Y,N): ");
- scanf("%c", &x);
- if ((x=='y')||(x=='Y')) return 1;
- else return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment