Skip to content

Instantly share code, notes, and snippets.

@hanjae-jea
Created April 23, 2013 09:09
Show Gist options
  • Save hanjae-jea/5442025 to your computer and use it in GitHub Desktop.
Save hanjae-jea/5442025 to your computer and use it in GitHub Desktop.
[NHN NEXT] 간단한 구조체의 예제와, 구조체의 포인터를 접근하는 간단한 예시를 작성하였다.
#include <stdio.h>
#include <string.h>
typedef struct student{
char name[15];
int number;
float total;
}student;
int main(void)
{
student hanjae, sunghwan;
student* best, point;
best = &sunghwan;
hanjae.number = 131071;
hanjae.total = 3.7;
strcpy( hanjae.name , "한재");
sunghwan.number = 131078;
sunghwan.total = 4.3;
strcpy( sunghwan.name , "성환" );
printf("이름 : %7s %7s\n", hanjae.name, sunghwan.name);
printf("학번 : %7d %7d\n", hanjae.number, sunghwan.number);
printf("총점 : %7f %7f\n", hanjae.total, sunghwan.total);
printf("가장 우수한 학생 --> %s\n", best->name);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment