• Welcome to Valhalla Legends Archive.
 

Me or compiler

Started by Whitetail, June 02, 2003, 08:16 AM

Previous topic - Next topic

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.

Eibro

printf("answer %d\n", sub);
I think you meant to pass sum instead of sub.
Eibro of Yeti Lovers.

Whitetail

Thanks Eibro, heh what a silly mistake

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