This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

time() 在C6457和VC2008里的区别。



第一步: c6457的代码如下,

#include  <time.h>

main()

{

       time_t   t;

       t = time(NULL);

      /* 如果此时掉用 ctime(t), 解析出来的时间是正确的  */

}

第二步: 将第一步中得到的t值放到VC2008里进行解析,VC2008代码如下:

#include  <stdio.h>

#include  <time.h>

main()

{

     // t:  第一步中得到的; 

      printf(“ now time  is  %s\n”,  ctime(&t));

}

此时,显示的时间不对,显示2086等等。两个编译器中time_t的位宽不一样。

请问,dsp中怎么取时间值,才能在vc2008中显示正确呢。

非常谢谢!

 

  • 你好,确定是两个编译器中time_t的位宽不一样引起的吗?

    如果是位宽不一样引起的,把小位宽的数值赋给大位宽的数值,应该没问题的。

  • CCS和VC2008之间没有联系的,但都是用的标准C语言格式。你在VC2008中先做第一步,得到的数值,应该可以解析成功。然后把VC2008中的这个数值和CCS中的这个数值比较一下,看看有什么不同。