Lỗi bộ nhớ free malloc trong VC++,tại sao vậy nhỉ
Mã:
#include <stdio.h>//#include <alloc.h>#include <stdlib.h>#include <conio.h>#define MAX 100#define TRUE 1#define FALSE 0int Stop, count;void Init(int *B, int n){ int i; for(i=1; i<=n ;i++) B[i]=0; count =0; }void Result(int *B, int n){ int i;count++; printf("
Xau nhi phan thu %d:",count); for(i=1; i<=n;i++) printf("%3d", B[i]); }void Next_Bits_String(int *B, int n){ int i = n; while(i>0 && B[i]) { B[i]=0; i--; } if(i==0 ) Stop=TRUE; else B[i]=1; } void Generate(int *B, int n){ //int i; Stop = FALSE; while (!Stop) { Result(B,n); Next_Bits_String(B,n); } } void main(void) { int *B, n;//clrscr(); printf("
Nhap n=");scanf("%d",&n); B =(int *) malloc(n*sizeof(int)); Init(B,n); Generate(B,n); free(B); getch(); }
View more random threads:
Thông qua phân tích dữ liệu Google từ 86 quốc gia, mới đây, một công ty tại Anh đã công bố bảng xếp hạng kích tấc "cậu nhỏ" của các nước trên thế giới. Kết quả, hầu hết các nước xếp ở nhóm đầu của...
"Chim" của chàng trai Việt thuộc...