Categories > Coding > C++ >
(Probably annoying by now) std::cout or std::printf?
Posted
title
i asked chatgpt and i still cant decide
srry if this is getting annoying
Cancel
Post
Replied
printf stands for print format
or the og spell it printfffffffffffffeeee
It's on the stdio.h header which is the std input output lib for C and it's the standard way of printing to the console using C, but since C++ still maintains C backwards compatibility so it's still there and to make it easier to access so they include it in the std namespace i guess.
There's not much a difference to be considered should I use this or that. Pretty sure printf is just printing string to conout using placeholder formatting like
printf("Hello, %s", "Bob"); %s for string or %d for digit or int stuff so that the %s is replaced by "Bob" or whatever I can't explain really well icl
Doesn't matter afaik, I mean it doesn't affect your program stuff that much so yeah stop 😶
Cancel
Post
Replied
std::cout is safe whilst printf may not be.
printf uses C runtime formatting which is notorious for causing some of the biggest bugs in history and causing billions of dollars in damage, outputting a string in printf is dangerous, whilst formatting them through a stream is not.
Comments
TERIHAX 30 Reputation
Commented
damn i didnt know it was that bad, also i rarely see you active anymore, what happened?
SeizureSalad 36 Reputation
Commented
he has better things to do
TERIHAX 30 Reputation
Commented
@SeizureSalad oh i can understand
Added
@0x90 prob stupid question again, is using the system() function safe? like if i want to clear the console, like system("cls");
0x90 27 Reputation
Commented
@TERIHAX System is used to invoke any shell command so the safety of it depends on how it's invoked.
Besides that though, system is a pretty slow function and using it to clear the screen is very slow, there are specific terminal codes dedicated to clearing the screen that are far better suited for it.
Cancel
Post
Random quote here...
Replied
I recommend you to use printf, as it is faster, and simpler to use.
printf(char *a, ...);
The argument a represents a pointer to the first character of a string that contains the format (example: "Text: %s\nNumber: %d\n");
The argument(s) ... represents either pointers to first character in string that represents `%s`, or just a number, or some other value...
Comments
luxiferrwoo -5 Reputation
Commented
no, and i dont think i have to explain why
Cancel
Post
Contribute to Express, an open-source ROBLOX exploit written fully in C.
Replied
std::cout 100%
Comments
Cancel
Post
silly billy 🍎🍎🍎🍎
Replied
STD = S*xualy trasmitted d-
Printf = Pratical retar*dation international news torment function
Cancel
Post
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Comments
TERIHAX 30 Reputation
Commented
wdym by "stop" at the end, should i stop making these annoying c++ threads
0
rilyn 0 Reputation
Commented
@TERIHAX No. don't afraid to ask questions, just stop asking question like this.
0
TERIHAX 30 Reputation
Commented
@rilyn alright
0