简单的C++编译问题,在线等....

来源:百度知道 编辑:UC知道 时间:2024/06/17 15:41:09
#include<iostream.h>
void main()
{
double x
.
.
.
.
cout<<"请输入会员卡卡号,如果没有,直接安回车键"<<;
cin>>x;
}

现在假设这个x就是会员卡卡号,请问如何实现上面的要求呢?
就是没有会员卡直接回车进入下一步
你们几个谁在线上啊?在的跟我聊聊

#include <iostream>
using namespace std;
int main()
{
double id;
cout<<"请输入会员卡卡号,如果没有,直接安回车键:";
if(cin.peek()!='\n')
{
cin>>id;
cout<<id<<endl;
}
return 0;
}

// ioo_get_function.cpp
// compile with: /EHsc
// Type up to 24 characters and a terminating character.
// Any remaining characters can be extracted later.
#include <iostream>
using namespace std;

int main()
{
char line[25];
cout << " Type a line terminated by carriage return\n>";
cin.get( line, 25 );
cout << line << endl;
}

只不过变成了字符数组, 再用函数atof()转换为实数的.
#include <iostream>
using namespace std;
int main()
{
double x;
char temp[30];

cout<<"请输入会员卡卡号,如果没有,直接安回车键:";
cin.get(temp, 30);