fork download
  1. #include <stdio.h>
  2. #define SIZE 5
  3. struct employee
  4. {
  5. char first_name [20]; /* First name */
  6. char last_name [20]; /* Last name */
  7. };
  8. /***************************************************************
  9. **
  10. ** Name: printNames
  11. **
  12. ** Description: Prints the first and last names in an array
  13. **
  14. ** Parameters: myNames - Array of Structures containing names
  15. **
  16. ** Returns: Nothing
  17. **
  18. ****************************************************************/
  19. void printNames (struct employee myNames [ ] )
  20. {
  21. int i; /* loop index */
  22. /* Print first name and then last name */
  23. for (i = 0; i < SIZE; ++i)
  24. {
  25. printf ("%s %s \n", myNames [ i ].first_name,
  26. myNames [ i ].last_name);
  27. }
  28. } /* printNames */
  29. int main()
  30. {
  31. struct employee names [] =
  32. {
  33. { "Connie", "Cobol" },
  34. { "Mary", "Apl" },
  35. { "Frank", "Fortran" },
  36. { "Jeff", "Ada" },
  37. { "Anton", "Pascal" } /* no comma here */
  38. };
  39. printNames ( names );
  40. return (0);
  41. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Connie Cobol 
Mary Apl 
Frank Fortran 
Jeff Ada 
Anton Pascal