error: expected primary-expression before '<<' token错误
#include<iostream>#include<string>usingnamespacestd;intmain(){stringuser_name;cout<<"...
#include<iostream>
#include<string>
using namespace std;
int main()
{
string user_name;
cout <<"Please enter your name:";
cin >>user_name;
switch ( user_name.size() ){
case 0:
cout<<"Ah,the user with no name."
<<"Well,ok,hi,user with no name\n";
break;
case 1:
cout<<"A 1-character name? Hmm,have you read Kafka?:";
<<"hello,"<< user_name <<endl;
break;
default:
//字符串长度超过一个字符
cout <<"hello, " << user_name
<<" --happy to make your acquaintance!\n";
break;
}
return 0;
} 展开
#include<string>
using namespace std;
int main()
{
string user_name;
cout <<"Please enter your name:";
cin >>user_name;
switch ( user_name.size() ){
case 0:
cout<<"Ah,the user with no name."
<<"Well,ok,hi,user with no name\n";
break;
case 1:
cout<<"A 1-character name? Hmm,have you read Kafka?:";
<<"hello,"<< user_name <<endl;
break;
default:
//字符串长度超过一个字符
cout <<"hello, " << user_name
<<" --happy to make your acquaintance!\n";
break;
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询