fork download
  1. #include <stdio.h>
  2.  
  3. // 구조체 정의
  4. typedef struct {
  5. int x;
  6. int y;
  7. } Point;
  8.  
  9. // 함수 선언 (포인터 표기법 사용)
  10. void printPoints(Point* pointsArray, int idx)
  11. {
  12. printf("x = %d, y = %d\n", pointsArray[idx].x, pointsArray[idx].y);
  13. }
  14.  
  15. int main() {
  16. // 구조체 배열 생성 및 초기화
  17. Point arr[] = {{10, 20}, {30, 40}, {50, 60}};
  18.  
  19. // 함수 호출 시 배열 이름과 크기 전달
  20. printPoints(arr, 2);
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
x = 50, y = 60