0
#include <iostream>
using namespace std;

int main()
{
  char str[100];
  int n;
cin>>n;
  std::cin.get(str, 100);
  
  cout <<str;
  return 0;
}

when i use cin.get() at first it works but it is not working if i use it after taking some inpute

  • 1
    That question is about `std::getline`, but both this and `std::cin.get()` are examples of unformatted stream extraction, while `std::cin >>` is formatted stream extraction. Using unformatted extraction after formatted one requires certain steps to clear the buffer from lingering newlines/whitespaces. – Yksisarvinen Nov 02 '20 at 17:10
  • Please specify the input, actual output and the expected output of your program. It is unclear what you are trying to do. – Andreas Wenzel Nov 02 '20 at 17:12

0 Answers0