Advertisement
Guest User

Untitled

a guest
May 29th, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. /* lab5.c */
  2. // taken from Thinking in C by Chuck Allison
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. #define MAXEMPS 10
  7.  
  8. struct Employee {
  9. char last[16];
  10. char first[11];
  11. char title[16];
  12. int salary;
  13. };
  14.  
  15. int main() {
  16. struct Employee emps[10];
  17. int n, i;
  18.  
  19. for (n = 0; n < MAXEMPS; ++n) {
  20. printf("Enter last: "); fflush(stdout);
  21. gets(emps[n].last);
  22. if (strlen(emps[n].last) == 0)
  23. break;
  24. printf("Enter first: "); fflush(stdout);
  25. gets(emps[n].first);
  26. printf("Enter title: "); fflush(stdout);
  27. gets(emps[n].title);
  28. printf("Enter salary: "); fflush(stdout);
  29. scanf("%d", &emps[n].salary);
  30. getchar(); /* eat newline */
  31. }
  32.  
  33. for (i = 0; i < n; ++i)
  34. printf("{%s,%s,%s,%d}\n",
  35. emps[i].last,
  36. emps[i].first,
  37. emps[i].title,
  38. emps[i].salary);
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement