Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


getting segmentation fault error in C++

Vaibhav GuptaVaibhav Gupta bangaloreMember Posts: 1

getting segmentation fault in C++ code
I am new to c++, working on my company's assignment my c++ code is giving me segmentation fault error, even debug is not detecting the exact error, please help me in this.


FetchingAndSortingFiles *fileParamToSort;
std::vector l_vecOfFileSortingOrderValues;
ABL_String m_lobName; //ABL_String is defined in framework ,it's just std::string
ABL_String m_CategoryName;
ABL_String m_langName;
ABL_String m_filename;
int m_numOfPages;
unsigned int m_parentAccountCode;
unsigned int m_childAccountCode;
unsigned int m_postalCode;
ABL_String filename;
ABL_String m_dirname;
std::vector l_unsortedFileList;


//mb_process() I am calling from main function from another file.
bool FetchingAndSortingFiles::mb_process()
// in below function I am fetching 3 files, , and storing in l_unsortedFileList vector


std::cout<<"l_unsortedFileListSize======="<<l_unsortedFileList.size()<<std::endl; //giving size 3

// allocating the memory equivalent to the size of vector,i think here i am committing the some mistake
fileParamToSort=new FetchingAndSortingFiles[l_unsortedFileList.size()];
for (int m_ifileIndex = 0; m_ifileIndex < l_unsortedFileList.size(); m_ifileIndex++)
filename =(l_unsortedFileList[m_ifileIndex]);
std::cout<<" filename====="<< filename<<std::endl; //giving first file which is
//in below function mb_extractDelimitedValues I am taking file one by one and segregating them based on delimiter ''
for example- if i take first file GSM_GOVT_ALL_12341_4158_103 then segregating them through delimeter '
' and then storing GSM ,GOVT ,ALL, 12341,4158,103 in vector l_vecOfFileSortingOrderValues like below
l_vecOfFileSortingOrderValues = FetchingAndSortingFiles::mb_extractDelimitedValues(filename,'_');
//in below code i am retreiving the values GSM ,GOVT ,ALL, 12341,4158,103 and so on from vector and storing them in fileParamToSort pointer ,m_direcDate,numOfPages values i am getting from another functions
if (l_vecOfFileSortingOrderValues.size() ==6)
fileParamToSort[m_ifileIndex].m_lobName = l_vecOfFileSortingOrderValues[0].mb_getSTLString();
fileParamToSort[m_ifileIndex].m_CategoryName = l_vecOfFileSortingOrderValues[1].mb_getSTLString();
fileParamToSort[m_ifileIndex].m_langName = l_vecOfFileSortingOrderValues[2].mb_getSTLString();
fileParamToSort[m_ifileIndex].m_parentAccountCode =atoi(( l_vecOfFileSortingOrderValues[3].mb_getSTLString()).c_str());
fileParamToSort[m_ifileIndex].m_childAccountCode = atoi((l_vecOfFileSortingOrderValues[4].mb_getSTLString()).c_str());
fileParamToSort[m_ifileIndex].m_postalCode = atoi((l_vecOfFileSortingOrderValues[5].mb_getSTLString()).c_str());
fileParamToSort[m_ifileIndex].m_numOfPages =numOfPages;

*m_ABL_ServicePtr<< DEBUG <<"file "<<filename<<"is not in correct format"<<Endl;
delete [] fileParamToSort;
return false;
}//for loop ends

in destructor in same file

delete [] fileParamToSort;


Segmentation fault (core dumped)

Sign In or Register to comment.