My output are only 0's?

I need values, but I'm not sure how?

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
struct Time
{
	int days = 0;
	int hours = 0;

};

void normalize(Time);

int main()
{
	int i;
        int n; // I realize my n is uninitialize, but I don't even know if I need n
	struct Time myTime;
	for (i = 0; i < n; i++) // Would 2 be better? I feel like it be wrong.
	{
		normalize(myTime);
	}

	return 0;
}

void normalize(Time timeNormalize)
{
	if (timeNormalize.days > 30)
		timeNormalize.days = 1;
	if (timeNormalize.hours > 24)
	{
		timeNormalize.hours = 0;
		timeNormalize.days++;
	
		cout << timeNormalize.days, timeNormalize.hours;
	}
	else
		timeNormalize.seconds++;
	cout << timeNormalize.days, timeNormalize.hours;
	
}
Last edited on
So you know that n is uninitialised, and thus some random value, but you use it anyway? WTF?

cout << timeNormalize.days, timeNormalize.hours;
What exactly are you trying to do here? Are you trying to do this:
cout << timeNormalize.days << timeNormalize.hours;


1
2
3
4
	for (i = 0; i < n; i++) // Would 2 be better? I feel like it be wrong.
	{
		normalize(myTime);
	}

What's this loop for? You just call the function on the same value over and over? Are you expecting something different to happen each time?
Last edited on
Topic archived. No new replies allowed.