Print some Info

Posts 1–5 of 5 · Page 1 of 1
Print some Info
Hello,

i just want to print something in the console like when im in the File RageBot.cpp and want to print a simple Variable into the Console or just like this
std::cout << "test" << std::endl; why the console is not openning and print me this?


and one more question why i can release my dll without any errors but when i try to debug the code it wont work?
Set _CRT_SECURE_NO_WARNINGS as a Preprocessor Definition.
Type AllocConsole(); somewhere at the start to open a console.
After that type freopen("CONOUT$", "w", stdout);


AFTER THAT, TYPE SYSTEM(START WWW.LEARNCPP.COM);

- - - Updated - - -

Quote Originally Posted by DarknzNet View Post
I can predict what kind of answers you will get: learncpp.com
Teach me your clairvoyant skills m8
He's probably using Visual Studios, which requires you to allocate the console. When i first started learning i was using codeblocks lmao. Which doesn't need to alloc the console since you just press compile and run lmao and it does it for you.
Quote Originally Posted by slenzakm View Post
He's probably using Visual Studios, which requires you to allocate the console. When i first started learning i was using codeblocks lmao. Which doesn't need to alloc the console since you just press compile and run lmao and it does it for you.
It actually depends, if you set it to CONSOLE or WINDOWS at SUBSYSTEM.

When using windows i recomend using:
Code:
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
But w/e you can use anything for "main"...
Usually when you use CONSOLE as SUBSYSTEM, you have to declare the EntryPoint.

-----------------------
OP:
You need to attach the console to it, acording to the info you provided...

Code:
...
FILE *conin, *conout;

AllocConsole();
AttachConsole(GetCurrentProcessId());
SetConsoleTitle("My Console Title");

freopen_s(&conin, "conin$", "r", stdin);
freopen_s(&conout, "conout$", "w", stdout);
freopen_s(&conout, "conout$", "w", stderr);
...
Use freopen_s, so you don't need to disable _CRT_SECURE_NO_WARNINGS... Then you can use std::cin, std::cout, ...
Code:
AllocConsole();
		freopen("conin$", "r", stdin);
		freopen("conout$", "w", stdout);
		freopen("conout$", "w", stderr);
Here is easy pastable and basic console opener code.
Everything should work after opening it.

- - - Updated - - -

EDIT: Whoops, I didn't see the code above me. Sorry!
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us