Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- 백준
- 프로그래머스
- 코딩독학
- 주가예측
- 모의 주식
- 코테
- Reflex
- 자바정리
- Python
- SNS
- 코딩테스트
- 자바
- C++
- 개발
- 코스닥
- 풀스택프레임워크
- backend
- 프로그램
- frontend
- 개발자
- 빅데이터
- java
- 개인프로젝트
- 사물인터넷
- java정리
- 이웃한 칸
- 코딩
- 자바독학
- Project
- 프로그래밍
Archives
- Today
- Total
Creative Code
main.c(구조체- 좌표) 본문
※main.c파일
#include <stdio.h>
#include "point.h"
int main(void)
{
point Point;
int x1;
int y1;
printf("점의 x좌표 : ");
scanf("%d",&x1);
printf("점의 y좌표 : ");
scanf("%d",&y1);
Point.x = x1;
Point.y = y1;
printPoint(&Point);
getLength(&Point);
return 0;
}
※point.h파일
#ifndef POINT_H
#define POINT_H
typedef struct point {
int x;
int y;
}point;
void printPoint(const point *p);
void getLength(const point *q);
#endif
※point.c파일
#include <stdio.h>
#include <math.h>
#include "point.h"
void printPoint(const point *p)
{
printf("좌표 : (%d,%d)\n",p->x,p->y);
}
void getLength(const point *q)
{
double length = (double)(q->x) * (double)(q->x) + (double)(q->y) * (double)(q->y);
length = (double)pow(length,0.5);
printf("길이 : %f \n",length);
}
'C Programming' 카테고리의 다른 글
name.c( 문자열 포인터로 입력) (0) | 2023.08.07 |
---|---|
name.c(scanf로 문자열 입력받기) (0) | 2023.08.07 |
main.c(date) (0) | 2023.08.04 |
main.c(구조체) (0) | 2023.08.04 |
main.c(serial함수) (0) | 2023.08.04 |