I’m having a very odd problem with my program and am hoping you can help. I have a really basic pair of functions. One calls the other and requires a return int.
For reasons completely unknown reasons the first function fails to print out match even though the conditions are true if the return value to a variable is assigned to a variable ie:
Function 1:
int function1(int posX, int posY){
int x=1;
int y=1;
if (posX == X && posY == Y){
printf("Match");
return 1;
}
}
Function 2:
int i = function1(1, 1);
Does work:
function1(1,1);
So to clarify, I’m saying that its working if I get the message “Match”.
C/C++ is case-sensitive. What do “X” and “Y” stand for?
Maybe try changing them to lowercase?
Also, always try to
returna value even if there is NOT a match (the functionfunction1is supposed to be returning anintvalue, right?)Code : (corrected)