本篇內(nèi)容介紹了“C語言怎么把時間戳轉(zhuǎn)換成時間”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> int isNumber(char * NUM) //check for a number,ture return non-0,false return 0; { int ret = 0; int ct = 0; for (ct=0; ct<strlen(NUM); ct++) { if ((ret = isdigit(NUM[ct])) == 0) { return ret; } } return ret; } int main(int argc, const char * argv[]) { int ret = 0; struct tm *p; time_t tt; char * str = calloc(sizeof(char), 1024); if (argc > 2) { printf("The parameter is only one!!!\n"); ret = 1; goto End; }else if (argc < 2){ printf("The program need a parameter!!!\n"); ret = 2; goto End; } if (isNumber(argv[1]) == 0) { printf("The parameter must be number!!!\n"); ret = 3; goto End; } if (strlen(argv[1]) != 10) { printf("The parameter is not good timestamp!!\n"); ret = 4; goto End; } tt= atoi(argv[1]); p = localtime(&tt); strftime(str, 1024, "%F %T", p); printf("%s\n",str); End: if (str != NULL) { free(str); } if (str != NULL) { free(p); } return ret; }
“C語言怎么把時間戳轉(zhuǎn)換成時間”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
文章標(biāo)題:C語言怎么把時間戳轉(zhuǎn)換成時間-創(chuàng)新互聯(lián)
路徑分享:http://vcdvsql.cn/article14/pjsge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、電子商務(wù)、網(wǎng)站內(nèi)鏈、網(wǎng)站改版、虛擬主機(jī)、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容