errors.txt

来自「ssd5 recommended exe2,答案绝对正确」· 文本 代码 · 共 14 行

TXT
14
字号
"string new_word_list = *(new string[2 * capacity]);" is wrong, I modify it to "string* new_word_list = new string[2 * capacity];" To keep the new_word_list beginning address, I add the line"string *p=new_word_list;" to call later.


"new_word_list = word_list[index];" is also wrong, it should be "*(new_word_list++) = word_list[index];"

"delete word_list" can just free the first element, it should be "delete[ ] word_list" to delete all.

After  copying all the elements, the pointer was moved to the end, so I add " word_list = p;" to modify "word_list" to point at the first element.


I move the print function into the function build_wordlist, because the pointer  transfered by value,  the pointer in the main function  is still point at NULL after the function build_wordlist calling.


"string *word_list;" causes a warning, because it hasn't been initialized. 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?