PDA

View Full Version : dp, clay and elezzzark, you are coders



m0nde
01-27-2019, 10:53 PM
i'm learning c++ and want to know if there is a way to target all systems in one method when i want to write directly to the console

i wrote a windows program where I'm using


int main()
{
// Create Screen Buffer
wchar_t *screen = new wchar_t[nScreenWidth*nScreenHeight];
HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
SetConsoleActiveScreenBuffer(hConsole);
DWORD dwBytesWritten = 0;

...
screen[nScreenWidth * nScreenHeight - 1] = '\0';
SetConsoleTextAttribute(hConsole, 0xaa);
WriteConsoleOutputCharacter(hConsole, screen, nScreenWidth * nScreenHeight, { 0,0 }, &dwBytesWritten);
}



it works fine. i have 2 questions, what do i do to do that in a way which will work on any system? is that even possible?

clay
01-27-2019, 11:40 PM
but he dead

juji
01-28-2019, 12:57 AM
I dont speak C++

m0nde
01-28-2019, 02:26 AM
but he dead

clay, stop

clay
01-28-2019, 03:03 AM
:bobsley:

m0nde
01-28-2019, 06:23 AM
clay, stop

Autistic Spectrum
01-28-2019, 06:25 AM
https://stackoverflow.com/questions/25153044/c-cross-platform-compiling

m0nde
01-28-2019, 07:28 AM
o don't need help compiling. I want to know specifically about targeting wstrings and wchar_t* (Unicode) for sure that writes to tty

juji
01-28-2019, 08:16 AM
Why? You’re reinventing the wheel

juji
01-28-2019, 08:20 AM
I believe you should try with mono develop where you can write C# in any system without worrying at specificying the data type

m0nde
01-28-2019, 08:59 AM
I think I'm just going to port my code to JavaScript and html5 and forget this shit. it'll be much easier

Autistic Spectrum
01-28-2019, 10:36 AM
no go deeper and port it to assembly

juji
01-28-2019, 10:49 AM
I think I'm just going to port my code to JavaScript and html5 and forget this shit. it'll be much easier

You can use this lib for node.js https://github.com/dtinth/screen-buffer and wrap it with electron including GUI then export to any system

Desolation
01-28-2019, 10:53 AM
101010101011101001010101001000010111

maks
01-28-2019, 05:06 PM
I think you should use a for loop

maks
01-28-2019, 05:07 PM
my programs use a lot of for loops because everything I write is based on the threadlong framework