c++ - exception handling -
i following core dump msg:
terminate called after throwing instance of 'std::out_of_range' what(): basic_string::substr abort - core dumped
i reading 14 digit hexadecimal number large file. periodically notice there these blank lines (well not sure is. how handle exception? maybe try catch thingy? looks below:
123456789abcde 123456789abcde 123456789abcde 123456789abcde
i not sure hidden symbol occupying space causing issues , not sure how handle this..any ideas? maybe sample of how handle it?
you need post more code exception looks you're reading file line line , storing line in std::string
, calling std::string::substr()
extract 14 characters want.
assuming code looks this:
std::string str; /* lines stored in string */ std::string substring; /* extracted substring stored here */ /* read file line line */ // ... substring = str.substr( index, 14 ); //extract 14 characters starting @ 'index'
change to:
if( str.size() > index ) { substring = str.substr( index, 14 ); }
Comments
Post a Comment