Code C

Em có đoạn code sau :


# include <stdio.h>
# include <stdlib.h>
# include <conio.h>

void main ()
{
	int *num, i,j=0;
	printf ("Enter the number of element : 
");
	scanf("%d",&i);
	num=(int *) malloc (i*sizeof(int));
	printf ("
Enter data
 ");
	for (j=0;j<=i;j++)
	{
		scanf("%d",(num+j));
	}
	printf("
");
	for (j=0;j<=i;j++)
		printf("%d	",*(num+j));
	getch();
	free(num);

}

Cứ chạy tới hàm free la nó báo lỗi em không hiểu tại sao cả ạ !

for (j=0;j<=i;j++)
{
scanf(“%d”,(num+j));
}

bạn xem lại đoạn trên này bạn viết đúng chưa nhé

anh test trên dev c++ thấy bình thường. Bạn coi lại xem!

Chủ thread edit lại post #1 cho phù hợp với các nguyên tắc ở đây http://forum.uit.edu.vn/threads/26761-Phai-doc-truoc-khi-tao-thread-Mot-so-quy-tac-khi-hoi-cac-van-de-ve-lap-trinh-

Đề nghị các bạn khác khoan trả lời cho đến khi post #1 được edit