BinaryByter
I wish it was as easy as in clinl
BinaryByter
just fill the VGA buffer with 0000
BinaryByter
;D
Talula
If you're on Pure CLI it would work but in Windows or Linux emulated CLI it wouldn't.
BinaryByter
you don't have access to the vga buffer in pure CLI
BinaryByter
i'll write somethign for you
Talula
Talula
I don't know but std:cout « "\0"; would mean end of string.
Talula
It wouldn't even go to 3.
BinaryByter
#include <iostream>
#include <system>
#ifdef __linux__
namespace std{ struct clscr_t{} clscr;
std::ostream& operator<< (clscr_t a, std::ostream& b) {
std::system ("clear");
}
}
#endif
#ifdef _WIN32
namespace std{
struct clscr_t{} clscr;
std::ostream& operator<< (clscr_t a, std::ostream& b) {
std::system ("cls");
}
}
#endif
BinaryByter
BinaryByter
according to my scarse research you can't
BinaryByter
it gets the job done
BinaryByter
this is probably the best way
BinaryByter
atleast it's the one thats the clearest of intent
BinaryByter
usage:
std::cout « clrscr « "\n";
BinaryByter
not tested, might produce a lot of compiler errors
BinaryByter
pm me the compiler errors i'll fix em
olli
BinaryByter
BinaryByter
that was new to me
BinaryByter
#include <iostream>
#include <system>
#ifdef __linux__
struct clscr_t{} clscr;
std::ostream& operator<< ( std::ostream& b, clscr_t a) {
std::system ("clear");
}
#endif
#ifdef _WIN32
struct clscr_t{} clscr;
std::ostream& operator<< ( std::ostream& b, clscr_t a) {
std::system ("cls");
}
#endif
BinaryByter
@stevewozniak
BinaryByter
use this one
BinaryByter
which one?
BinaryByter
mine?
Randy
vector<vector <int>>v(5,vector<int>());
can anyone explain me this declaration
BinaryByter
you make a vector of vectors of int
BinaryByter
please google next time before asking here
Randy
2d vector i know it
Randy
what does the bracket states(5,vector<int>())
BinaryByter
are you talking about the contructor?=
BinaryByter
this is the so-called fill constructor
BinaryByter
it's not as beautiful as mine ;)
BinaryByter
Yep
BinaryByter
1) it's encapsulated in a weird namespace
2) mine mimics a std-cout modifier
BinaryByter
also mine will work on windows AND on linux
BinaryByter
and it is clear of intent
olli
I think both are not great.. :D
olli
BinaryByter
BinaryByter
but it might be overkill
BinaryByter
its not C++ standard though
BinaryByter
yea
olli
I dont like system, you're basically creating a process to clear your screen
BinaryByter
google
klimi
i dont need to be admin
BinaryByter
klimi
cuz we are admins
klimi
lol
BinaryByter
Hi!
olli
and i don't like the idea of cleaning your screen by printing something. Imho not that clear intent. Package this into a function like clearScreen()
BinaryByter
BinaryByter
you don't like me as admin? 😢
klimi
klimi
i would end up banned
BinaryByter
BinaryByter
No klimi
BinaryByter
I love you ❤️
BinaryByter
#nohomo
BinaryByter
#onlyasfriends
BinaryByter
#friendzoned
klimi
y
olli
but you wrapped it inside a function.
Image at some point there might be a magical function to do this in a portable manner, say clrscr
To keep API compatibility you would just change you clearScreen function to look like
void clearScreen() {
clrscr();
}
But with the overloaded operator approach you would end up with
std::ostream& operator << (std::ostream&, const markerStruct&) {
clrscr();
}
In the overloaded function you make no use of the std::ostream operator no more. Therefore i consider this design not got, since clearing your screen can not only be done by outputting something
my opinion ¯\_(ツ)_/¯
BinaryByter
BinaryByter
i'm sorry, we can't be friends anymore
BinaryByter
¯\_(ツ)_/¯
BinaryByter
lol
BinaryByter
don't wrap it in a namespace/class
BinaryByter
it's useless
BinaryByter
UNLESS you need it to be encapsulated
olli
i like the idea to wrap it inside a functio better
@linuxer4fun you could make it "free", it does not depend on the state of your object
BinaryByter
Khaerun
why can't read binary files? is it because of struct?
Fault Segmentation (core dumped)
os gnu/linux elementary
BinaryByter
I deleted your pictures, please make ONE pastebin
BinaryByter
it's easier for us to read
BinaryByter
you can read binary files with ostream