int betterRunner(const Trunner *runner1, const Trunner *runner2);
in main I have something like this
Trunner = runner1, runner2;
betterRunner(runner1, runner2);
...
and get a error:
expected 'const struct Trunner *' but argument is of type 'Trunner'
if I use the address of opperater & then it seems to work but some of the data when printed comes out all jacked up.
The question is how do I pass the runner to the function so the data inside does not come out as garbage?
int betterRunner(const Trunner *runner1, const Trunner *runner2)
{
int ret;
ret = compare_times(runner1->time, runner2->time);
if(ret == 1)
{
return 1;
}
else
{
return 2;
}
}
the compare time function it Ttime is like this
int compare_times(Ttime t1, Ttime t2)
{
if(t1.min < t2.min)
{
return -1;
}
if(t1.min > t2.min)
{
return 1;
}
if(t1.min == t2.min)
{
return 0;
}
return 0;
}
main looks like this
#include <stdio.h>
#include "Runner.h"
int main()
{
Trunner runner1, runner2;
int ret;
readName(&runner1, "Give the name for the runner 1? ");
readName(&runner2, "Give the name for the runner 2? ");
readTime(&runner1, "Give the time for the runner 1? ");
readTime(&runner1, "Give the time for the runner 1? ");
ret = betterRunner(runner1, runner2);
printf("ret is %d", ret);
if(ret == 1)
{
displayRunner(&runner1);
}
else
{
displayRunner(&runner2);
}
return 0;
}
when it displays the time in the end its some huge # when I pass using &runner.
ok well then pointers still seem to have me confused. What do I need to pass then to make this right? I tried just runner1 and *runner1 both complain about invalid conversions and dont work. the &runner1 seems to run but is not what it is looking for. Suggestions anyone?
Post your code in code block. [ code][/code ] removing the leading and trailing space in the tags I just gave you. Post your error and the line number the error is occurring in the code you post.