0

I am writing a program that read two dates(type STRUCT) from the user and compares them using a function which be called in main{}

struct datum1 {
    short tag;
    short monat;
    int jahr; }datum1;
struct datum2 {
    short tag;
    short monat;
    int jahr; }datum2;
void datumvergleich (struct datum1,struct datum2);

int main(){
    printf("Geben Sie den Ersten Datum im Tag Monat und Jahr");
    scanf("%hd\n",& datum1.tag);
    scanf("%hd\n",& datum1.monat); 
    scanf("%d\n",& datum1.jahr);  
    datumvergleich (datum1,datum2);
        }
/* void datumvergleich (struct d1, struct d2 )*/{ 
    int t,m,j;
    j=d1.jahr-d2.jahr;
    m=d1.monat-d2.monat;
    t=d1.tag-d2.tag;``` ...
i keep getting "error duplicate identifier:" at the line where there is the comment bracket " /* */ "
just FYI tag/monat/jahr mean day/month/year in german.
thanks in advance

1 Answers1

0

The commented line needs to be

void datumvergleich (struct datum1 d1, struct datum2 d2 )

in order to match the function prototype further up in the program (you don't need to specify the variable names in function prototypes, just the types). Note that if datum1 and datum2 will always have exactly the same members, then you could use the same struct for both d1 and d2.

Note that you can use typedef to obviate the tedium of writing struct datum1 etc. See Why should we typedef a struct so often in C?

Bathsheba
  • 231,907
  • 34
  • 361
  • 483