点击(此处)折叠或打开

  1. /*
  2.  * =====================================================================================
  3.  *
  4.  * Filename: t.c
  5.  * Version: 1.0
  6.  * Created: 05/25/2012 09:35:49 AM
  7.  * Revision: none
  8.  * Compiler: gcc
  9.  *
  10.  * Author: xutao (xt), butbueatiful@gmial.com
  11.  *         HomePage:     http://butbueatiful.blog.chinaunix.net
  12.  * Company: akaedu.org
  13.  * Copyright: Copyright (c) 2012, xutao
  14.  *
  15.  * Description:
  16.  *
  17.  * =====================================================================================
  18.  */
  19. #include <stdio.h>

  20. struct student {
  21.     int num;
  22.     char *name;
  23.     int score;
  24. } stu;

  25. int main(int argc, char *argv[])
  26. {
  27.     struct student *p = &stu;    
  28.     stu.num = 1;
  29.     (*p).name = "tom";
  30.     p->score = 78;

  31.     printf("num = %d\n", p->num);
  32.     printf("name = %s\n", p->name);
  33.     printf("score = %d\n", p->score);

  34.     return 0;
  35. }

01-11 10:47
查看更多