I have been programming in C++ for around a month now, just long enough, I figure, to develop bad habits. Can anyone point out where I'm making mistakes and offer topics I should investigate to understand why?#include <iostream>#include <cassert>#include <sstream>#include <string>using namespace std;string get_line();int long get_integer();int* flex(long int num);void test_flex();int main(){     //flex(get_integer());    test_flex();}/*  * ===  FUNCTION  ============================================================= *         Name:  flex *  Description:  flex takes one integer argument and returns an then number *  of odd, even and zero digits. *  flex(111022) -> [3,2,1] i.e [odd,even,zero's] * ============================================================================ */    int*flex (long int num){    int res;    int even = 0;    int odd = 0;    int zero = 0;    while(num != 0){        res = num % 10;        if(res == 0){            zero++;        }        else if(res % 2 == 0){            even++;        }        else{            odd++;        }        num = (num - (num % 10))/10;    }    int oez[3] = {odd,even,zero};    return oez;}       /* -----  end of function flex  ----- *//*  * ===  FUNCTION  ============================================================= *         Name:  test_flex *  Description:  test suite for flex function * ============================================================================ */    voidtest_flex ( ){    assert(flex(1)[0] == 1);     assert(flex(1)[1] == 0);    assert(flex(1)[2] == 0);    assert(flex(112220)[0] == 2);    assert(flex(112220)[1] == 3);    assert(flex(112220)[2] == 1);}       /* -----  end of function test_flex  ----- *//*  * ===  FUNCTION  ====================================================================== *         Name:  get_integer *  Description:  checks if input is integer * ===================================================================================== */    long intget_integer (){    while(true){        stringstream converter;        converter << get_line();        int long result;        if(converter >> result){            char remaining;            if(converter >> remaining)                cout << Unexpected character:  << remaining << endl;            else{                return result;            }        } else            cout << Please enter an integer. << endl;        cout << Retry: << endl;    }}       /* -----  end of function get_integer  ----- *//*  * ===  FUNCTION  ====================================================================== *         Name:  get_line *  Description:  wraps getline * ===================================================================================== */    stringget_line(){    string result;    getline(cin,result);    return result;}       /* -----  end of function get_line  ----- */
Determine number of even, odd, and zero digits of a given integer
c++;beginner
Do not see the point in: get_line()get_line(line);// Vsstd::getline(std::cin, line);Get Integer is well done. Most people forget to test if there is anything else remaining on the line.A simple enhancement is:        char remaining;        if(converter >> remaining)        // easier to rewrite as:        if (!converter.str().empty())Also there is already a boost function that does something similar:long value = boost::lexical_cast<long>(line); // Will throw if anything left on line.Over complicating this:    num = (num - (num % 10))/10;You can simplify it too:    num /= 10;  // Integer division truncates.I think this is a logical error:    if(res == 0){        zero++;    }    else if(res % 2 == 0){ // zero is an even number                           // do you really want that else?Your one major error is:int oez[3] = {odd,even,zero};return oez;You are returning a pointer to an array that has gone out of scope. Personally I would return a std::vector<int>. Don't worry on a simple returning like this the copy back of the array will be optimized out (look up RVO and NVRO).std::vector<int> oez = {odd,even,zero};return oez;