Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct osoby{
- char imie[20];
- char nazwisko[25];
- int wiek;
- };
- int main(){
- int z,i=0,j=0;
- struct osoby *tab;
- tab=(struct osoby*)malloc(sizeof(struct osoby));
- while(1){
- printf("Jesli dodac 1 \nJesli odczytac 2 \nJesli wyjsc 0 \n");
- scanf("%d",&z);
- if(z==0){
- break;
- }
- switch (z){
- case 1:{
- tab=(struct osoby*)realloc(tab,i*sizeof(struct osoby));
- printf("Podaj imie: \n");
- scanf("%s",tab[i].imie);
- printf("Podaj nazwisko: \n");
- scanf("%s",tab[i].nazwisko);
- printf("Podaj wiek: \n");
- scanf("%d",&tab[i].wiek);
- i++;
- break;
- }
- case 2:{
- printf("\n");
- for(j=0;j<i;j++){
- printf("%s %s %d \n",tab[j].imie,tab[j].nazwisko,tab[j].wiek);
- }
- printf("\n");
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement