Advertisement
cd62131

Print Student

Dec 26th, 2013
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct {
  5.   int year;/* 学年 */
  6.   int clas;/* クラス */
  7.   int number;/* 出席番号 */
  8.   char *name;/* 名前 */
  9. } student;
  10.  
  11. void student_print(student *data) {
  12.   printf("year: %d\n", data->year);
  13.   printf("clas: %d\n", data->clas);
  14.   printf("number: %d\n", data->number);
  15.   printf("name: %s\n", data->name);
  16.   return;
  17. }
  18.  
  19. int main(void) {
  20.   student *data = (student *) malloc(sizeof(student));
  21.   data->year = 2013;
  22.   data->clas = 1;
  23.   data->number = 1;
  24.   data->name = "Name1";
  25.   student_print(data);
  26.   return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement