void maintainFileName ()
{
std :: ifstream myfile;
myfile.open ("zoomLevels.txt");
if (myfile.is_open ())
{
// Move to end of the file,
myfile.seekg (0, std::ios::end);
// and then six characters back to pick up the last file number.
myfile.seekg (6, std::ios::beg);
int len = 1;
char *t = new char[len];
myfile.read(t, len);
qDebug () << "\nt: " << *t << "\n";
}
else
{
qDebug () << "\nsorry";
}
}
该文件包含以下内容:
78.8115,29.582,1,01.rda
78.8115,29.582,2,02.rda
76.3671,30.2201,1,11.rda
76.3671,30.2201,2,12.rda
78.1908,30.3007,1,01.rda
78.1908,30.3007,2,02.rda
77.3284,29.1415,1,01.rda
77.3284,29.1415,2,02.rda
77.3064,29.1655,1,01.rda
77.3064,29.1655,2,02.rda
该函数返回的值是5
,而倒数第六个字符是0
!
我哪里错了?