怎么将系统时间(年 月 日)以阿拉布数字的形式输入到程序中
如何将系统时间(年 月 日)以阿拉布数字的形式输入到程序中
如何将系统时间(年 月 日)以阿拉布数字的形式输入到程序中?
比如,
int year,month,day;
scanf("%d %d %d",&year,&month,&day);
新手很多要学的
谢谢各路大神
------解决方案--------------------
获取系统日期和时间有很多方法(http://blog.163.com/gao_junfu/blog/static/91177329200962211185037/)。
------解决方案--------------------
------解决方案--------------------
仅供参考
------解决方案--------------------
思路:先获取当前系统的时间,这个库函数中肯定有,然后对这个时间根据需求处理,库函数也很多,具体参看
http://blog.****.net/zlhy_/article/details/8210245 绝对有你用到的函数
------解决方案--------------------
int year,month,day;
scanf("%d %d %d",&year,&month,&day);
這個就很好,輸入用空格隔開,比如:
2013 1 9
顯示的時候要轉為字符串,
char ys[8];
char ms[8];
char ds[8];
printf("%s,%s,%s", itot(year, ys), itoa(month,ms), itoa(day,ds));
char* itoa (int i,char* a)
{
// 這個函數你自己先想想怎麽實現.
return a;
}
如何将系统时间(年 月 日)以阿拉布数字的形式输入到程序中?
比如,
int year,month,day;
scanf("%d %d %d",&year,&month,&day);
新手很多要学的
谢谢各路大神
------解决方案--------------------
获取系统日期和时间有很多方法(http://blog.163.com/gao_junfu/blog/static/91177329200962211185037/)。
------解决方案--------------------
TCHAR FileName[MAX_PATH];
SYSTEMTIME time;
GetLocalTime(&time); //获取当前系统时间
wsprintf(FileName, _T("%u%u%u%u%u%u.txt"),
time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
------解决方案--------------------
仅供参考
#include <afxdisp.h>
#include <stdio.h>
COleDateTime t;
int main(int argc, char **argv) {
if (argc<2) {
printf("Usage:%s \"DateTimeStr\"\n",argv[0]);
return 2;
}
if (t.ParseDateTime(argv[1])) {
printf("\"%s\" is a valid DateTimeStr.\n",argv[1]);
printf("%s\n",t.Format("%Y-%m-%d %H:%M:%S"));
return 0;
} else {
printf("\"%s\" is a INVALID DateTimeStr!\n",argv[1]);
return 1;
}
}
------解决方案--------------------
思路:先获取当前系统的时间,这个库函数中肯定有,然后对这个时间根据需求处理,库函数也很多,具体参看
http://blog.****.net/zlhy_/article/details/8210245 绝对有你用到的函数
------解决方案--------------------
int year,month,day;
scanf("%d %d %d",&year,&month,&day);
這個就很好,輸入用空格隔開,比如:
2013 1 9
顯示的時候要轉為字符串,
char ys[8];
char ms[8];
char ds[8];
printf("%s,%s,%s", itot(year, ys), itoa(month,ms), itoa(day,ds));
char* itoa (int i,char* a)
{
// 這個函數你自己先想想怎麽實現.
return a;
}