我正在处理一个带有行链表的文件,每个节点看起来像这样:
struct TextLine{
//The actual text
string text;
//The line number of the document
int line_num;
//A pointer to the next line
TextLine * next;
};
text
我正在编写一个函数,通过调用如下函数在变量中找到的行的开头添加空格linelist_ptr->text.insert(0,1,'\t');
该程序可以编译,但是当我运行它时,出现此错误:
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::at
Aborted
有任何想法吗?