Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct hold {
- int age;
- char name[30];
- };
- void all(){
- struct hold *ptr;
- int i, n;
- printf("Enter the number of persons: ");
- scanf("%d", &n);
- ptr = (struct hold*) malloc(n * sizeof(struct hold));
- for(i = 0; i < n; ++i){
- printf("Enter first name and age respectively: ");
- scanf("%s %d", (ptr+i)->name, &(ptr+i)->age);
- }
- printf("Displaying Information:\n");
- for(i = 0; i < n; ++i)
- printf("Name: %s\tAge: %d\n", (ptr+i)->name, (ptr+i)->age);
- }
- int main(){
- int type;
- printf("Enter type: ");
- scanf("%d", type);
- switch(type){
- case '1':
- all();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement