-2
我正在从here获知C中与时间相关的函数。他们证明了使用以下示例的strftime()函数:C中的strftime()函数中的奇怪格式说明符
#include <stdio.h>
#include <time.h>
#define LEN 150
int main()
{
char buf[LEN];
time_t curtime;
struct tm *loc_time;
//Getting current time of system
curtime = time (NULL);
// Converting current time to local time
loc_time = localtime (&curtime);
// Displaying date and time in standard format
printf("%s", asctime (loc_time));
strftime (buf, LEN, "Today is %A, %b %d.\n", loc_time);
fputs (buf, stdout);
strftime (buf, LEN, "Time is %I:%M %p.\n", loc_time);
fputs (buf, stdout);
return 0;
}
我已经在printf的瞪大眼睛大约%米说明符()。它表示%m转换说明符不是C,而是对printf的GNU扩展。 '%m'转换将打印出与errno中的错误代码相对应的字符串。
我知道%一个格式说明符在C99中是新的。它以十六进制形式打印浮点数。
但是这个程序中%b和%I的目的是什么?我不明白%b的用法是什么?我从来没有听说过这个。 %i与%i相同吗?
致OP:阅读任何类型的文档就足够了。例如在这个答案的链接中的手册页。 –