我只是想按照一定的顺序写一个数月的数月。
std::fstream fin(file, std::ios::in | std::ios::binary | std::ios::ate);
if (fin.good())
{
fin.seekg(0, fin.end);
int size_stream = (unsigned int)fin.tellg(); fin.seekg(0, fin.beg);
int pos = (unsigned int)fin.tellg();
//........................<sending the file in blocks
while (true)
{
if (size_stream > 64000)
{
fin.read(buf, 63999);
buf[64000] = '\0';
CString strText(buf);
SendFileContent(userKey,
(LPCTSTR)strText);
size_stream = size_stream - 63999;
pos = pos + 63999;
fin.seekg(pos, std::ios::beg);
}
else
{
fin.read(buf, size_stream);
buf[size_stream] = '\0';
CString strText(buf);
SendFileContent(userKey,
(LPCTSTR)strText); break;
}
}
然后像这样写入数组:
string January = "January";
string February = "February";
string March = "March";
string April = "April";
string May = "May";
string June = "June";
string July = "July";
string August = "August";
string September = "September";
string October = "October";
string November = "November";
string December = "December";
sortedmonths在另一个cs表中初始化。 已排序的月份数组的大小为1022,因为这是读入的月数。
为什么这不起作用?我用Google搜索了空引用异常,但没有发现任何与写入数组有关的内容。
答案 0 :(得分:0)
analyzer.sortedmonths
为空。你必须初始化它:
analyzer.sortedmonths = new string[12];