Weird C programming problem...

Mears

Platinum Member
Mar 9, 2000
2,095
1
81
I am developing a function that is in the form of:

int functionname(float);

int functionname(float var)
{
return someint;
}

I have a driver that calls this function with a float. The problem is that whatever I passed in get's screwed with. IE I call it with 5.67 and when I print var inside the function it comes out as 2.34... I took out everything except the print statement to make sure that it wasn't something else, but it would still print out bogus numbers. Then I put the declaration and definition inside the driver and it worked. Anybody know what could cause this to happen? I showed my professor and she didn't know what was going on either.
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
You'll have to post all the code that duplicates this problem. Otherwise, there is no way to tell what's happening.