Kalojan Ninov
Kalojan Ninov

Reputation: 3

error "Invalid initializer"

This is program which turns seconds into secods-minutes-hours.When i try to compile it, I get one error "Invalid initializer" on "struct time_t malko=times(a);" please someone help P.S. I have to do it only with structs not pointers or anything else!!


#include <stdio.h>

  struct time_t {
  float sec;
  int min,hours;
};

struct time_t fastest_time (float times[3]){
     int i;
     int prom;
     struct time_t malko;
     for(i=0;i<3;i++) {
     if(prom>times[i]) {prom=times[i];}
}
    malko.sec=prom%60;
    prom=prom/60;
    malko.min=prom%60;
    prom=prom/60;
    malko.hours=prom%60;

   return malko;
}


int main () {
   float a[3]={3423,1234,34232};
   struct time_t malko=times(a);
   printf("\n %d %d %f", malko.hours, malko.min, malko.sec);

   return 0;
}

Upvotes: 0

Views: 4808

Answers (1)

Adrien B
Adrien B

Reputation: 91

struct time_t malko=fastest_time(a); instead of struct time_t malko=times(a); ?

times isn't defined for main. (here the output : http://codepad.org/yvGhoHw4 )

Upvotes: 3

Related Questions