gpt4 book ai didi

c - 接受用户输入并将其添加到数组中的函数

转载 作者:行者123 更新时间:2023-11-30 14:26:00 25 4
gpt4 key购买 nike

我有一个作业问题要完成这个方法。我真的不知道该怎么办。给出这个伪代码有人可以帮我写这个方法吗?

/*
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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com