Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 基数10到2,8,16的函数问题?_C++ - Fatal编程技术网

C++ 基数10到2,8,16的函数问题?

C++ 基数10到2,8,16的函数问题?,c++,C++,我是初学者,对编码和英语可能不太好。我住在泰国曼谷 我通过使用开关盒创建了10到2,8,16的函数基 这里可以看到我的代码C++: 问题 当我运行该程序时,我选择了数字案例1、2、3一个问题是,正如Tyger提到的,你没有初始化x,你可以从菜单函数中的cin中得到它。 另一个问题是,即使从函数中获取字符串,也不会将其写出。因此,您的主要功能应该如下所示: int main(){ string out; // Do you realy need the out string here? int

我是初学者,对编码和英语可能不太好。我住在泰国曼谷

我通过使用开关盒创建了10到2,8,16的函数基

这里可以看到我的代码C++:

问题


当我运行该程序时,我选择了数字案例1、2、3一个问题是,正如Tyger提到的,你没有初始化x,你可以从菜单函数中的cin中得到它。 另一个问题是,即使从函数中获取字符串,也不会将其写出。因此,您的主要功能应该如下所示:

int main(){

string out;  // Do you realy need the out string here?
int mod,x;   // or the mod here
int choice;

cout << "Give x: " << endl;
cin >> x;

out = " ";

do{
    menu(choice);
    switch(choice)
    {
        case 1 : cout << base10to2(x) << endl; break;
        case 2 : cout << base10to8(x) << endl; break;
        case 3 : cout << base10to16(x) << endl; break;
    }
}
while(choice != 4);{
cout<<"End Program / Thank You";
}

return 0;

}

因为您没有初始化x。谢谢Geri。我忘记了在函数和转换后的输出中输入Base 10来转换任何2,8,6。我能解决这个问题,因为你。非常感谢你。