我写了这个程序,但我有这个错误请帮助 [英] I Wrote This Program But I Have This Error Please Help

查看:64
本文介绍了我写了这个程序,但我有这个错误请帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<stdio.h>
typedef struct
{
    int annee;
    int mois;
    int jour;
}date;
/***Tableau 3D des jours de 200 annees***/
(int***) nbre_jours()
{
    (int***)K;
    int jour, mois, annee;
    int T[200][12][31];
    for(annee=0;annee<200;annee++)
    for(mois=0;mois<12;mois++)
    for(jour=0;jour<31;jour++)
    T[annee][mois][jour]=1;
    for(annee=0;annee<200;annee++)
     for(mois=0;mois<12;mois++)
     {
        if(mois==1||mois==3||mois==5||mois==8||mois==10)
        T[annee][mois][30]=0;
    }
    for(annee=0;annee<200;annee++)
    T[annee][1][29]=0;
    for(annee=0;annee<200;annee++)
    {
        if((annee+1900)%4!=0)
        T[annee][1][28]=0;
    }
    K=T;
    return K;
}
/***Compteur de jours***/
date convert_int_to_date(int A)
{
    int ***nbre_jours();
    int T[200][12][31]=nbre_jours();
    int annee, mois, jour, som=0;
    date DATE;
    for(annee=0;(annee<200)&&(som<a);annee++)>
    for(mois=0;(mois<12)&&(som<a);mois++)>
    for(jour=0;(jour<31)&&(som<a);jour++)>
    som+=T[annee][mois][jour];
    DATE.jour=jour+1;
    DATE.mois=mois+1;
    DATE.annee=annee+1900;
    return DATE;
}
main()
{
    date convert_int_to_date(int);
    int A;
    date DATE;
    do
    {
        printf("saisir un entier positif");
        scanf("%d",&A);
    }
    while(A<=0);
    DATE=convert_int_to_date(A);
    printf("cet entier renvoie a la date:%d/%d/%d",DATE.jour,DATE.mois,DATE.annee);
}



这里是消息:

第2行预期在'int'之前的nonqualified-id

第2行预期')'在'int'之前


here is the message:
Line 2 expected unqualified-id before 'int'
Line 2 expected ')' before 'int'

推荐答案

main()
{
    date convert_int_to_date(int);
    int A;





函数原型不属于内部main()函数。由于您的函数完全定义在main之上,因此您不需要原型。只需删除行date convert_int ...





您将遇到类似的问题:





Function prototypes do not belong inside the main() function. Since your functions are fully defined above main, you don't need the prototype. Just delete the line "date convert_int..."


You will have a similar problem with this line:

date convert_int_to_date(int A)
{
    int ***nbre_jours();   //<-- Function prototype inside a method


(int ***)不是有效类型。您需要删除这些括号。也就是说,这只会修复一个错误,还有更多错误,其中最重要的是C.Pallini的评论中提到的,我。即 nbre_jours 返回一个悬空指针,在运行时访问时该指针无效。



另外,你不能将 int [] [] [] 分配给 int *** 。这些是不同的类型。最简单的方法是为数组定义一个类型,并始终如一地使用该类型。
(int***) is not a valid type. You need to remove those parentheses. That said, this will only fix one error, there are many more to come, not the least of which is mentioned in the comment by C.Pallini, i. e. that nbre_jours returns a dangling pointer which will be invalid when accessed at runtime.

Also, you can't assign int[][][] to int***. These are different types. The easiest way around this is to define a type for your array and use that type, consistently.


这篇关于我写了这个程序,但我有这个错误请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆