#include <stdio.h>
#include <stdlib.h>
#include "time.h"




void Send_Message_To_Data_Server(struct tm *tm, time_t t)
{
    struct tm *now; //实时时间
    /**打印org处获得的tm(指针),实际指针所指的内容在调用localtime()时被更改了*/
    printf("A:%d %d %d %ld\n",tm->tm_hour,tm->tm_min,tm->tm_sec,t);


    /**转换org处获得的秒数*/
    now = localtime(&t);
    printf("B:%d %d %d %ld\n",now->tm_hour,now->tm_min,now->tm_sec,t);
}




void Send_Message_To_Data_Server_With_Ask(struct tm *tm, time_t t)
{


    time_t timep;
struct tm *now; //实时时间




    int i=0;
    for(i=0;i<3;i++)
    {
        /**C 第2次获取时间**/
        time(&timep);


        now = localtime(&timep);
        printf("C:%d %d %d %ld\n",now->tm_hour,now->tm_min,now->tm_sec,timep);
        Send_Message_To_Data_Server(tm,t);
        sleep(2);


    }


}






int main()
{


    time_t timep;
struct tm *now; //实时时间
    /**org 第一次获取时间**/
    time(&timep);


    now = localtime(&timep);
    printf("ORG:%d %d %d %ld\n",now->tm_hour,now->tm_min,now->tm_sec,timep);
Send_Message_To_Data_Server_With_Ask(now,timep);
    printf("Hello world!\n");
    return 0;
}





输出如图

struct tm *now测试




相关文章:

  • 2022-03-02
  • 2021-07-07
  • 2021-07-27
  • 2021-10-29
  • 2021-11-22
  • 2022-01-19
猜你喜欢
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2022-02-10
相关资源
相似解决方案