关于getline的使用,为什么报错啊
#include <iostream>
#include <string>
using namespace std;
void main()
{
string str;
getline(cin,str,'#');
char c=getchar();
cout<<str<<''<<c<<endl;
}
[解决办法]
#include <iostream>
#include <string>
using namespace std;
void main()
{
string str;
getline(cin,str,'#');
char c=getchar();
cout<<str<<" "<<c<<endl;
}
[解决办法]
标点错了吧。。。。。。。
[解决办法]
cout<<str<<''<<c<<endl;
单引号中间没有任何字符是错误的,你可以打个空格:比如:
cout << str<<' '<<c<<endl;