c语言中怎么动态分配一个字符串数组

2024-11-29 00:48:34
推荐回答(1个)
回答1:

#include
#include
#define LENGTH 20
int main()
{
    int str_num;
    scanf("%d",&str_num);
    char (*str_arr)[LENGTH] = (char(*)[LENGTH])malloc(sizeof(char)*LENGTH*str_num);
    for(int i=0;i    {
        scanf("%s",str_arr[i]);
    }
}