#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);
}
I want to send a variable to function from main, this code is not working on visual studio but this works on dev-c++. I want to work on visual studio, what is the problem?
User contributions licensed under CC BY-SA 3.0