读入空格但不读入换行

时间:2022-11-05 15:12:40
读入空格但不读入换行读入空格但不读入换行View Code
#include<cstring>
#include<cstdio>
#include<string>
#include<iostream>
#define N 1010
using namespace std;
int main()
{
string s;char ss[N]; //while(sscanf(gets(ss),"%[^\n]",ss)) //能重复读入但是不是文件结束
while(cin.getline(ss,N))//以文件结束
{
int t;
s=ss; //直接赋值
t=s.find("you");
while(t!=-1)
{
s.replace(t,3,"we");
t=s.find("you");
}
cout<<s<<endl;
}
return 0;
}