Я получаю неверную ошибку нулевого указателя из этого раздела кода. Я предполагаю, что это как-то связано со струнами, но, как я только недавно узнал о них, я не могу найти проблему.Invalid Null pointer - C++
string batchCipherFiles()
{
int count(0);
string text, file;
ifstream inputFile;
cout << " How many files do you wish to encrypt?: ";
cin >> count;
for (int i(1) ; i <= count ; ++i)
{
stringstream ss;
ss << "unencrypted" << i << ".txt";
file = ss.str();
inputFile.open(file.c_str(), ios::in);
if (inputFile.fail())
{
cout << "\n An error has occurred.";
}
else
{
while (!inputFile.eof())
{
getline(inputFile, text);
cout << "\n " << file << " = " << text << "\n\n";
int applyCeasarShift(string,string);
applyCeasarShift(text, file);
}
inputFile.close();
}
}
return (0);
}
Вот отладки линия от xstring:
#ifdef _DEBUG
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Debug_message(const wchar_t *message, const wchar_t *file, unsigned int line)
{ // report error and die
if(::_CrtDbgReportW(_CRT_ASSERT, file, line, NULL, message)==1)
{
::_CrtDbgBreak();
}
}
Заранее спасибо за любую помощь.
EDIT: ошибка возникает в операторе Return, а в выписке из xstring желтая стрелка указывает на «:: _ CrtDbgBreak();»
EDIT 2:
xstring:
basic_string(const _Elem *_Ptr)
: _Mybase()
{ // construct from [_Ptr, <null>)
_Tidy();
assign(_Ptr);
}
xutility:
template<class _Ty> inline
void _Debug_pointer(const _Ty *_First, _Dbfile_t _File, _Dbline_t _Line)
{ // test iterator for non-singularity, const pointers
if (_First == 0)
_DEBUG_ERROR2("invalid null pointer", _File, _Line);
}
stdthrow:
#ifdef _DEBUG
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Debug_message(const wchar_t *message, const wchar_t *file, unsigned int line)
{ // report error and die
if(::_CrtDbgReportW(_CRT_ASSERT, file, line, NULL, message)==1)
{
::_CrtDbgBreak();
}
}
Надеюсь, это правильный материал.
, на какой строке происходит ошибка? – Chris
, показывая верхнюю часть stacktrace, абсолютно бесполезен. Какая линия происхождения? –
Просьба показать всю трассировку стека. Нам нужно знать, что называется '_CrtDbgBreak()', и то, что называется _that_ функцией, и так далее. –