Gilbert Waltoon
Gilbert Waltoon

Reputation: 3

directing file output to the console

I'm working with a C-function foo(FILE* file) that outputs some text to a file.

Rather than write to a .txt file, I'd like foo to write to the console.

Is there a way to pass 'the console' as a FILE*? (And if so, how) ?

(foo is part of a library and I can't edit the source code directly)

Upvotes: 0

Views: 63

Answers (1)

dbush
dbush

Reputation: 225344

There's a special file object called stdout that will write to the console (assuming the shell didn't redirect anything).

foo(stdout);

Upvotes: 3

Related Questions