请大虾们帮忙看一下~~
我想实现输入号码时,如果第一个是0,也能输出,如输入022, 输出的也是022而不是22。请指教!!
#include <iostream>
using namespace std;
////////////////////////////
struct photo
{
int areacode;
int exchange;
int number;
};
////////////////////////////
int main()
{
photo Photo1 = {212, 767, 8900 };
photo Photo2 ;
cout<<"Please enter your area code, exchange, and number: ";
cin>>Photo2.areacode>>Photo2.exchange>>Photo2.number;
cout<<"My number is "<<"("<<Photo1.areacode<<") "<<Photo1.exchange<<"-"<<Photo1.number<<endl;
cout<<"Your number is "<<"("<<Photo2.areacode<<") "<<Photo2.exchange<<"-"<<Photo2.number<<endl;;
return 0;
}
[解决办法]
都改成字符类型啊
CString
string
都可以的啊
你说的报错应该是类型不统一吧