printf为啥不打印unsigned short?
测试之前一个哥们的面试题,碰到这么一个问题
VS express 2012 for Windows Desktop
Console Application
#include "stdafx.h"
#include <iostream>
#include <sys/types.h>
#include <sys/timeb.h>
#include <time.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i;
struct timeb t1 = {0}, t2 = {0};
void *p = malloc(1024*1024*1024);
ftime(&t1);
memset(p, 'A', 1024*1024*1024);
ftime(&t2);
printf("%d.%hu\n", t1.time, t1.millitm);
cout << t1.time << '.' << t1.millitm << endl;
printf("%d.%03hu\n", t2.time, t2.millitm);
cout << t2.time << '.' << t2.millitm << endl;
printf("%ld.%d\n", t2.time - t1.time, t2.millitm - t1.millitm);
cout << t2.time - t1.time << '.' << t2.millitm - t1.millitm << endl;
cin >> i;
}
1364596105.0
1364596105.479
1364596105.000
1364596105.618
0.0
0.139