我有一个之前由 malloc 分配的结构数组。释放它:free(temp) 可以吗?temp 是数组的名称。或者我应该逐个释放元素?
是的。这个函数。好吧,我添加了 structs.cur_node 的声明,它是 Node 的 var。我使用 Node 来创建链表。并逐个节点释放它。
struct Node
{
char template_id[6];
double tm_score;
double rmsd;
double sequence_id;
int length;
double translation_vector1;
double translation_vector2;
double translation_vector3;
double rotation_matrix1;
double rotation_matrix2;
double rotation_matrix3;
double rotation_matrix4;
double rotation_matrix5;
double rotation_matrix6;
double rotation_matrix7;
double rotation_matrix8;
double rotation_matrix9;
char target_sequence[2000];
char template_sequence[2000];
struct Node *next;
};
struct Node *start_node, *cur_node;
typedef struct
{
char *template_id;
double tm_score;
double rmsd;
double sequence_id;
int length;
double translation_vector1;
double translation_vector2;
double …Run Code Online (Sandbox Code Playgroud) 我试图通过动态分配来构建二维数组.我的问题是,它的第一个维度可能需要100个值,那么第二个维度会根据我的问题采用可变数量的值吗?如果有可能那么我将如何访问它?我怎么知道第二维的边界?