M
M
Maxim Rudnev2016-05-20 21:32:43
C++ / C#
Maxim Rudnev, 2016-05-20 21:32:43

How to correctly fill a line in a structure?

#include <iostream>
#include <conio.h>
#include <ctime>
#include <string>
// структура 
// 
using namespace std;

struct Data		
{
  int year;
  string month;
  int day;

  
};
void input(Data *s)
{
  cout << "Ввод даты" << endl;
  cout << "Введите год: " << endl;
  cin >> s->year;
  cout << "Введите месяц: " << endl;
  cin.getline(s->month);
}
  


int main()
{
  setlocale(LC_ALL, "Russian");
  
  



  _getch();
  return 0;
}

line 23 is underlined in red. I do not understand how to fill in the string with the month. How to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bonce, 2016-05-20
@stigmt

Use getline(cin, s->month);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question