如何在C ++中查找字符串中的行 [英] how to find a line in a string in C++
问题描述
#include<iostream>
#include<string>
using namespace std;
int main(){
string sSentence;
sSentence = "this is a string";
int iVowel = sSentence.find_first_of("aeiou");
while(iVowel!=string::npos){
}
}
所以这是未完成的代码。
我们的任务是制作一个关于piglatin的程序:
首先找到第一个一个单词的元音
将所有字符放在句子最后一个字母后的第一个元音之前然后添加ay
例如:编码==== odingcay
问题:
1.找到第一个元音后,如何在第一个元音之前得到字符。
2.翻译单词后,如何跳转到下一个单词。 (当我找到下一个单词的第一个元音但我不知道如何找到那个空格时,我想用空格作为起点)。
pls救命。谢谢:)
so this is the unfinished code.
The program that was tasked of us was so make a program about piglatin:
first find the first vowel of a word
put all the characters before the first vowel after the last letter of the sentence then add "ay"
example: coding ==== odingcay
Problems:
1. after finding the first vowel, how do I get the characters before the first vowel.
2. after translating the word, how do I jump to the next word. (I was thinking of using the blank space as the starting point when finding the next first vowel of the word but I dont know how to find that space).
pls help. thank you :)
推荐答案
字符串
类有许多有用的成员函数可以操作其内容,如上所述在 https://msdn.microsoft.com/en-us/library/syxtdd4f.aspx [ ^ ]。熟悉MSDN对开发人员来说总是有用。
The string
class has many useful member functions that can manipulate its content, as described at https://msdn.microsoft.com/en-us/library/syxtdd4f.aspx[^]. Getting familiar with MSDN is always useful to a developer.
这篇关于如何在C ++中查找字符串中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!