int main()
{
std:: string menuChoice;
int nArrayNumber = 0;
int nAuthorArrayNumber = 0;
int nElementArrayNumber = 0;
pCurrentMediaItem = aMediaItemArray;
displayMediaMenu();
while (!finished)
{
std::cin.clear();
interActive = isatty(fileno(stdin));
std:: cout << std::endl << "Menu[" << nArrayNumber << "]:";
getline (std::cin, menuChoice);
charOption(menuChoice,
pCurrentMediaItem,
nArrayNumber,
finished,
nAuthorArrayNumber,
nElementArrayNumber);
字符串
C++:我如何解析一个字符串,并将整数赋给其他变量,将名称赋给一个单独的字符串变量。
举例来说,您可以:必须输入作者的出生年份、死亡年份和姓名,并且必须将该字符串发送到一个switch语句,该语句将解析该字符串并将单独的成员分配给其他变量。
1条答案
按热度按时间lc8prwob1#
根据你对解析字符串
c 1888 1999 Author Name
的评论,你可以考虑用第一个字符创建一个switch语句。例如:字符串
Author
是一个有名字、出生年份和死亡年份的类,find_author
是下面可怕的意大利面条代码。我沿着了STL的字符串构造函数,find_first_of
、find_first_not_of
和find_last_of
返回字符串中的一个位置。型