#include <stdio.h>
#include <ctype.h>
void spyral(int boyut)
{
int i;
int*a = malloc(boyut * sizeof(int*));
for (i = 0; i < boyut; i++)
{
a[i] = i + 1; //program is erroring here
}
for (i = 0; i < boyut; i++)
{
printf("%d", a[i]);
}
/*int x = 5;
int y = 5;
int** a = malloc(x * sizeof(int*));
for (int i = 0; i < y; i++) {
a[i] = malloc(sizeof(int*) * y);
}*/
}
int main()
{
spyral(6);
}
我想从main发送一个变量到函数,此代码在Visual Studio上不起作用,但在dev-c ++上起作用。我想在Visual Studio上工作,这是什么问题?