이 코드 섹션에서 잘못된 널 포인터 오류가 발생합니다. 나는 그것이 문자열과 관련이 있다고 추측하고 있지만, 최근에야 그들에 대해 배웠기 때문에 문제를 발견 할 수 없습니다. 사전에 어떤 도움Null 포인터가 잘못되었습니다 - C++
#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();
}
}
감사 :
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에서 디버그 라인입니다.
편집 : 오류가 Return 문에서 발생하고 xstring에서 추출 할 때 노란색 화살표가 ":: _ CrtDbgBreak();"를 가리키고 있습니다.
편집 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
스택 트레이스의 맨 위를 보여주는 것은 완전히 쓸모가 없습니다. 원본 라인은 무엇입니까? –
전체 스택 추적을 표시하십시오. 우리는 무엇이'_CrtDbgBreak()'인지, 무엇이 _that_ 함수인지 등을 알아야합니다. –