>I wanted to know where will the selected message will be printed?
It's a part of the preprocessor, therefore it's a compile-time operation. Logically, you can expect the message to be printed in the compiler's output. In Visual Studio that's the output window (Ctrl+Alt+O).
>Can you give me a working example for it, and how it work...
#include <iostream>
#pragma message("This is a test")
int main()
{
std::cout<<"Hello, world!\n";
}
This is in the output window (I've highlighted the message):
1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>This is a test
1>Build log was saved at "file://c:\C++ Projects\Test\Test\Debug\BuildLog.htm"
1>Test - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401