c++ konsolenausgabe
To display output in C++, you can use the cout
statement from the iostream
library. Here's an example of how to use it:
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
Explanation:
The
#include <iostream>
line includes the necessary header file for input and output operations.The
int main()
function is the entry point of the program. It is where the program execution begins.std::cout
is an output stream object that is used to display output to the console.The
<<
operator is used to insert data into thecout
object. In this case, we are inserting the string "Hello, World!".std::endl
is used to insert a newline character and flush the output buffer.Finally,
return 0;
is used to indicate that the program has executed successfully.
When you run this program, it will display "Hello, World!" in the console.