Hello, I just switched to macOS M1. Now I'm using VSC to code c++ on codeforces. But I just realized cin.tie(0) doesn't work like in windows. In windows, after entering all input, the output will be written later. But now, the output comes before I finish the input (I'm talking about the problem with multiple test cases). Does anyone have the same problem, can help me to fix it? Thank you guys so much!
I think the best option would be to create "input.txt" or smth similar and read input from here. You can use ifdefs or for example in CLion 2021, you can edit your configuration and read from file, without changing your code.
Use unix pipes, like
./a < a.txt
.Thank you. But in a contest, it's not effective because it takes a bit more time to run the code. Maybe I'll try to use another code editor.
It shouldn't.
I'm using Windows and
stdout
isn't always flushed only when the program exits. Sometimes if the output is a quite long,stdout
might get flushed before the program exits (and I don't usually usestd::endl
).Try this: setvbuf(stdout, nullptr, _IOFBF, BUFSIZ);
Thank you. I tried, but unfortunately, it still doesn't work.
VS code is not fully optimized for M1, it is designed for processors from Intel. Due to the new structure of the processor, VS code may be wrong. I advise you to use Xcode, it fully works for M1
It works fine in m1 with g++-11 compiler but doesn't work with clang++. I think you need to change your default compiler in VSC. One more thing How you precompiling bits/stdc++.h in m1 its not working for me.
Me too, bits/stdc++.h doesn't work. I wrote include for all the libraries :(
Based on the ideas our friends have commented on before. I found out how the following works. Although it doesn't seem to be very efficient. I created a sh file, which is named "run" like this:
I put all input to file input.txt Now when I need to run the code, I will write to the terminal:
I did it because it looks like we are running python file xD Anyone has a better idea to share?