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:
Vệ sinh cá nhân là một phần quan yếu của sức khỏe nam giới. Dùng dung dịch vệ sinh mỗi ngày mang lại nhiều ích, giúp loại bỏ vi khuẩn và vi sinh vật gây hại, giúp khu vực cơ quan sinh dục luôn sạch...
Gel vệ sinh cu, bạn trai có nên...