I'm trying to develop a recursive function to convert an integer number into binary and putting the result into a vector using the following logic:
Every function call, divide the number by 2, if the remainder is equal to 0, insert a 0 in vector, if not, put one in the vector.
Soon after when the function ends, I show the contents of the vector.
However, nothing is displayed on the screen.
Why?
You're passing the vector by value so its contents can't be modified by the function. The function is working with a copy.
Pass the vector by reference instead: void itob(short n,vector<int>& binary);// note the &