Program language/C

[C] 구조체 화살표연산자 이용해서 대소 비교하기

COSMOSRKSI 2021. 4. 5. 18:15

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct employee {
char name[10];
int year;
int pay;

}; //lee, kim;

void main()
{
struct employee lee;
struct employee kim;

struct employee* leeptr = &lee;
struct employee* kimptr = &kim;

leeptr->year = 2015;
kimptr->year = 2014;

if (leeptr->year > kimptr->year)
printf("lee is senior\n");
else
printf("kim is senior\n");
}