[求助]这个程序有什么问题.
题目:编写一个函数, 它接收一个输入参数, 该参数由两个单词组成, 单词之间使用一个空格分隔,函数通过它的两个输出参数返回每一个单词.所有三个参数都应该为string类型
程序代码:#include <iostream>
#include <string>
using std::string;
void dividewords(string, string &, string &);
int main(void)
{
using std::cin;
using std::cout;
using std::endl;
string input_words;
string word1, word2;
getline(cin, input_words, '\n');
dividewords(input_words, word1, word2);
cout<<word1<<" "<<word2<<endl;
return 0;
}
void dividewords(string input_words, string & word1, string & word2)
{
int k;
for(k = 0; input_words.at(k) != ' '; k++)
word1.insert(input_words.at(k));
for(; input_words.at(k) != '\0'; k++)
word2.insert(input_words.at(k));
}这是我写的代码.在g++的编译下提示错误.








