ÀÌ ÇÁ·Î±×·¥Àº Á¦´ë·Î ¼öÇàµÇÁö ¾Ê´Â´Ù.
¾îµð¿¡ ¹®Á¦°¡ ÀÖ´ÂÁö ã¾Æº¸½Ã¿À.
¿À·ù´Â µü ÇÑ °÷¿¡ ÀÖÀ½
Á¤¼ºÈÆ
[ÀϹÝÀûÀÎ µð¹ö±ë ´Ü°è]
- ¿À·ù³ ±Ùó ¾Õ ÂÊ¿¡ breakpoint ¼³Á¤Çؼ ÇØ´ç À§Ä¡¿¡¼ ÇÁ·Î±×·¥ ½ÇÇà ¸ØÃß±â
- ÇØ´ç À§Ä¡¿¡¼ ¸ØÃá ÈÄ¿¡ ¿©·¯ º¯¼ö¸¦ È®ÀÎÇؼ µ¿ÀÛÀÇ ¿À·ù¸¦ ÆľÇÇϱâ
> ¿À·ù¸¦ ÆľÇÇϱâ À§ÇØ ÇÑ ¶óÀξ¿ ¼öÇà Çϱâ (F10 À̳ª F11)
// F10 Àº ÇÔ¼öÀÇ °æ¿ì ÇÔ¼ö ¾ÈÀ¸·Î µé¾î°¡Áö ¾Ê°í ÇÔ¼ö Àüü°¡ ½ÇÇàµÊ
// F11 Àº ÇÔ¼öÀÇ °æ¿ì ÇÔ¼ö ¾ÈÀ¸·Î µé¾î°¡¼ ½ÇÇàÇÔ
> °è¼ÓÀ» ´©¸£¸é ´ÙÀ½ breakpoint ¸¸³¯ ¶§ ±îÁö ½ÇÇà
- ÆÄ¾ÇµÈ ¿À·ù¿¡ µû¶ó¼ ¼Ò½ºÄÚµå ¼öÁ¤Çϱâ
- ¼öÁ¤ÇÑ ÈÄ Á¤»óµ¿ÀÛ ¿©ºÎ È®ÀÎÇϱâ
- Á¤»óµ¿ÀÛ È®ÀÎ ÈÄ ¸ðµç breakpoint ¸¦ Á¦°ÅÇÏ°í ½ÇÇàÇϱâ
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> typedef struct student_info { char name[10]; int height; float weight; } element; typedef struct { element* data; // dataÀº Æ÷ÀÎÅÍ·Î Á¤ÀǵȴÙ. int capacity; // ÇöÀç Å©±â int top; } StackType; // ½ºÅà »ý¼º ÇÔ¼ö void init_stack(StackType* s) { s->top = -1; s->capacity = 1; s->data = (element*)malloc(s->capacity * sizeof(element)); } // °ø¹é »óÅ °ËÃâ ÇÔ¼ö int is_empty(StackType* s) { return (s->top == -1); } // Æ÷È »óÅ °ËÃâ ÇÔ¼ö int is_full(StackType* s) { return (s->top == (s->capacity - 1)); } void push(StackType* s, element item) { if (is_full(s)) { s->capacity *= 2; s->data = (element*)realloc(s->data, s->capacity * sizeof(element)); } s->data[++(s->top)] = item; } // »èÁ¦ÇÔ¼ö element pop(StackType* s) { if (is_empty(s)) { fprintf(stderr, "½ºÅà °ø¹é ¿¡·¯\n"); exit(1); } else return s->data[(s->top)--]; } int main(void) { element e; StackType s; init_stack(&e); int i; for ( i = 0; i<4; i++) { printf("À̸§:"); scanf_s("%s", e.name, sizeof(e.name)); printf("Å°:"); scanf_s("%d", &e.height,sizeof(e.height)); printf("¸ö¹«°Ô:"); scanf_s("%f", &e.weight,sizeof(e.weight)); push(&s, e); } for (i = 0; i < 4; i++) { e = pop(&s); printf("%s %d %f\n", e.name, e.height, e.weight); } free(s.data); return 0; } | cs |