C++ で strptime() 関数を使用すると問題が発生します。
以下のようにstackoverflowでコードを見つけました。文字列の時間情報をstruct tmに保存したいと思います。tm tm_year 変数で年情報を取得する必要がありますが、常にゴミが表示されます。誰か助けてくれませんか? 前もって感謝します。
string s = dtime;
struct tm timeDate;
memset(&timeDate,0,sizeof(struct tm));
strptime(s.c_str(),"%Y-%m-%d %H:%M", &timeDate);
cout<<timeDate.tm_year<<endl; // in the example below it gives me 113
cout<<timeDate.tm_min<<endl; // it returns garbage
**string s will be like "2013-12-04 15:03"**