이번 시간 학습할 내용
- "typedef"를 이용하여 새로운 자료형인 POINT를 선언한 프로그램이다.
- 상세 코드 -
#include
#include
#include
#include
#include
#include
typedef struct point {
int x;
int y;
}POINT;
POINT translate(POINT p, POINT delta);
int main()
{
POINT p = { 2, 3 };
POINT delta = { 10, 10 };
POINT result;
result = translate(p, delta);
printf("새로운 점의 좌표는 (%d, %d)입니다.\n", result.x, result.y);
return 0;
}
POINT translate(POINT p, POINT delta)
{
POINT new;
new.x = p.x + delta.x;
new.y = p.y + delta.y;
return new;
}
출력 화면
이해가 안가시는 부분이 있으면 질문남겨주세요!
'Programming > C언어 학습기' 카테고리의 다른 글
C언어 학습기[18 - 문자열 복사는 한 문자씩!!] (0) | 2019.06.16 |
---|---|
C언어 학습기[17 - 점과 점사이의 거리계산(구조체 활용)] (0) | 2019.06.16 |
C언어 학습기[16 - 3X3 행렬의 곱셈구하기] (0) | 2019.06.16 |
C언어 학습기[15 - 입력한 정수까지의 소수 출력 프로그램] (0) | 2019.05.26 |
C언어 학습기[14 - 1부터 100까지의 소수 판별] (0) | 2019.05.26 |