我正在编写一个类似函数的简单日志,但是我似乎无法通过传递用户输入的值来了解如何生成向量的新元素.我是编程的新手,所以答案可能很明显:/我编译程序时没有错误,但添加日记条目的代码似乎没有任何效果.有任何想法吗?
这是以下程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
bool running = true;
while (running = true)
{
vector<string> journal;
vector<string>::const_iterator iter;
int count = 1;
journal.push_back("Day 1. Found some beans.");
journal.push_back("Must remember not to eat beans");
journal.push_back("Found some idiot who traded beans for a cow!");
cout << "Journal Tester.\n\n";
cout << "1 - View Journal\n2 - Add journal entry\n";
cout << "3 - Quit\n";
cout << "\nPlease choose: ";
string newentry;
int choice;
cin …
Run Code Online (Sandbox Code Playgroud)