Final Platform Layer 1.0.0
Loading...
Searching...
No Matches
Console Input/Output

FPL provides a couple of functions for writing text to the console and reading a single character from it.
These work with the standard output and standard error streams.

Note
To get an actual console window on Windows, include the fplInitFlags_Console flag when calling fplPlatformInit() .

Writing text

Use fplConsoleOut() to write plain text to the standard output and fplConsoleError() to write plain text to the standard error stream.

fplConsoleOut("Hello from standard output\n");
fplConsoleError("Something went wrong\n");
fpl_platform_api void fplConsoleOut(const char *text)
Writes the given text to the standard output console buffer.
fpl_platform_api void fplConsoleError(const char *text)
Writes the given text to the standard error console buffer.

Writing formatted text

For printf-style formatting, use fplConsoleFormatOut() for the standard output and fplConsoleFormatError() for the standard error stream.
Both take a format string followed by a variable number of arguments.

int frame = 42;
fplConsoleFormatOut("Current frame: %d\n", frame);
fplConsoleFormatError("Failed to load asset '%s'\n", "player.png");
fpl_common_api void fplConsoleFormatOut(const char *format,...)
Writes the given formatted text to the standard output console buffer.
fpl_common_api void fplConsoleFormatError(const char *format,...)
Writes the given formatted text to the standard error console buffer.

Reading a character

Use fplConsoleWaitForCharInput() to block until a single character is typed into the console input, and return it.

fplConsoleOut("Press any key to continue...\n");
fplConsoleFormatOut("You pressed: %c\n", c);
fpl_platform_api char fplConsoleWaitForCharInput(void)
Waits for a character to be typed in the console input and returns it.

Notes