0
std::getline(std::cin, time[d]);
Я довольно новичок в этом, и это первый случай, когда я столкнулся с ошибкой компиляции сообщения.Ошибка отладки - std :: getline
Я думаю, что ошибка изолирована от этой строки, но опять же я не уверен.
#include "stdafx.h"
#include <string>
#include <iostream>
#include <limits>
#include <stdlib.h>
#include <vector>
#include <cstdlib>
int main()
{
std::vector<std::string> time(24);
size_t d;
int a;
restart:
std::cout << "what time of day would you like to write the reflection? (0-23)" << std::endl;
std::cin >> d;
if (d > 23)
{
std::cout << "Please enter a time of day between 0 - 23" << std::endl;
system("PAUSE");
system("CLS");
goto restart;
}
else
std::cout << "What would you like to have inside of that?" << std::endl;
std::cout << "Please enter a sentence: ";
std::getline(std::cin, time[d]);
std::cout << "Is this what you wrote?" << std::endl;
std::cout << "[" << time[d] << "]" << std::endl;
system("pause");
std::cout << "To add a new reflection press 1" << std::endl;
std::cout << "To output all of the reflections press 2" << std::endl;
std::cout << "To terminate program press 3" << std::endl;
std::cin >> a;
if (a == 1)
{
goto restart;
}
if (a == 2)
{
system("pause");
std::cout << time[0] << std::endl;
std::cout << time[1] << std::endl;
std::cout << time[2] << std::endl;
std::cout << time[3] << std::endl;
std::cout << time[4] << std::endl;
std::cout << time[5] << std::endl;
std::cout << time[6] << std::endl;
std::cout << time[7] << std::endl;
std::cout << time[8] << std::endl;
std::cout << time[9] << std::endl;
std::cout << time[10] << std::endl;
std::cout << time[11] << std::endl;
std::cout << time[12] << std::endl;
std::cout << time[13] << std::endl;
std::cout << time[14] << std::endl;
std::cout << time[15] << std::endl;
std::cout << time[16] << std::endl;
std::cout << time[17] << std::endl;
std::cout << time[18] << std::endl;
std::cout << time[19] << std::endl;
std::cout << time[20] << std::endl;
std::cout << time[21] << std::endl;
std::cout << time[22] << std::endl;
std::cout << time[23] << std::endl;
system("pause");
}
else
system("pause");
return 0;
}
Пожалуйста ВЫВЕШУ [SSCCE] (http://sscce.org). – chris
Я не вижу ничего плохого в этой строке. Можете ли вы показать нам больше кода, пожалуйста? – 0x499602D2
Что такое 'время'? Убедитесь, что 'time [d]' является 'string'. – herohuyongtao