다음 코드는 알파벳이없는 문자열을 찾습니다. 123 인식되어야하며, numberFinder()가이 사실뿐만 아니라 같은 수의 인덱스을 시작 반환하여야한다처럼 mynumber123 인식 할 수 없다 같은 경우와 numberFinder()는 허위 경우 반환해야 .액세스 위반 읽기 위치 0x00000006
생성자 :
for (i;i<m_length;i++)
{
bool UpperCaseBeforeNoFound=false;
if(this->numberFinder (i).second)
{
//do some calculations.
}
}
: 텍스트 파일 어딘가에 나는 다음과 같은 코드를 건너 구현에 따라
의 내용을 포함하는 문자열 m_text
를 초기화
CaddressParser::CaddressParser(string fileName) //constructor
{
m_fileName=fileName;
int length=getLength(m_fileName.c_str());
m_text =fileReader(m_fileName.c_str());
m_length=length;
}
numberFinder 함수는 다음과 같이 구현됩니다.
,pair <int,bool> CaddressParser::numberFinder(int counter)
{
bool noFound=isdigit(m_text[counter]); //number found? -> true
if(noFound)
{
int end=HouseNoDigits(counter);
if(((counter-1)>=0) && ((counter +end-1) <m_length))
{
if((!(isalpha(m_text[counter-1]))) && (!isalpha(m_text[counter+end-1])))
{
return make_pair(counter,noFound); //return index if true
}
}
}
else return make_pair(0,noFound);
}
이제 문제는 다음과 같은 텍스트 "he23 시장 거리 런던 Q12 H13"를 포함하는 텍스트 파일입니다. 나는 제목에 언급 된 오류 및 디버거가 포함되어있는 라인에 저를 필요 :이 일어나는 이유를 알아낼 수 없습니다
if(this->numberFinder (i).second)
. 제발 이해해주세요.
들여 쓰기가 읽기 쉽도록 수정하십시오. 감사. –
아마도 "numberFinder"가 NULL을 반환합니다 (또는 'this'는 NULL입니다). –
@ Oli Charlesworth 예! –