Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c程序中的错误_C_Compiler Errors - Fatal编程技术网

c程序中的错误

c程序中的错误,c,compiler-errors,C,Compiler Errors,这是我的代码: #include <stdio.h> #include <stdlib.h> //funkcija dodavanja u red void add(cvor* red, int i, cvor broj){ //Errors appear in this line red[i] = broj; } // brise iz vadi iz reda clan koji je prvi usao cvor delete(cvor *red, int

这是我的代码:

#include <stdio.h>
#include <stdlib.h>
//funkcija dodavanja u red
 void add(cvor* red, int i, cvor broj){ //Errors appear in this line
    red[i] = broj;
}
// brise iz vadi iz reda clan koji je prvi usao
cvor delete(cvor *red, int i){
    cvor a;
    int e;
    a = red[0];
    for (e = 1; e < i;e+=1){
        red[e - 1] = red[e];

    }
    return a;
}
//definiticja strukture cvora
typedef struct temp{
    double info;
    struct temp* levi;
    struct temp* desni;

}cvor;

// pravljenje novog cvora
cvor *novi_cvor(cvor *levi_sin,cvor *desni_sin,double broj){
    cvor *novi = malloc(sizeof(cvor));
    novi->levi = levi_sin;
    novi->desni = desni_sin;
    novi->info = broj;
    return novi;

}

void main(){
    int i=0,e,n;
    cvor *red;
    double broj;
    // definisanje reda kao dinamcikog niza
    red = calloc(50, sizeof(cvor));
    // u red unosimo clanove liste redom

    printf("Uneti broj clanova liste");
    scanf_s("%d", &n);
    while (n>0){
        scanf_s("%lf", &broj);

        add(red, i, *novi_cvor(NULL,NULL,broj));
        i += 1;
        n -= 1;
    }
    //ispis reda
    for (e = 0; e < i; e += 1){
        printf("%2.lf\n\n", red[e]);
    }



    system("pause");
}
所有这些都显示在第4行中

有什么解决办法吗?
谢谢

如果您想在另一个方法中使用struct、typedef或方法,您必须声明它或编写它们的代码。 这意味着当您在main中调用函数delete时,它不会检测到cvor的含义,因为cvor的定义如下


在第一行,在其他行之前。

哪里有错误?请在发布的源代码中标出。您的
typedef
移到顶部。
Error 1 error C2143: syntax error : missing ')' before '*'
Error 2 error C2143: syntax error : missing '{' before '*'  
Error 3 error C2059: syntax error : 'type'  
Error 4 error C2059: syntax error : ')'
typedef struct temp{
double info;
struct temp* levi;
struct temp* desni;
}cvor;