我在C语言中有这个结构体
typedef struct
{
const char * array_pointers_of_strings [ 30 ];
// etc.
} message;
我需要将这个array_pointers_of_strings复制到一个新的数组中,以便对字符串进行排序。我只需要复制地址。
while ( i < 30 )
{
new_array [i] = new_message->array_pointers_of_strings [i];
// I need only copy adress of strings
}
我的问题是:如何使用malloc()仅为字符串地址分配new_array [i]?
malloc(30 * sizeof(char*))
中使用双精度变量而不是数字30,那么new_array [i]
语法将无法工作。那么如何访问元素呢? - hpaknia