C++ reading date into struct -


i risk modeler use sas , sql new c++. currenting studying ios issues , have question date may need guys' help. suppose in txt file there field called origination_date format: mm/dd/yy. purpose read such variable:

struct orig_date {     int oyr;//extract year origination date     int omonth;     int oqtr;//no necessary @ begin     int oday; }; 

what should want? help!

if have choice @ all, don't invent own type task.

c , c++ provide tm struct contains broken-down date , time, along routines convert to/from time_t, , i/o. unless had overwhelming reason otherwise, i'd use that. example, read date in format you've given, use this:

std::tm orig;  std::cin >> std::get_time("%m/%d/%y", &orig); 

the fields you've given available orig.tm_year, orig.tm_mon, , orig.tm_mday.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -