读取格式为YYYYMMDD的日期和时间 [英] read a date and time in format YYYYMMDD

查看:343
本文介绍了读取格式为YYYYMMDD的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用fscanf从txt文件中读取格式为YYYYMMDD的日期和时间,而不使用任何符号,例如/或-...如何使用fscanf分隔年,月,日..请帮助我!

i want to read a date and time in format YYYYMMDD without using any symbol such as / or - from txt file using fscanf...how can i seperate year,month, days by using fscanf..please help me!

推荐答案

看看:
http://pleac.sourceforge.net/pleac_cposix/datesandtimes.html [
have a look at :
http://pleac.sourceforge.net/pleac_cposix/datesandtimes.html[^]


指定元素的宽度:
Specify the width for the elements:
int nYear, nMonth, nDay;
fscanf(f, "%4d%2d%2d", &nYear, &nMonth, &nDay);


这篇关于读取格式为YYYYMMDD的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆