Your program behavior is undefined. number_needed is a void function, so for all program management paths, an explicit return value is required.
It's hard to know what you want to type cout in main . Judging by the text of your question, you can change the return type of number_needed to void and set main to
int main(){ string a; cin >> a; number_needed(a); cout << endl;
source share