现在的位置: 首页 > 综合 > 正文

终于解决了,我说程序怎么一直崩溃呢

2013年09月13日 ⁄ 综合 ⁄ 共 666字 ⁄ 字号 评论关闭
Code:
  1. #include <stdio.h>  
  2. #include <conio.h>  
  3. #include <stdlib.h>  
  4. #include <time.h>  
  5. int main ()  
  6. {     
  7.     char ch[80];  
  8.     time_t tn,*p;   //p指向??  
  9.  //   p=(time_t *)malloc(sizeof(time_t));  
  10.     time(p);  
  11.       
  12.     tn=time(0);  
  13.       
  14.     printf("%ld/n%ld/n",tn,*p);   
  15.     struct tm *pt;  
  16.     pt=localtime(&tn);  
  17.     
  18.     printf("%s", asctime(pt));   
  19.     printf("%s",ctime(&tn));  
  20.     printf("%s",ctime(p));  
  21.       
  22.     tn=time(0);  
  23.     pt=localtime(&tn);  
  24.     strftime(ch,80,"This is week %U of the year %Y",pt);  
  25.     puts(ch);  
  26.     getch();  
  27.     return 0;  
  28. }  
  29.   
  30.   
  31. 我擦,一直都没注意指针的问题,知道这次因为程序一直崩溃,才注意了,我说怎么加上char ch[80];程序就会崩溃阿。。。还以为是char ch[80];有问题,果然,错的是我,不是电脑。。。。。  

抱歉!评论已关闭.