How to convert this code to use string

前端 未结 2 374
一向
一向 2021-01-29 08:49
char * recursivecombo(char *str, int choices, int level)
{
    int len = strlen(str);

    level++;
    if( level == choices)
    {   
            for (int i = 0; i <         


        
2条回答
  •  时光取名叫无心
    2021-01-29 09:45

    std::string recursivecombo(const std::string& str, int choices, int level)
    {
        level++;
        for (int i = 0; i < str.length() -2; ++i)
        {
            cout<

    This is just a mock-up using a string. Some issues with your function

    1)Where is your return value

    2)If you intend to use string use cout, rather than printf, if it is C++

    3)Use prefix ++.

提交回复
热议问题