我正试图在时间轴上绘制事件.事件相隔几毫秒.如果我将两个事件的时间戳转换为datenum,我会得到不同时间戳的完全相同的结果.请参阅以下输出:
datenum(2011,06,13,15,11,05.500)
ans =
7.3467e+005
datenum(2011,06,13,15,11,06.500)
ans =
7.3467e+005
Run Code Online (Sandbox Code Playgroud)
这两个日期之间的时间相隔一秒.我究竟做错了什么?有没有办法和这样的时间一起工作?
谢谢-Daniel
我的问题涉及继承自ifstream的Bifstream的以下成员函数.Read需要一个char指针.我给它(char*)和目标.target是一个引用,所以我给它的是对int的引用的引用.为什么这样做?
bool cBifstream::ReadInt( int& target ){
if( !this->is_open() ){
return false;
}
this->read( (char*)&target, sizeof(int) );
}
Run Code Online (Sandbox Code Playgroud)
这是我使用的其他工作代码的片段.
int size;
is.read((char*)&size, sizeof(int));
Run Code Online (Sandbox Code Playgroud)
语法是相同的,但这次变量是一个int而不是对int的引用.
目标声明:
cBifstream a("test2");
int b;
a.ReadInt(b);
Run Code Online (Sandbox Code Playgroud)
编辑:谢谢你的回复.我还是不明白一件事.
this->read( (char*)target, sizeof(int) ); (all i did here was remove the ampersand)
Run Code Online (Sandbox Code Playgroud)
此更改导致我的程序崩溃.但是target是对int的引用,所以上面应该有效
int size;
is.read((char*)&size, sizeof(int));
Run Code Online (Sandbox Code Playgroud)
作品.