windows-console

Assign output of a program to a variable using a MS batch file

我与影子孤独终老i 提交于 2019-11-26 01:24:23
问题 I need to assign the output of a program to a variable using a MS batch file. So in GNU Bash shell I would use VAR=$(application arg0 arg1) . I need a similar behavior in Windows using a batch file. Something like set VAR=application arg0 arg1 . 回答1: One way is: application arg0 arg1 > temp.txt set /p VAR=<temp.txt Another is: for /f %%i in ('application arg0 arg1') do set VAR=%%i Note that the first % in %%i is used to escape the % after it and is needed when using the above code in a batch

Output unicode strings in Windows console app

我的梦境 提交于 2019-11-25 22:20:53
问题 Hi I was trying to output unicode string to a console with iostreams and failed. I found this: Using unicode font in c++ console app and this snippet works. SetConsoleOutputCP(CP_UTF8); wchar_t s[] = L\"èéøÞǽлљΣæča\"; int bufferSize = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL); char* m = new char[bufferSize]; WideCharToMultiByte(CP_UTF8, 0, s, -1, m, bufferSize, NULL, NULL); wprintf(L\"%S\", m); However, I did not find any way to output unicode correctly with iostreams. Any

Running my C++ code gives me a blank console

孤街醉人 提交于 2019-11-25 21:56:38
问题 I\'m trying to run some C++ code in Visual Studio 2015. When I build it I get no errors, but once I run it, all I get is an empty console. I don\'t think it froze, because I can see a flashing underscore. Also if I run it in debug mode Visual Studio just freezes. I used a simple \"hello world\" code: #include <iostream> int main() { std::cout << \"hello world!\\n\"; return 0; } What I tried: I tried reinstalling Visual Studio, but it didn\'t fix anything. I also tried running some Python and