mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-15 13:10:59 +00:00
fix: Update C code for compatibility with the MSVC compiler (#949)
* Replace VLA with malloc Replace VLA with malloc to make C code compatible with cl compiler on Windows. * Fix C code for CI compiler. * Fix C code compability to CI. * check the trigger
This commit is contained in:
@@ -47,12 +47,13 @@ int main() {
|
||||
|
||||
printf("\n输出所有根节点到节点 7 的路径,要求路径中不包含值为 3 的节点\n");
|
||||
for (int i = 0; i < resSize; ++i) {
|
||||
int vals[MAX_SIZE];
|
||||
int *vals = malloc(MAX_SIZE * sizeof(int));
|
||||
int size = 0;
|
||||
for (int j = 0; res[i][j] != NULL; ++j) {
|
||||
vals[size++] = res[i][j]->val;
|
||||
}
|
||||
printArray(vals, size);
|
||||
free(vals);
|
||||
}
|
||||
|
||||
// 释放内存
|
||||
|
||||
Reference in New Issue
Block a user