NEED HELP ASAP

Ok so there is this project I have to do for my programming class. It opens a file and then computes volumes with a link list. It will then sort the volumes and give you stats on them. Med, max, min, stand deviation, median, all that jazz. Well I am having troubles with definitions and I don't understand why.

My code is:
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "Project.h"

void main()
{
	struct shape *shapes;
	struct statistics stats;
	struct statistics stats1;
	struct statistics stats2;
	int coneSize1, cylSize2;
	double *coneVolumes1, *cylVolumes2;
	coneVolumes1=0;
	cylVolumes2=0;

	shapes = readShapes();
	coneSize1 = coneSize(shapes);
	cylSize2 = cylSize(shapes);
	coneVolumes1 = coneVolume(shapes, coneSize1);
	cylVolumes2 = cylVolume(shapes, cylSize2);
	stats1 = getStats(coneVolumes1, coneSize1);
	stats2 = getStats(cylVolumes2, cylSize2);

	if (shapes != 0)
	{
		printf("Shape Volume Statistics");
		printf("\n\n\t\t\tCount Minimum Maximum Average Std. Dev Median");
		printf("\nCone \t\t\t%i %lf %lf %lf %lf %lf %lf", stats1.count, stats1.min, stats1.max, stats1.avg, stats1.std, stats1.med);
		printf("\nCylinder \t\t\t%i %lf %lf %lf %lf %lf %lf", stats2.count, stats2.min, stats2.max, stats2.avg, stats2.std, stats2.med);
	}
	else
	{
		printf("Unable to open data.txt file");
	}
	printf("\n\nEnd Program");
}

int coneSize(struct shape *shapes)
{
	struct coneStats *stats1;
	int coneSize=0;
	stats1->coneCount=0;
	while(shapes != NULL)
	{
		if(shapes->type==1)
		{
			stats1->coneCount = (stats1->coneCount)+1;
			shapes = shapes->next;
		}
	}
	coneSize = stats1->coneCount;
	return coneSize;
}

int cylSize(struct shape *shapes)
{
	struct cylStats *stats2;
	int cylSize=0;
	stats2->cylCount=0;
	while(shapes != NULL)
	{
		if(shapes->type==2)
		{
			stats2->cylCount = (stats2->cylCount)+1;
			shapes = shapes->next;
		}
	}

	stats2->cylCount = cylSize;
	return cylSize;
}

struct shape* readShape(FILE *file)
{
	struct shape *s = (struct shape*) malloc(sizeof(struct shape));
	fscanf(file, "%i %lf %lf", &s->type, &s->radius, &s->height);
	return s->next = 0, s;
}

struct shape* readShapes()
{
	FILE *file;
	struct shape *first, *last;
	first = 0;
	file = fopen("data.txt","r");
	if(file != NULL)
	{
		if(!feof(file))
		{
			first = last = readShape(file);
			while(!feof(file))
			{
				last = last->next = readShape(file);
			}
		}
		fclose(file);
	}
	else
	{
		printf("\nUnable to open data.txt file");
	}
	return first;
}

double *coneVolume(struct shape *shapes,int coneSize)
{
	struct coneStats *stats1;
	int index;
	double *coneVolumes;
	coneVolumes = (double*)malloc(sizeof(double)*coneSize);
	for (index=0; index<=(stats1->coneCount); index++)
	{
		while(shapes->type==2)
		{
			shapes=shapes->next;
		}
		while(shapes->type==1)
		{
			coneVolumes[index] = (1.0/3) * (3.14) * (shapes->radius) * (shapes->radius) * (shapes->height);
			shapes = shapes->next;
		}
	}
	return coneVolumes;
}

double *cylVolume(struct shape *shapes, int cylSize)
{
	struct cylStats *stats2;
	int index;
	double *cylVolumes;
	cylVolumes = (double*)malloc(sizeof(double)*cylSize);
	for(index=0; index<=(stats2->cylCount); index++)
	{
		while(shapes->type==1)
		{
			shapes=shapes->next;
		}
		while(shapes->type==2)
		{
			cylVolumes[index] = (3.14) * (shapes->radius) * (shapes->radius) * (shapes->height);
			shapes = shapes->next;
		}
	}
	return cylVolumes;
}

struct statistics getStats(double volumearray[], int size)
{
	struct statistics stats;
	int index, count;
	double min, max, avg, std, med, total;


	count = 0;
	while(index<size)
	{
		stats.count++;
		index++;
	}

	min = volumearray[0];
	for(index=0; index<size; index++)
	{
		if(volumearray[index]<min)
		{
			min = volumearray[index];
		}
	}

	max = volumearray[0];
	for(index=0; index<size; index++)
	{
		if(volumearray[index]>max)
		{
			max = volumearray[index];
		}
	}

	total=0;
	for(index=0; index<size; index++)
	{
		total = total + volumearray[index];
	}
	avg = total/size;

	std = 0;
	for(index=0; index<size; index++)
	{
		stats.std = sqrt((1/(count - 1))*((volumearray[index] - avg) * (volumearray[index] - avg)));
	}

	for(index=0; index<size; index++)
	{
		if(volumearray[index] > volumearray[index+1])
		{
			double temp;
			temp = volumearray[index];
			volumearray[index] = volumearray[index+1];
			volumearray[index+1]=temp;
		}
	}

	med = 0;
	if (size %2 == 0)
	{
		med = ((volumearray[size]/2) + (volumearray[size - 1]/2)/2);
	}
	if (size %2 == 1)
	{
		med = (volumearray[size]/2);
	}

	stats.count = count;
	stats.min = min;
	stats.max = max;
	stats.avg = avg;
	stats.med = med;
	stats.std = std;

	return stats;
}


with a header file of

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
struct shape
{
	int type;
	double radius;
	double height;
	struct shape *next;
};

struct coneStats
{
	int coneCount;
	double coneMin, coneMax, coneAvg, coneStd, coneMed;
};


struct cylStats
{
	int cylCount;
	double cylMin, cylMax, cylAvg, cylStd, cylMed;
};

struct statistics
{
	int count;
	double min, max, avg, std, med, total;
};


Now when I compile it it is telling me that I can't convert from int to statistics, my getStats function has a redefinition; different basic types. A few other things. I've clicked each error trying to decipher what is wrong and I can't understand it. I'd appreciate any help.

I think it has to do with how i'm calling my getStats function into my main but I can't figure out why. I"ve tried changing to pointers and that doesn't work either.
Actually I figured it out! It was something silly. I didn't put my functions in my header file.

Now my stats won't display and I can't figure out why yet.
Topic archived. No new replies allowed.