Valhalla Legends Forums Archive | General Programming | Me or compiler

AuthorMessageTime
Whitetail
#include <stdio.h>
#include <conio.h>

int sub(int x, int y, int z)
{
int answer;
answer = x - y - z;
return answer;
}
int main()
{
int sum;
sum = sub(12, 6, 12);
printf("answer%d\n",sub);
getch();
return 0;
}

it is returning is weird value of "4198928"
I have no clue what the problem is is it my error?

Please do not flame..yes I am aware I didnt put the code in the code format, I wasnt sure how to do so.

the needless call to getch() is to keep my DOS window open so i can look at the output.
June 2, 2003, 1:16 PM
Eibro
printf("answer %d\n", sub);
I think you meant to pass sum instead of sub.
June 2, 2003, 2:36 PM
Whitetail
Thanks Eibro, heh what a silly mistake
June 2, 2003, 4:25 PM
JoeCool
Silly Mistack lol!
not meaning to be mean or anything, you should of looked it over for like 30min and tired every possible thing u could of done wrong and change it... before posting it.. i gues.. sry to be mean :D
July 9, 2003, 2:50 AM

Search