Segmentation fault depending on string length?

后端 未结 2 997
后悔当初
后悔当初 2021-01-27 01:08

I am writing a program that will read lines from an infile using getline into strings, convert the strings to c-strings containing the first m nonwhitespace characters of the st

2条回答
  •  萌比男神i
    2021-01-27 01:25

    I am not sure why the backtrace is pointing to string input; but when you are copying row into map. if mapsize is bigger than the size of row, you could well end up seg-faulting. This will be more common for a bigger mapsize.

    you also may well be stomping over return addresses on the stack that could be causing the "wrong" core-dump.

提交回复
热议问题