簡體   English   中英

““double”類型的參數與“void *”類型的參數不兼容

[英]“argument of type ”double“ is incompatible with parameter of type ”void *“”

我正在編寫一種插值方法來構造一個樣條來插值數據。

I have the file spline.c that contains three functions the one that allocates memory for the variable needed inside the interpolation method inimem_spline and another function to free the space after computing the spline which is called freemem_spline . 但是在這部分我有一個錯誤:

double類型的參數與void *

我不知道這個錯誤來自哪里。

#include "math.h"
#include "malloc.h"
#include "stdlib.h"
#include "stdio.h"
#include "subroutines.h"

// Libreria para resolver sistemas lineales.

static double *sub_diag, * sup_diag, *diag, *d ;

// Function which allocates memory for the variables used inside the interpolation method
void inimem_spline(int n)
{
    int r = n-2, c = n-2; 
    int i, j;

    d=(double *) calloc(n,sizeof(double));
    if(d==NULL) {
        printf("\ninimem_spline:It is not possible to allocate memory\n");
        exit(19);
    }
    for(j=0;j<n;j++) d[j]=0.e+0;

    sub_diag=(double *) calloc(n-1,sizeof(double));
    if(sub_diag==NULL) {
        printf("\ninimem_spline:It is not possible to allocate memory\n");
        exit(20);
    }
    for(j=0;j<n;j++) sub_diag[j]=0.e+0;

    sup_diag=(double *) calloc(n-1,sizeof(double));
    if(sup_diag==NULL) {
        printf("\ninimem_spline:It is not possible to allocate memory\n");
        exit(21);
    }
    for(j=0;j<n;j++) sup_diag[j]=0.e+0;

    diag=(double *) calloc(n,sizeof(double));
    if(diag==NULL) {
        printf("\ninimem_spline:It is not possible to allocate memory\n");
        exit(22);
    }
    for(j=0;j<n;j++) diag[j]=0.e+0;

}

// Free Space of the Variables used inside the interpolation method.

void freemem_spline(int n)
{
    int i,j;

    for(j=0;j<n;j++) free(sub_diag[j]); 
    for(j=0;j<n;j++) free(sup_diag[j]); 
    for(j=0;j<n;j++) free(diag[j]); 
    for(j=0;j<n;j++) free(d[j]); 
    printf("\freemem_spline:Memmory free\n");

}

刪除循環並簡單地

free(sub_diag);
free(sup_diag);
free(diag);
free(d);

每個free()必須與每個calloc()對應。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM