Announcement

Collapse
No announcement yet.

Code C

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Code C

    Em có đoạn code sau :
    Code:
    # include <stdio.h>
    # include <stdlib.h>
    # include <conio.h>
    
    void main ()
    {
    	int *num, i,j=0;
    	printf ("Enter the number of element : \n");
    	scanf("%d",&i);
    	num=(int *) malloc (i*sizeof(int));
    	printf ("\nEnter data\n ");
    	for (j=0;j<=i;j++)
    	{
    		scanf("%d",(num+j));
    	}
    	printf("\n");
    	for (j=0;j<=i;j++)
    		printf("%d\t",*(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ả ạ !

  • #2
    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é

    Email: sinhngoc.nguyen@gmail.com
    Skype: sinhngoc.nguyen
    ĐT: 0974117946

    Comment


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

      Comment


      • #4
        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/2676...-ve-lap-trinh-

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

        Comment

        LHQC

        Collapse
        Working...
        X