Sabin
header file for working in graphic
Sabin
Making shapes and geometrical representation for school project
NXiss7
Nameful
Making shapes and geometrical representation for school project
ohh, all right. OpenGL is probably overkill then
Nameful
but it can be useful to learn
Artöm
fopen returns null on error
Artöm
Yes
HLEBR
Can anybody write analog of this python code in C? import subprocess output = subprocess.getoutput("command") print("cmd: "+output)
Dima
why
HLEBR
Can anybody write analog of this python code in C? import subprocess output = subprocess.getoutput("command") print("cmd: "+output)
This code get symbols from terminal output, I don’t like to write code in python but I didn’t find analog of this in C language
Dima
pipe/fork
HLEBR
use pipes
Do u mean popen()?
HLEBR
How to use pipe ()?
Dima
google it
Dima
man pages
Anonymous
HLEBR
system("command>output"); FILE *fcmdout = fopen("output", "r");
It’s doesn’t catch output of programs, just output of commands. But python code catch output of programs
Dima
read about pipe() lol
HLEBR
read about pipe() lol
I need a function wich return char[]
Dima
I need a function wich return char[]
how come you made these tutorials without knowing that one
Dima
I need a function wich return char[]
just google “pipe c get process external output”
HLEBR
Google didn’t help me
Dima
Google didn’t help me
http://www.microhowto.info/howto/capture_the_output_of_a_child_process_in_c.html
Ибраги́м
auto fn = [&] <typename T> (std::string arg, T val) { bool empty = args[arg].empty(); if constexpr (std::is_integral_v<T>) { return !empty ? std::stoi(args[arg]) : val; } else { return !empty ? args[arg] : val; } }; Well well well
Nomid Íkorni-Sciurus
arent' constexpr those you can calculate at compile time?
Ибраги́м
Nomid Íkorni-Sciurus
oh my
Mar!o
wait how is that a constexpr ? O.o"
The type checks are compile time
Mar!o
Evaluated at compile time*
Nomid Íkorni-Sciurus
The type checks are compile time
yeah but the value is not
Nomid Íkorni-Sciurus
so it shouldn't be a constexpr
Mar!o
so it shouldn't be a constexpr
But only the if is constexpr where is another?
Ибраги́м
so it shouldn't be a constexpr
https://en.cppreference.com/w/cpp/language/if
Mar!o
The if/else is evaluated at compile time
Nomid Íkorni-Sciurus
Nomid Íkorni-Sciurus
ok, now it makes sense
Ибраги́м
Oh. I missed this one.
And this: auto fn = [&] <typename T> (std::string arg, T val) ?
Artöm
[]<auto a>(auto u){ auto t = a + u; return t; }
Nomid Íkorni-Sciurus
And this: auto fn = [&] <typename T> (std::string arg, T val) ?
oh, that is just a lambda. maybe it's the only language where I wouldn't use them inline.
Nomid Íkorni-Sciurus
uh?
Ибраги́м
That's not "just a lambda"
Nomid Íkorni-Sciurus
hmmm....?
Ибраги́м
hmmm....?
Open your, free your mind.
Ибраги́м
Let Templates flow...
Nomid Íkorni-Sciurus
wait, what do you mean
Artöm
These <> fellas
Nomid Íkorni-Sciurus
Aaaaaaaaanyway C++ lambdas are ugly compared to other languages I don't feel like having to specify the pointer types that way very natural (I mean... [&, =] wtf)
Nomid Íkorni-Sciurus
These <> fellas
No, I know what templates are. I didn't understand what's special about that lambda
Nomid Íkorni-Sciurus
it's "just" a lambda with a typename
Artöm
We hadnt it before
Nomid Íkorni-Sciurus
Ah.
Nomid Íkorni-Sciurus
that's why it didn't feel special
Nomid Íkorni-Sciurus
I still wonder why people still programs in C++ instead on moving to easier solutions. It's ok you might want to optimize and I don't think C++ has such that memory harness they usually complain about (I actually think it's a matter of experience of the programmer) but I think you should be able to use most if not all of the modern tools to write better programs for example, Haskell, OCaml, but even experimental languages like Scala and Dart, they all compile to native binary (still somewhat inefficient since they embed a whole VM, OBVIOUSLY) and they all provided (for example) generic lambdas much before C++ did I mean, take a look at the NIM programming language. It doesn't have a VM, its output binaries are light and slim and it even features STATIC DEPENDENT VARIABLES, LOL
Nomid Íkorni-Sciurus
Maybe I'm missing something anyway or I'm getting something wrong.
Nomid Íkorni-Sciurus
There's to say that languages like Go, Rust and the ones I said before, have a much smaller share rate than C++. And I think this is mostly due to the fact that it's being taught in schools (and maybe, in a bad way) than to actual usefulness.
Nomid Íkorni-Sciurus
Though. There's also to say that C and C++ have gigatons of libraries available for most of the business stuff and that, that is what carries the community and what actually the programmer is happy about (because it means better environment too) But this means also, that it's going to be very slow for C++ to adequate to the modern standard way of thinking a program.
Nomid Íkorni-Sciurus
Though. There's also to say that C and C++ have gigatons of libraries available for most of the business stuff and that, that is what carries the community and what actually the programmer is happy about (because it means better environment too) But this means also, that it's going to be very slow for C++ to adequate to the modern standard way of thinking a program.
For example. I would... NEVER want annotations in C++. They suck ordinarly and they would suck more in C++ (I actually don't think it would be an easy task to manage because... I mean you have to modify the object representation in memory to attach metadata) But they are also convenient in some situations.
Dima
I just love this language that’s why I won’t move
Nomid Íkorni-Sciurus
I just enjoy writing in cxx
which is just okay u.u"
矢田
i never really know situations that wud make me go for tiny or intel c and c+ compilers instead of gnu/gcc anybody know
NXiss7
NXiss7
which is just okay u.u"
And yeah you miss a lot about C++. It's "native", so it can run anywhere, literally. Ypu can acxess your C++ lib from any environment, you manage memory as you like (which is essential for my many projects, especially my unique pet project), you can create optimized single-executables, write one codebase maybe with some ifdefs and you have code that you compile literally on anywhere. For example, my cryptolib runs on Windows, Linux and Android from single codebase. I've written a simple desktop GUI in ImGui with full encryption support, all features of my cryptolib, fonts and icons included it's about ~900kb single static executable, just put it into your USB and use it anywhere.
NXiss7
Hell, I love this language. This was my childhood love. 😄😄😄😄😂
NXiss7
which is just okay u.u"
It's not fully but mostly C++ is "just what you use'. When you write a program in C# or Java you need to have client install whole VM to use just a few functions from it. This is really annoying to me...
Nomid Íkorni-Sciurus
What's wrong with C++? And giving example of alternatives like haskell and ocaml? There is a reason why there are few if any large projects one of those. Purity is good in theory and maybe small project but in real world large scale is a pain.
They were not examples for alternatives. I was arguing the fact that C++'s "newest" features are kind of late for the time other languages provided them.
Nomid Íkorni-Sciurus
I also said in fact that C++'s ecosystem is fine, but that is the only reason you may really want to use C++. Which is fine because it makes development a lot easier. But it means C++ will always be late.
Nomid Íkorni-Sciurus
Just, they provide much more modern implementation/concepts that C++ can. they support case classes, data classes, pattern matching, AST manipulation and advanced templating with static dependent variables, and decorators. C++ does none of these.
Nomid Íkorni-Sciurus
The reason why C++ is used more is because of the existing codebase. But they should just try to move to a new (and maybe better) technology.
Mat
I agree with @TheLonelyAdventurer