关于#c++#的问题,如何解决?

一直不能实现10进制转8进制

//10进制转8进制
#include
#include 
#include 
#include 
using namespace std;
int power(int n, int p) {
    int j = n;
    if (p == 0) {
        return 1;
    }
    for (int i = 0; i == p; i++) {
        n = n * j;
    }
    return n;
}
char _10to8(int t,int s=0){
    int y=s;
    string a,a1;
    y = t % 8;
    a += y;
    if(y!=0){
        y = t % 8;
        a += y;
        t = (t - y) / 8;
        a1 = _10to8(t,y);
        a1 += a;
        a = a1;
    }
    else {
        char buffer[256];
        sprintf(buffer, "%d", a);
        return buffer;//这里一直显示返回值不匹配
    }
}
int main() {
    int k;
    cin >> k;
    cout << _10to8(k) << endl;
    return 0;
}

char *_10to8(int t, int s = 0) 函数返回值得是指针或数组,而且局部变量buffer带不出函数,
你都用string了buffer也定义为string更方便

string _10to8(int t)
{
    if (t == 0)
        return "";

    int y = t % 8;
    t /= 8;
    return _10to8(t) + (char)(y + '0');
}
int main()
{
    int k;
    cin >> k;
    cout << _10to8(k) << endl;
    return 0;
}