Skip to content

Instantly share code, notes, and snippets.

View mostsignificant's full-sized avatar
🚀

Christian Göhring mostsignificant

🚀
View GitHub Profile
I welcome any visitors, I’m a staple in the home
My day starts in the evening and as an after-work throne
When most of time used in a horizontal state, so
You can always count on me when feeling like a po-ta-to
Though I am with you all night long you leave me in the morning
It doesn’t give me much surprise, a tune plays as a warning
You use two of me, arranged during well-defined routines
Nearest when you’re resting and closest in your dreams
I come with you to many places on trips and during travel
In civilised territory: I don’t like soil, I don’t like gravel
Thanks to physics, power and transmission
I help you undertake an expedition sans emission
You fill me up with water, but never take a sip
I am a great companion when the climate starts to dip
I’m useless when I’m empty and unsafe when too hot
And as time slowly passes by my energy is lost
I’m much longer than I am wide, so flat when I’m awake
But curled up tight and on my side when I can take a break
I help you reach your very goals, support you from the ground
It’s funny how each time you work I’m always lying down!
@mostsignificant
mostsignificant / main-signatures.cpp
Last active October 16, 2021 23:34
blog-main-signatures
(1) int main(void) { /* ... */ }
(2) int main(int argc, char *argv[]) { /* ... */ }
@mostsignificant
mostsignificant / main-args-printing.cpp
Created October 16, 2021 23:36
blog-main-args-printing
#include <algorithm>
#include <iostream>
int main(int argc, char *argv[]) {
std::copy(argv, argv + argc, std::ostream_iterator<char *>(std::cout, "\n"));
// ...
}
@mostsignificant
mostsignificant / main-bonus-signature.cpp
Created October 17, 2021 14:42
blog-main-bonus-signature
(3) int main(int argc, char *argv[], char *envp[]) { /* ... */ }
@mostsignificant
mostsignificant / input-args-checking.cpp
Last active October 18, 2021 22:37
blog-input-args-checking
if (argc < 2) {
std::cerr << "dog: missing input file!\n";
std::cerr << "usage: dog <input_file> ...\n";
return EXIT_FAILURE;
}
@mostsignificant
mostsignificant / input-file-opening.cpp
Last active October 18, 2021 22:39
blog-input-file-opening
for (auto i = 1; i < argc; ++i) {
std::ifstream input_file(argv[i], std::ios::in);
if (!input_file.is_open()) {
std::cerr << "dog: could not open input file '" << argv[i] << "'!\n";
return EXIT_FAILURE;
}
// ...
}