fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct the_struct
  5. {
  6. char FirstName[20];
  7. char LastName[32];
  8. char Score[20];
  9. };
  10. int main () {
  11. int i=0,n;
  12. printf("how many students?\n");
  13. scanf("%d",&n);
  14. printf("Reading %d items\n", n);
  15. struct the_struct *ptr[100];
  16.  
  17. while (i < n) {
  18. ptr[i] = malloc(sizeof(struct the_struct));
  19. printf("Enter First Name \n");
  20. scanf("%s",ptr[i]->FirstName);
  21. printf("Enter Last Name \n");
  22. scanf("%s",ptr[i]->LastName);
  23. printf("Enter Score? \n");
  24. scanf("%s",ptr[i]->Score);
  25. printf("%s %s %s\n",ptr[i]->FirstName,ptr[i]->LastName,ptr[i]->Score);
  26. i++;
  27. }
  28. }
  29.  
Success #stdin #stdout 0s 2428KB
stdin
3
hello world one
quick brown fox
jumps over the
stdout
how many students?
Reading 3 items
Enter First Name 
Enter Last Name 
Enter Score? 
hello world one
Enter First Name 
Enter Last Name 
Enter Score? 
quick brown fox
Enter First Name 
Enter Last Name 
Enter Score? 
jumps over the