I am getting incorrect results when passing a int in a function:
int recruit(int var1, int re_unit, char *char_buffer, int var2) {
int run = 1;
int int_buffer
Uninitialized values in C's functions are not 0, they are just garbage whatever memory had at that particular moment..
#include <stdio.h>
int main()
{
int a;
printf("%i\n", a);
return 0;
}
That should demonstrate the idea...
Hopefully I interpreted the question correctly.
Please change this statement int recruit(int lvl, int re_unit, char *char_buffer, int u_lvl, int lvl2)
to int recruit(int lvl, int re_unit, char *char_buffer, int lvl, int lvl2)
. You are observing an incorrect value due to uninitialized variables.