
函数: ctime
功 能: 把日期和时间转换为字符串
用 法: char *ctime(const time_t *time)
程序例:
#include<cstdio>
#include<ctime>
intmain(void) //返回值是int类型,用int来指示
{
time_tt //以秒计算
t=time(&t)
printf("Today'sdateandtime:%s\n",ctime(&t))
return0
}
注:若在linux下使用本函数,需要include <time.h>头文件。
CListBox* pList = (CListBox*)GetDlgItem(YOUR_LIST_ID) // 获取你的CListBox对象
// 指针,YOUR_LIST_ID为你的列表框资源ID
pList->ResetContent() // 清空ListBox原有内容
unsigned char uch[] = {188, 199, 200, 204} // 任意个元素的usigned char数组
const int nSize = sizeof(uch) / sizeof(uch[0]) // 获取数组元素个数
char pBuff[5] // 字符串缓存
for(int i = 0 i < nSize i++){
sprintf(pBuff, "%x", uch[i]) // 将usgined char数组元素转换为16进制值,并以字符串形式装入缓存
pList->AddString(pBuff) //添加到ListBox列表中
}
另外请注意:ListBox一般会按字母顺序给你排序后显示
本列中显示结果为:(相信这就是你想要的)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)