'How multiple lines logging works?
I am working on a C++ program. I saw multiple lines of logs in this pattern in one of the files:
#include <iostream>
using namespace std;
int main()
{
std::cout << "First line"
" second line" << std::endl;
return 0;
}
I am not very familiar with cpp language, is this a standard way of logging and how does it work? I feel like it should give some kind of syntax error on a quick look?
Solution 1:[1]
To log a simple string in C++ one can type std::cout << "My String.";
To log a variable one can replace "My String" from before with their variable.
to either add a string or another variable to a std::cout one can add "+ "My String"" or + MyVariable.
To end a line and begin writing to the line below one can add \n
to their string.
To play a sound one can add \a
to their string.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |