fork download
  1. // 구조체 함수의 반환값
  2.  
  3. #include<stdio.h>
  4. #include<string.h>
  5. #define _CRT_SECURE_NO_WARNINGS;
  6. struct student {
  7. int sno, age;
  8. char name[10];
  9. };
  10.  
  11. struct student becoming(); // 사용자 정의 함수
  12.  
  13. int main(void) {
  14. struct student a;
  15.  
  16. a = becoming(); // 구조체 함수 호출
  17.  
  18. printf("학번 : %d\n성명 : %s\n나이 : %d\n", a.sno, a.name, a.age);
  19.  
  20. return 0;
  21. }
  22.  
  23. struct student becoming() {
  24. struct student s;
  25. s.sno = 20235678;
  26. strcpy(s.name, "이겨레");
  27. s.age = 25;
  28. return s;
  29. }
Success #stdin #stdout 0s 4876KB
stdin
Standard input is empty
stdout
학번 : 20235678
성명 : 이겨레
나이 : 25