News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

[don't care]Program arguments, redirect output, >stdout.txt

Started by visir, December 24, 2017, 08:39:53 PM

Previous topic - Next topic

visir

I just tried adding >stdout.txt to the Project->Set Program Arguments.

Didn't work. Program receives it as an argument, and no redirection happens.

visir

Hm, don't do that on windows. It corrupted binary data, probably because it treated it as text.

Remade it as fopen("bw+"), it works now.

Figured it out from the fact that pcm_u16le sounded less noisy than pcm_s16le. Ascii text only takes first 128 possible values of a byte. I'm not sure if I'm lucky or the opposite. Holy shit. How the f*ck I made this connection.

BlueHazzard

Quote from: visir on December 25, 2017, 06:05:27 AM
Hm, don't do that on windows. It corrupted binary data, probably because it treated it as text.

Remade it as fopen("bw+"), it works now.

Figured it out from the fact that pcm_u16le sounded less noisy than pcm_s16le. Ascii text only takes first 128 possible values of a byte. I'm not sure if I'm lucky or the opposite. Holy shit. How the f*ck I made this connection.

what are you talking about?

Quote from: visir on December 24, 2017, 08:39:53 PM
I just tried adding >stdout.txt to the Project->Set Program Arguments.
Didn't work. Program receives it as an argument, and no redirection happens.
This obviously does not work. Your program needs a console host to run in it and the stream operator is a command of this console host, not for your program or windows. And also codeblocks does not know how to interpret the stream operator, because it is not a console host.

visir

So I can't run programs that use stdin or stdout?

>what are you talking about?

Just one bug I had a problem with for a few days. Binary data was corrupted after passing stdout, but text worked fine.

stahta01

Quote from: visir on December 25, 2017, 07:13:52 PM
So I can't run programs that use stdin or stdout?

You can not use the CB run and use stdin or stdout.

I hope you know enough to run programs that use stdin or stdout?

If not, I suggest learning how to open an command prompt to run your program.

Edit: Once, you figure out how to use the "command prompt"; I would suggest loking at the CB tools menu or toolsplus plugin.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Jenna

Quote from: visir on December 24, 2017, 08:39:53 PM
I just tried adding >stdout.txt to the Project->Set Program Arguments.

Didn't work. Program receives it as an argument, and no redirection happens.
It's called "Set program arguments", because you set program arguments.
A redirection is something different and has nothing to do with arguments, even if on a shell (console/cmd) it looks similar.

visir


oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Jenna

You can run every project in a console and copy and paste the content to review it.
Just check "Project -> Set programs' arguments... -> Run host in terminal".