一个小程序的段异常

一个小程序的段错误
C/C++ code
 1 #include<stdio.h>
  2 #include<stdlib.h>
  3 #include<string.h>
  4 #include<time.h>
  5 
  6 struct MSG
  7 {   
  8     char temp[5];
  9     char userno[12+1];
 10     int  accountdate;
 11     char username[10];
 12     char useraddr[100];
 13     char area[10+1];
 14     char tranamt[12+1];
 15     char insertdate[8+1];
 16     int  flag;
 17 };
 18 int main()
 19 {   
 20     struct tm *tblock;
 21     time_t timer;
 22     timer=time(NULL);
 23     tblock=localtime(&timer);
 24     struct MSG *msg;
 25     msg->accountdate=tblock->tm_year+1900;
 26     //printf("now %d\n",msg->accountdate+1900);
 27     printf("now %d\n",tblock->tm_mday);
 28 }


编译之后 执行 出现段错误,问题问题应该出在25行那里,我不知道是什么原因,求大家帮看下。。。

------解决方案--------------------
C/C++ code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct
{
    char temp[5];
    char userno[12+1];
    int accountdate;
    char username[10];
    char useraddr[100];
    char area[10+1];
    char tranamt[12+1];
    char insertdate[8+1];
    int flag;
}MSG;

int main()
{
    struct tm *tblock;
    time_t timer;
    timer=time(NULL);
    tblock=localtime(&timer);
    MSG *msg = NULL;
    msg=(MSG *)malloc(sizeof(MSG));
    msg->accountdate=tblock->tm_year+1900;
    //printf("now %d\n",msg->accountdate+1900);
    printf("now %d\n",tblock->tm_mday);
    return 0;
}