My friend just sent me this code block and I can't find out what is wrong, the idea is the following, it scans for both army numbers, and it must be done in the same scan, same line. After it comepares the numbers, if hamashs army is smaller it should prints fight and the difference between the 2 armys, else it prints runs and the difference.
Code:
#include<stdlib.h>
#include<stdio.h>
int main (){
int hmsharmy, earmy, dif;
hmsharmy = earmy = dif = 0;
printf("Should Hamash Fight or Run!?:");
printf("\nPlease inform the number of soldier in Hamash's and in the enemy army is THIS ORDER:");
scanf("%d",&hmsharmy,&earmy);
//scanf("%d",&earmy);
dif=&hmsharmy-&earmy;
if (dif < 0) {
printf("\nWe shall fight!\n");
printf("%d\n",&dif); }
else {printf("\nWe shall run!\n");
printf("%d\n",&dif);}
return 0;
}
By the moment it returns they should allways run, and doesn't print the right number on the difference.