Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Why won't this take input?

$
0
0

Hi,

I can't seem to figure out why this doesn't take input:

#include <iostream>
#include <conio.h>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int number_of_tasks;
	cout << "Enter the number of tasks: ";
	cin >> number_of_tasks;
	std::string* tasks = new   std::string[number_of_tasks];
        for(int i = 0; i < number_of_tasks; ++i)
	{
		cout << "Give a name to task " << i + 1 << ": ";
		std::getline(std::cin, tasks[i]);
                cout << "Enter deadline: ";

The above is part of the code. But here is a sample output:

Enter the number of tasks: 3

Give a name to task 1: Enter deadline:

What's wrong with my code?


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>