I am trying to build a simple console to-do list. I built a struct with its various properties. Now, I am trying to build a function that will allow users to input their own data:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct task {
string Name;
string Description;
string DueDate;
bool isCompleted = false;
};
task createTaskFromUser() {
task Task;
cout << "Enter Task Title";
getline(cin, task.name);
}
int main() {
vector<task> taskList;
int choice;
cout << "Choose from following:\n1: Add Task\n2: Delete Task\n3: Show All Tasks\n";
cin >> choice;
if (choice == 1) {
cout << "Create New Task:\n"; cout << task;
}
return 0;
}
...however, when I use getline()
it comes up with an error.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744170591a4561516.html
评论列表(0条)