Advertisement
math230

C Structs

Sep 15th, 2015
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. //http://fresh2refresh.com/c/c-passing-struct-to-function/
  4. struct student
  5. {
  6.             int id;
  7.             char name[20];
  8.             float percentage;
  9. };
  10. void func(struct student record);
  11. int main()
  12. {
  13.             struct student record;
  14. record.id=1;
  15.             strcpy(record.name, "Raju");
  16.             record.percentage = 86.5;
  17. func(record);
  18.             return 0;
  19. }
  20. void func(struct student record)
  21. {
  22.             printf(" Id is: %d \n", record.id);
  23.             printf(" Name is: %s \n", record.name);
  24.             printf(" Percentage is: %f \n", record.percentage);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement