Visual Studio C++ Console调试过程中,有哪些手段可以将要输入的参数,事先存好读进去,而不用手工敲键盘输入?
更新:提这个问题主要是好奇,那些OJ的系统,是怎么对代码进行评测的。代码里都是cin这样的输入,那么OJ是怎样来用自己的case来评测这些代码是否正确呢?
业精于勤,荒于嬉;行成于思,毁于随。
Add header file fstream
#include<fstream>
Then, put the data you want to lose in in.txt, and add
std::ifstream cin("in.txt");
Just follow the normal usage of cin later.
Called through code, haha
Fill in the parameters you want to enter directly in the main function and that’s it. . . There are many methods.
type yourtext.txt | yourexe.exe
An alternative, unit testing
Add header file fstream
at the beginningThen, put the data you want to lose in in.txt, and add
in the codeJust follow the normal usage of cin later.
Called through code, haha
Fill in the parameters you want to enter directly in the main function and that’s it. . .
There are many methods.
type yourtext.txt | yourexe.exe
An alternative, unit testing