Anonymous
You can do everything youd do in cpp in c. Except you shouldnt
well , can you do something like generic(ig its called meta) programming in C ?
BinaryByter
c is cute
Looks like someones not willing to look at the good stuff. "no i dont want free caviar and free foie gras. I prefer pizza"
BinaryByter
But... Ewww
BinaryByter
No
Anonymous
With some makro hackery, i think
I was typing .. without using the hackish macro way
Dima
I have a lot of professional experience in C lol
Dima
It’s good enough for me
Dima
BinaryByter
Anonymous
C isnt as modern, isnt as safe, isnt as clean, isnt as fast, isnt as clear of intent
hmm safe,clear,fast ? ig cpp doesn't have those sides much better ? does it ?
Dima
I can make a caviar out of pizza in C, that’s why I like it
BinaryByter
I was typing .. without using the hackish macro way
Well no. No generics without macros xD
BinaryByter
hmm safe,clear,fast ? ig cpp doesn't have those sides much better ? does it ?
By using the standardlib, you can on average gain quite some speed. Its very clear and clean because you can abstract stuff away, and the standardlibrary is just epic. Also, modern cpp requires you not to use on the fly mebory allocation, which makes your program memory safe
BinaryByter
Hmm but how ?
strlen loops througd the string until it hits the nulr termination. Std string just keeps track of the size
Anonymous
I've to check this
BinaryByter
Hmm a loop in the bg ?
No its not a loop in the background
BinaryByter
Wait lemme show you
BinaryByter
int strlen (char*a) { int b; while (*(a++)) {b++;} return b; }
Anonymous
Oh lol
Anonymous
Didn't mean this
Anonymous
I meant how std keeps track of the strings
BinaryByter
when you change the string, it Updates the size
BinaryByter
class std::string{ private: size_t size; char *data; } ;
BinaryByter
You need to know the size anyway, in order to manipulate the strings
BinaryByter
Besides the comp statements used in strlen are up to twenty times slower than the addition
BinaryByter
Also, when using size multiple tiwes on the same string, you gain a lot of time in cpp
Anonymous
when you change the string, it Updates the size
Hmm got it I'll check the mem managment subject tomorrow Well seems like there are interesting improvments tbqh
BinaryByter
Tldr:
BinaryByter
Dont use new or delete
BinaryByter
Prefer references over pointers
BinaryByter
Prefere smart pointers over pointers
BinaryByter
Prefer std::vector or std::array over c arrays
BinaryByter
In general, prefer the stuff provided in the stdlib xD
MᏫᎻᎯᎷᎷᎬᎠ
Why still some ppl use C?
BinaryByter
Why still some ppl use C?
In SOME embedded systems that dont have a good enougb cpp compiler it makes sense
BinaryByter
But else, its just because of dogma
MᏫᎻᎯᎷᎷᎬᎠ
It does not support even overloading function
MᏫᎻᎯᎷᎷᎬᎠ
It does, iirc
Sure about that?
BinaryByter
Pretty sure yea
MᏫᎻᎯᎷᎷᎬᎠ
Weird
BinaryByter
It doesnt support operator overloading though
BinaryByter
Which is a great pro of cpp
BinaryByter
UDLs are such a great idea
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
That function
BinaryByter
❤️
❤️
MᏫᎻᎯᎷᎷᎬᎠ
system(char*)
MᏫᎻᎯᎷᎷᎬᎠ
I'm in love with it💕
BinaryByter
system(char*)
Where is that function?
MᏫᎻᎯᎷᎷᎬᎠ
BinaryByter
Ewww
BinaryByter
Cpp is better
MᏫᎻᎯᎷᎷᎬᎠ
Just #include<stdlib.h>
MᏫᎻᎯᎷᎷᎬᎠ
system(char*)
This func can run cmd commands if u r using Windows
MᏫᎻᎯᎷᎷᎬᎠ
Just pass the command as char*
BinaryByter
use cerr or clog instead of that btw
BinaryByter
They accept modern strings and are clearer of intent
MᏫᎻᎯᎷᎷᎬᎠ
Last time I shut down my windows
BinaryByter
system works on linux too iirc
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Try it
MᏫᎻᎯᎷᎷᎬᎠ
I guess
BinaryByter
Though piping to /bin/bash is clearer
BinaryByter
@QNeko correct me if im wrong
MᏫᎻᎯᎷᎷᎬᎠ
Though piping to /bin/bash is clearer
I hope one day to master that Linux 💔
MᏫᎻᎯᎷᎷᎬᎠ
Kali linux❤️
BinaryByter
No dont go with kali
BinaryByter
Go with fedore
BinaryByter
Fedora
BinaryByter
Kali is for skids lol
MᏫᎻᎯᎷᎷᎬᎠ
Why
BinaryByter
Anyway, sleep time