I'm a student who just started studying through C++ Jeongol!!
The question is, there are printf and cout in C++, right?
When opening here, printf inserts \n in the middle of the character to open it
In cout, we use the endl to open itYo
My question is whether it is possible to print it out with printf and publish it through endl!!
I don't think it'll work because Cout treats \n as a text, but I want to know if it can be used as an inverse!
c++
#include <iostream>
#include <stdio.h>
#define endl '\n'
using namespace std;
int main(){
char a = 'a';
cout << "cout: " << a << "\n";
printf("printf: %c %c",a,endl);
printf("a");
return 0;
}
/*
Result
cout: a
printf: a
a
*/
"\n" is also available for both cout and printf.
If you want to use endl in printf, you can redefine it like #define endl '\n'
and write it like above. (If you just write in "", endl will be printed as it is.)
536 Uncaught (inpromise) Error on Electron: An object could not be cloned
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
708 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.