xeluxee / competitest.nvim

CompetiTest.nvim is a Neovim plugin for Competitive Programming: it can manage and check testcases, download problems and contests from online judges and much more
GNU Lesser General Public License v3.0
381 stars 15 forks source link

Read until the end of the stdin is not working #11

Closed MuhammadSawalhy closed 2 years ago

MuhammadSawalhy commented 2 years ago

I have tried this snippet of code to read until the last line of input:

std::string a;
while(std::cin >> a) {
  // do something
}

And when I CompetiTestRun it resulted in TIMEOUT. But it works in the terminal with redirecting a file to the stdin of the program.

./main < input.txt
xeluxee commented 2 years ago

Please provide main.cpp and input.txt

MuhammadSawalhy commented 2 years ago
#include <bits/stdc++.h>

using namespace std;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string a, b;

  while (cin >> a) {
    cin >> b;
    std::cout << a << " * " << b << std::endl;
  }

  return 0;
}
12
12
2
222222222222222222222222

image

xeluxee commented 2 years ago

Fixed with aa3bbfbd4432ef28f026148c99961811562c77ef