我有一个作业问题要完成这个方法。我真的不知道该怎么办。给出这个伪代码有人可以帮我写这个方法吗?
/*
make a new array of the old size plus the new size
copy from the old to the new
add the new characters
don't forget to clean up the old array (free it)
before you leave this function
*/
char * add(char * array, int num)
{
return array;
}
最佳答案
由于这是 C,请查看 realloc - 但您还需要一个旧大小的参数(或者可能使用 strlen
)
关于c - 接受用户输入并将其添加到数组中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9706828/