我正在尝试解析日期时间字符串并将结果放入std :: tm结构中。以下是代码,
#include <iomanip>
#include <ctime>
#include <sstream>
#include <string>
std::stringstream ss;
struct std::tm when;
ss.str("8/14/2015 3:04:23 PM");
ss >> std::get_time(&when, "%m/%d/%Y %r");
运行代码后,when.tm_hour为27.这是一个错误,还是我做错了什么?
我在Windows 7上使用Visual Studio 2013.
感谢。
答案 0 :(得分:4)
您遇到了Microsoft的user@host ~/test $ ls "abc"
abc
函数实现中的错误,特别是部分时间解析AM / PM(import java.io.File;
import java.util.Scanner;
public class Reader {
public static void main(String[] args) {
String text = "";
try {
Scanner x = new Scanner(new File("C:/Documents and Settings/User/Desktop/Counties/Adair_County,_Oklahoma.txt"));
text = x.nextLine();
} catch (Exception e) {
System.out.print("File Not Found");
}
System.out.print(text);
}
}
)的部分:
{{1}}
问题是_Getloctxt返回[0,3]范围内的int而不是预期范围[0,1]中的int。
已向Microsoft声明此ID(ID:808162)并声称已在Visual Studio 2015中修复此错误。