Help with functions and structures

Hello guys, i'm seeking help again here. I've been trying to practice structures and functions altogether but i don't know why the code is wrong.

Can you tell me what is wrong there? Because it won't let me compile. It seems to be a problem with secs_to_time function (expected primary expresion before ')' token)

The code is in spanish because i'm from argentina but i'm sure you can understand it ;)

Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//prueba de estructuras
#include <iostream>
using namespace std;

struct Tiempo{
	int horas, minutos, segundos;
};

Tiempo secs_to_time(long secs);
long time_to_secs(&Tiempo);

int main()
{
	Tiempo tiempo;
	long segundo;
	
	cout << "introduzca horas minutos y segundos" << endl;
	cin >> tiempo.horas >> tiempo.minutos >> tiempo.segundos;
	cout << "son " << time_to_secs(tiempo) << " segundos" << endl
	<< "ahora introduzca segundos y le dire cuantas horas minutos y segundos son" << endl;
	cin >> segundo;
	
	tiempo = secs_to_time(segundo);
	
}

Tiempo secs_to_time(long secs)
{
	Tiempo tiempo;
	
	tiempo.horas = secs / (3600);
	tiempo.minutos = (secs / 60) - tiempo.horas * 60;
	tiempo.segundos = secs - tiempo.minutos * 60 - tiempo.horas * 3600;
	return tiempo;
}

long time_to_secs(&Tiempo tiempo)
{
	return tiempo.horas * 3600 + tiempo.minutos * 60 + tiempo.segundos;
}
Last edited on
1
2
long time_to_secs(&Tiempo);
long time_to_secs(Tiempo&);
In both declaration and definition
Thanks, i can't believe i'm so stupid :P

Again, thank you, problem solved!
Topic archived. No new replies allowed.