#include <stdio.h>
#include <stdlib.h>
struct Point {
int x;
int y;
};
void PrintPoint(Point* p) {
printf("(%d, %d)\n", p -> x, p -> y);
}
int main() {
Point pt = { 2,3 };
Point pt2 = { -1, 3 };
Point* p = &pt;
PrintPoint(&pt);
PrintPoint(&pt2);
}
//#include <stdio.h>
//#include <stdlib.h>
//
//struct Point {
//
// int x;
// int y;
//};
//
//void PrintPoint(Point pt) {
// printf("(%d, %d)\n", pt.x, (&pt)->y);
//}
//
//int main() {
// Point pt = { 2,3 };
// Point pt2 = { -1, 3 };
// Point* p = &pt;
//
// PrintPoint(pt);
// PrintPoint(pt2);
//
//
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//struct Point {
//
// int x;
// int y;
//};
//
//void PrintPoint(Point pt) {
// printf("(%d, %d)\n", pt.x, (&pt)->y);
//}
//
//int main() {
// Point pt = { 2,3 };
// Point* p = &pt;
//
// PrintPoint(pt);
// printf("(%d, %d)\n", (*p).x, p->y);
// //printf("(%d, %d)\n", *p.x, p->y); // 에러 발생: "."연산자보다 우선순위가 낮아 참조불가
//
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//struct Point {
// int x;
// int y;
//};
//
//int main() {
// Point pt = { 2,3 };
// Point* p = &pt;
//
// printf("(%d, %d)\n", pt.x, (& pt)->y);
// printf("(%d, %d)\n", (*p).x, p->y);
// //printf("(%d, %d)\n", *p.x, p->y); // 에러 발생: "."연산자보다 우선순위가 낮아 참조불가
//
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//struct Point {
// int x;
// int y;
//};
//
//int main() {
// Point pt = { 2,3 };
// Point* p = &pt;
//
// printf("(%d, %d)\n", pt.x, pt.y);
// printf("(%d, %d)\n", p->x, p->y);
//
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//struct Point {
// int x;
// int y;
//};
//
//int main() {
// Point pt = { 2,3 };
// printf("(%d, %d)\n", pt.x, pt.y);
//
// printf("%p %\p\n", &pt, &pt + 1); // pt는 8바이트의 변수
// printf("%p\n", &pt.x);
// printf("%p\n", &pt.y);
// Point* p1 = &pt;
// int* p2 = &pt.x;
//
//
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//struct Point {
// int x;
// int y;
//};
//
//int main() {
// int n = 10;
// Point pt = { 2,3 };
//
// printf("%d\n", n);
// printf("(%d, %d)\n", pt.x, pt.y);
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//void AssignAddress(int** pp, int* pdata) {
// *pp = pdata;
//}
//
//int main() {
//
//
// int a = 10;
// int b = 20;
// int* p = NULL;
// AssignAddress(&p, &b);
//
// printf("data : %d\n", *p);
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//void AllocIntArray(int** pa, int capacity) {
// *pa = (int*)malloc(sizeof(int) * capacity);
//}
//
//void InitIntArray(int* pa, int size) {
// for (int i = 0; i < size; ++i)
// pa[i] = i + 1;
//}
//
//void PrintIntArray(int* pa, int size) {
// for (int i = 0; i < size; ++i)
// printf("data : %d\n", pa[i]);
//}
//
//void FreeIntArray(int* pa) {
// free(pa);
//}
//int main() {
//
//
// int* pa = NULL;
//
// InitIntArray(pa, 10);
// PrintIntArray(pa, 10);
// FreeIntArray(pa);
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//int* AllocIntArray(int capacity) {
// return (int*)malloc(sizeof(int) * capacity);
//}
//
//void InitIntArray(int* pa, int size) {
// for (int i = 0; i < size; ++i)
// pa[i] = i + 1;
//}
//
//void PrintIntArray(int* pa, int size) {
// for (int i = 0; i < size; ++i)
// printf("data : %d\n", pa[i]);
//}
//
//void FreeIntArray(int* pa) {
// free(pa);
//}
//int main() {
//
//
// int* pa = AllocIntArray(10);
//
// InitIntArray(pa, 10);
// PrintIntArray(pa, 10);
// FreeIntArray(pa);
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//int* AllocInt() {
// return (int*)malloc(sizeof(int));
//}
//double* AllocDouble() {
// return (double*)malloc(sizeof(double));
//}
//
//void SetInt(int* p, int data) {
// *p = data;
//}
//
//void SetDouble(double* p, double data) {
// *p = data;
//}
//
//void PrintInt(int data) {
// printf("int : %d\n", data);
//
//}
//
//void PrintDouble(double data) {
// printf("double : %g\n", data);
//
//}
//
//void FreeInt(int* data) {
// free(data);
//}
//void FreeDouble(double* data) {
// free(data);
//}
//
//int main() {
// int* pa = NULL;
// double* pb = NULL;
// // CRUD(create, read, update, delete)
// pa = AllocInt();
// pb = AllocDouble();
// SetInt(pa, 10);
// SetDouble(pb, 3.14);
// PrintInt(*pa);
// PrintDouble(*pb);
// FreeInt(pa);
// FreeDouble(pb);
//
//
//}
//#include <stdio.h>
//#include <stdlib.h>
//
//int main() {
// int* pa = NULL;
// double* pb = NULL;
// pa = (int*)malloc(sizeof(int));
// pb = (double*)malloc(sizeof(double));
// *pa = 10;
// *pb = 3.14;
// printf("int : %d\n", *pa);
// printf("double : %g\n", *pb);
// free(pa);
// free(pb);
//
//}