我想读取用户输入合并字符串和数字,像这样:分配结构的数组,数组内
50:string one
25:string two blablabla
...
我不知道投入将有多少行有,我也不要不知道弦的最大长度。
因此,我创建
typdedef struct line
{
int a
char *string
} line;
那么这sturct
line *Array = NULL;
现在我有一个循环,读取一行并将其解析到temporaryString和temporaryA的数组。我如何重新分配数组以将它们复制到数组中?
通过使用['realloc'](http://en.cppreference.com/w/c/memory/realloc)函数? –
可能的重复[如何使此函数采取任意字符串?](http://stackoverflow.com/questions/34353204/how-do-i-make-this-function-take-arbitrary-strings) –