"""Modern C++""" what's the catch? - /g/ (#105681001) [Archived: 822 hours ago]

Anonymous
6/23/2025, 4:53:39 PM No.105681001
maxresdefault
maxresdefault
md5: 573d3c580c48e9f6f571b437783ba4f2🔍
I haven't touched C++ in a very long while.
I believe the last C++ revision I used was C++14.
I'm impressed by how much it's changed. I want to use some of its "new features" but I am afraid some might be memes that just introduce more problems
I need /g/ to enlighten me on it
Especially on ranges.
I am impressed you can do this in C++ now :
#include <string>
#include <cctype>
#include <ranges>
using namespace std;
bool isPalindrome(string s) {
auto alnum_lower = s | views::filter([](char c) {
return isalnum(static_cast<unsigned char>(c));
})
| views::transform([](char c) {
return tolower(static_cast<unsigned char>(c));
});

auto rev = views::reverse(alnum_lower);

return ranges::equal(alnum_lower, rev);
}

But there has to be some kind of catch that I simply am not aware of.
There always is with every "cool new modern feature" the Cpp committee introduces.
It's very hard to do all of these things and maintain backward compatibility with C all the while having the gigantic and old std library to maintain, and keep things consistent with all the bloated paradigms and features C++ has like templates.
And when you try to use these cool new modern features in a real code base you only realize the "catch" when it's too late and the stress is unbearable
Replies: >>105681190 >>105681192 >>105681237 >>105682927 >>105683000 >>105683130 >>105683138 >>105683279 >>105683563 >>105683651 >>105683698 >>105683887 >>105686355 >>105686885 >>105688892 >>105691031 >>105691384 >>105694663 >>105695737 >>105696288 >>105696552 >>105703081
Anonymous
6/23/2025, 4:54:56 PM No.105681009
the catch is immense bloat and tons of overhead
Replies: >>105683563 >>105694717
Anonymous
6/23/2025, 5:19:58 PM No.105681190
>>105681001 (OP)
17 gave us smart pointers which is handy for making your own garbage collection.
20 gave some threading convenience shit. modules are absolutely worthless and nobody switched to using them. I just stick to 17. the computer is jerking themselves over reflection in the new proposal but idrc. If only they packed in a proper build system and package management, noobs wouldn't think it's so scary. snake case is retarded too
Replies: >>105681195 >>105681229 >>105681329 >>105691411 >>105691528
Anonymous
6/23/2025, 5:20:26 PM No.105681192
>>105681001 (OP)
i don't care about backwards compatibility with C
templates are based, metaprogramming is based, algorithms, functional, ranges, variant, consteval, if constexpr, concepts and requires.... all of them BASED
many of the actually useful things in le modern C++ do not introduce unnecessary runtime overhead and can literally result in faster code
i ship most of my returning interface functions with a [[nodiscard("fuck you for discarding this value that i just returned to you")]]
mind you that I am an embedded SWE and therefore HATE dynamic memory, especially that which is embedded into the STL, so I avoid some parts of it like the plague
compile times are increased, thats for sure, but compile times are usually a non-issue at least in embedded. if it takes 1 minute 30 seconds instead of 1 minute to compile it doesnt matter, especially when you can get so many compile-time guarantees for free
Replies: >>105682624 >>105682959
Anonymous
6/23/2025, 5:20:59 PM No.105681195
>>105681190
>computer
*comitee
Anonymous
6/23/2025, 5:26:12 PM No.105681229
>>105681190
hey now, 20 gave us concepts, requires, consteval, ranges, span, std::remove_cvref, and something that, for no reason, has been withheld from us for decades, AGGREGATE INITIALIZATION USING DESIGNATED INITIALIZERS
Replies: >>105695701
Anonymous
6/23/2025, 5:26:40 PM No.105681237
>>105681001 (OP)
It's unfortunate, filter is the most interesting range but also the most broken one and you should not be using ranges at all because the committee got them wrong, they are a dead feature, should never be used.
https://www.youtube.com/watch?v=c1gfbbE2zts
Replies: >>105683042
Anonymous
6/23/2025, 5:36:49 PM No.105681329
>>105681190
20 also gave std::format and std::print, those are good
Anonymous
6/23/2025, 8:23:22 PM No.105682624
>>105681192
>i don't care about backwards compatibility with C
c++ is not compatible with c in any way
Replies: >>105683241
Anonymous
6/23/2025, 8:57:30 PM No.105682927
>>105681001 (OP)
Modern c++ rivals rust in ugliness.
Anonymous
6/23/2025, 9:00:16 PM No.105682959
>>105681192
if constexpr is almost completely worthless. What a complete joke, a quintessential example of everything wrong with c++. Each new feature is as crippled and minimally useful as possible.
Replies: >>105685783
Anonymous
6/23/2025, 9:03:26 PM No.105682996
Don't they ensure backwards compatibility? Then the version doesn't matter. It's only bad if you work with others then they will fuck your project up with c++ shit that's bad.
Anonymous
6/23/2025, 9:03:47 PM No.105683000
>>105681001 (OP)
>what's the catch?
it's inferior to Rust.
Replies: >>105683314
Anonymous
6/23/2025, 9:08:06 PM No.105683042
>>105681237
>first few seconds is some woman
C++ has fallen.
Anonymous
6/23/2025, 9:08:35 PM No.105683048
is there a subset of C++ that will be as comfy as java?
im brown btw
Anonymous
6/23/2025, 9:19:31 PM No.105683130
>>105681001 (OP)
The only big thing since C++14 is concepts.
The real big bang will be reflection, which the committee approved for C++26. Codebases after that will be completely different and unreadable compared to C++23.
Replies: >>105687101
Anonymous
6/23/2025, 9:20:42 PM No.105683138
>>105681001 (OP)
>auto alnum_lower = s | views::filter([](char c) {
> return isalnum(static_cast<unsigned char>(c));
> })
> | views::transform([](char c) {
> return tolower(static_cast<unsigned char>(c));
> });
Where is the collection expression?
Replies: >>105683187
Anonymous
6/23/2025, 9:28:39 PM No.105683187
>>105683138
string has a .begin() and .end() so it counts
Anonymous
6/23/2025, 9:34:25 PM No.105683226
https://arewemodulesyet.org/
There has actually been substantial progress because last time I checked the ETA was in the 26th century. Now I’m filled with optimism, we might actually get full modules support within this millennium!
Replies: >>105696236 >>105696284
Anonymous
6/23/2025, 9:35:44 PM No.105683241
>>105682624
Sort of. I do always write DLL interfaces C style. Not just for compatibility with C but for compatibility with any C++ standard library.
bruce3434
6/23/2025, 9:40:03 PM No.105683279
>>105681001 (OP)
Modern C++ can be pretty cool but the fundamental problem is that majority of the C++ ecosystem is stuck in C++11 or 14. C++ has a baggage of "C compatibility"
Rust is what modern C++ wants to be but can't because of that baggage.

fn is_palindrome(s: &str) -> bool {
// no allocation, case sensitive
let lhs = s.bytes().take(s.len() / 2);
let rhs = s.bytes().skip(s.len() / 2).rev();
lhs.zip(rhs).all(|(c1, c2)| c1 == c2)
}
Replies: >>105683367 >>105686943 >>105693208 >>105703081
Anonymous
6/23/2025, 9:44:09 PM No.105683314
>>105683000
compiles faster more powerful &has more jobs
Replies: >>105689191
Anonymous
6/23/2025, 9:49:53 PM No.105683367
>>105683279
fn is_palindrome(s: &str) -> bool {
let bytes = s.as_bytes();
let len = bytes.len();
bytes[..len/2].iter().zip(bytes[len/2..].iter().rev()).all(|(&a, &b)| a == b)
}
Replies: >>105683470 >>105686943 >>105689202 >>105693208 >>105703081
bruce3434
6/23/2025, 10:01:07 PM No.105683470
>>105683367
I'd be surprised if LLVM doesn't optimize the two calls to bytes and len
Replies: >>105683535
Anonymous
6/23/2025, 10:07:43 PM No.105683535
>>105683470
uhh...
https://godbolt.org/z/G8h5eocMc
Replies: >>105683576
Anonymous
6/23/2025, 10:10:49 PM No.105683563
>>105681009
fpbp
>>105681001 (OP)
just stick with c++14, the best version of the language
bruce3434
6/23/2025, 10:12:08 PM No.105683576
>>105683535
Oh wow, I'm slightly disturbed.
Anonymous
6/23/2025, 10:20:35 PM No.105683651
>>105681001 (OP)
compile times it goes from sub 100ms to 4s on a modern laptop as soon as you got a couple files. It also isn't as well integrated as in other languages like in rust or c# where you can just use a third party library that implements the same interface.
Anonymous
6/23/2025, 10:27:33 PM No.105683698
>>105681001 (OP)
>what's the catch
That your company still uses a version from the late 90s and you won't see the benefits until 2040
Anonymous
6/23/2025, 10:54:35 PM No.105683887
>>105681001 (OP)
Look at this mess. Even Lisp is more readable. God have mercy on the poor souls who do C++ for a living.
Replies: >>105686887
Anonymous
6/24/2025, 3:28:28 AM No.105685783
file
file
md5: 21e59acc5bcd4f62168243a18d7295f6🔍
>>105682959
I thought if constexpr just has the compiler generate the branch that evaluates to true at compile time thus minimizing the amount of code in the final binary? seems pretty useful to me
Replies: >>105686896 >>105687425
Anonymous
6/24/2025, 4:56:20 AM No.105686211
I've had a greater appreciation for C++ once I started using concept and requires, but it's undeniable that they would benefit from nothing more than just ditching some of the backwards compatibility.
Having to support 50 years of C and 40 years of C++, across all of those decades of evolution is really straining it.
Replies: >>105686308
Anonymous
6/24/2025, 4:59:31 AM No.105686224
does C++ even have syntax or will the compiler accept any string of text with std:: and []() in it
Anonymous
6/24/2025, 5:14:47 AM No.105686308
>>105686211
It would help if they didn't keep introducing half-baked features with increasingly arcane syntax.
Anonymous
6/24/2025, 5:22:46 AM No.105686355
>>105681001 (OP)
I'll be sticking to 17 for the next 20 years thanks.
Replies: >>105686417
Anonymous
6/24/2025, 5:34:38 AM No.105686417
>>105686355
lmao you will probably die within 5 years.
Replies: >>105686879
Anonymous
6/24/2025, 6:57:23 AM No.105686879
>>105686417
Naw when the asteroids start hitting in 2030 I'm in a good location that has survived for tens of thousands of years. Chances are I'll be okay, as long as I get to higher ground in time.
Anonymous
6/24/2025, 6:58:19 AM No.105686885
>>105681001 (OP)
hi herb.
you suck.
Anonymous
6/24/2025, 6:58:25 AM No.105686887
>>105683887
Lisp is very easy to read because it's consistent.
Replies: >>105686902
Anonymous
6/24/2025, 7:01:18 AM No.105686896
>>105685783
constexpr allows the compiler to do a bunch of work at compile time, replacing chunks of code with a simple constant. this feature is important for reducing the burden on icache.
Replies: >>105695848
Anonymous
6/24/2025, 7:02:19 AM No.105686902
>>105686887
it makes me feel like im on /pol/
Anonymous
6/24/2025, 7:03:58 AM No.105686910
I still write mostly C++11. Hate templates. Hate auto. Hate lambda. Shit is just ugly. I like the new threading shit so I don't have to use pthreads though.
Anonymous
6/24/2025, 7:10:06 AM No.105686943
>>105683279
>>105683367
Is the last line automatically returned or something?
Replies: >>105686954 >>105693240 >>105694753
Anonymous
6/24/2025, 7:11:53 AM No.105686954
>>105686943
only if you cut your dick off
Anonymous
6/24/2025, 7:13:12 AM No.105686961
for me it's k&r c++
Anonymous
6/24/2025, 7:39:59 AM No.105687101
>>105683130
Concepts hardly add any value over normal templates beyond making intellisense work and SFINAE easy.
Coroutines are the big thing. The committee just royally fucked up by not including something as basic as std::task<T>, making std::future awaitable, etc. If you actually use a coroutine library, it completely changes the way you write C++.
Replies: >>105687152
Anonymous
6/24/2025, 7:48:55 AM No.105687152
>>105687101
>If you actually use a coroutine library, it completely changes the way you write C++.
How?
Replies: >>105687236
Anonymous
6/24/2025, 7:49:55 AM No.105687158
1728146810031209
1728146810031209
md5: f88a6db4521127b960f20cf659716c13🔍
>nooooo you have to use this language feature!
>>why?
>because it's NEEEEEEEEEEEEEEEEEEEWWWWWWWWWWWWWWWWWWWWWWWWWWW
Replies: >>105691391
Anonymous
6/24/2025, 8:02:59 AM No.105687236
>>105687152
Imagine all the things that you used to rely on callbacks for. Now you can write that as if it were synchronous code with a single co_await.
You can create thread pools that can take any function an immediately schedule it like std::async without playing with function pointers. If the function you're scheduling suspends at points, it can yield that thread back to the pool and let other coroutines use it while it waits. You can even take code that used to be multithreaded and make it event loop based just by changing the parameters of your thread pool.
Rather than blocking forever while waiting for a mutex, coroutines can suspend execution until it becomes available and let other coroutines do useful work.
Network requests, epolling, parallelism, resource synchronication, all become way easier when the compiler manages the state machine for you.
Anonymous
6/24/2025, 8:34:28 AM No.105687425
>>105685783
Most of the places where one would use if constexpr, its not actually required. The optimizer will get rid of the branch not taken even without constexpr. The problem with if constexpr, is that both branches need to be valid code which severly limits the usefulness of if constexpr, there are only a few cases where if constexpr does something that plain if cannot.
Anonymous
6/24/2025, 1:08:04 PM No.105688892
>>105681001 (OP)
Excuse me if I sound arrogant but why would one ever pick C++?
If it's lower level/embedded stuff I can see using C
C# if it's coding for windows
But what would I ever need C++ for?
Replies: >>105689224
Anonymous
6/24/2025, 1:59:32 PM No.105689191
>>105683314
>compiles faster
no, it doesn't.
>more powerful
yes, sure, also has more powerful footguns as well
>has more jobs
and? wage cucks get the rope.

you don't sound very smart.
Anonymous
6/24/2025, 2:01:08 PM No.105689202
>>105683367
you don't need as_bytes to get len in bytes:

pub const fn len(&self) -> usize

Returns the length of this String, in bytes, not chars or graphemes. In other words, it might not be what a human considers the length of the string.
Anonymous
6/24/2025, 2:04:36 PM No.105689224
>>105688892
coding for windows, unless you like a GC'd shit lang with weird behavior and 10 different "in support" versions with different tooling and subtle behavior differences.
Replies: >>105690990
Anonymous
6/24/2025, 5:31:32 PM No.105690990
>>105689224
> 10 different "in support" versions with different tooling and subtle behavior differences

isn't this same as what itt is about?
Replies: >>105692138
Anonymous
6/24/2025, 5:35:12 PM No.105691031
>>105681001 (OP)
"modern" C++ is just Rust if it was designed by an anally retentive retard, which in itself is Haskell if it was designed by an anally retentive faggot
Anonymous
6/24/2025, 6:11:49 PM No.105691384
>>105681001 (OP)
>headers
Fucking kill yourself Poopesh.
Replies: >>105692147
Anonymous
6/24/2025, 6:13:04 PM No.105691391
>>105687158
Not because it's "new", but because it's objectively superior (simpler API and faster), midwit.
Anonymous
6/24/2025, 6:13:48 PM No.105691396
Aren't all the new features just stuff from boost ported as standard libraries?
Anonymous
6/24/2025, 6:15:34 PM No.105691411
>>105681190
>modules are absolutely worthless
if it's shit why bloat the language with it...
Replies: >>105691528 >>105692147
Anonymous
6/24/2025, 6:28:52 PM No.105691528
>>105681190
>>105691411
Headers force you to fully qualify everything because muh using statements being leaked.
Also no one wants to compile the same code a hundred times just because a hundred files included it.
Anonymous
6/24/2025, 7:43:50 PM No.105692138
>>105690990
one is C++ (nightmare) the other is .NET (no excuse, literal virtual fucking machine language)
Anonymous
6/24/2025, 7:45:00 PM No.105692147
>>105691384
>modules
no one cares about your broken shitware M$ jeet.
>>105691411
because the C++ committee is wildly incompetent and full of fake news to push some garbage feature dreamed up by some overpaid retards.
Replies: >>105694798
Anonymous
6/24/2025, 9:42:49 PM No.105693146
should I learn C before learning C++? I'm mostly interested in embedded programming
Replies: >>105695446 >>105695564
Anonymous
6/24/2025, 9:50:23 PM No.105693208
>>105683279
>>105683367
https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#method.eq
Anonymous
6/24/2025, 9:53:25 PM No.105693240
>>105686943
The last line is an expression because it lacks a ;
Otherwise it would be a statement.
The compiler is smart enough to pop the value of the last expression of a block.
Replies: >>105694212
Anonymous
6/24/2025, 11:44:23 PM No.105694212
>>105693240
>returning or not depending on ;
shit design honestly, just have different syntax for single line lambdas like c#
Replies: >>105694645
Anonymous
6/25/2025, 12:32:03 AM No.105694645
>>105694212
It works very well with the fact that everything is an expression. It let's you simplify the concept of code blocks and syntax in general. It works very well with if-else and matches, skipping the need for hacky comma and ternary operators. It really is not as confusing as it might seem like.
Anonymous
6/25/2025, 12:34:22 AM No.105694663
>>105681001 (OP)
They are fine. Just use them. People just larp about them on /g/ but this board is a bunch of deranged nocoding faggots. Also don't listen to the rust memes.
Anonymous
6/25/2025, 12:40:23 AM No.105694717
>>105681009
That's utterly wrong. Most of the features introduced by c++ are zero cost abstractions (except virtual methods, inheritance, exceptions, etc.)
Replies: >>105695441 >>105695730 >>105696001 >>105696460
Anonymous
6/25/2025, 12:43:26 AM No.105694753
>>105686943
Yes. It's not just the last line of a function. Normally in other languages, you have compound statements and if statements, but in Rust, they actually serve as expressions with arbitrary code in them, as long as the last line of it is an expression of the right type. Here are some examples:
let a = {
x += 1;
println!("hello, world");
x / 2
};
let b = if a == 0 { 1 } else { a };

The fact that the last line of a function doesn't need an explicit "return" is just a special case of that.
Anonymous
6/25/2025, 12:48:14 AM No.105694798
>>105692147
>the only alternative to modules is to continue using the broken pooslop system that is header inclusion
No thanks, I would sooner use Java than ever use headers
Anonymous
6/25/2025, 2:18:08 AM No.105695441
>>105694717
hi herb. you suck.
Anonymous
6/25/2025, 2:19:12 AM No.105695446
>>105693146
don't bother with c++ and don't listen to that faggot at cppcon that says you can do embedded with c++
Anonymous
6/25/2025, 2:39:58 AM No.105695564
>>105693146
you can do embedded with C++
Replies: >>105695732
Anonymous
6/25/2025, 3:04:46 AM No.105695701
>>105681229
>aggregate initializer uses value initialization for uninitialized members
lol, why
Anonymous
6/25/2025, 3:09:22 AM No.105695730
>>105694717
People enjoy repeating that but it doesn't make it true.
Replies: >>105695877
Anonymous
6/25/2025, 3:09:34 AM No.105695732
>>105695564
>t. faggot at cppcon
Anonymous
6/25/2025, 3:10:19 AM No.105695737
>>105681001 (OP)
> modern c++
AWCH!
Anonymous
6/25/2025, 3:33:59 AM No.105695848
>>105686896
C# does that without any special keywords. it also folds branching on constant values, like #if #else
Anonymous
6/25/2025, 3:38:47 AM No.105695877
>>105695730
It literally doesn't incur runtime overhead though. Compile-time, sure, some. But who gives a fuck about that?
Replies: >>105696035
Anonymous
6/25/2025, 4:01:14 AM No.105696001
>>105694717
virtual is also zero cost under certain circumstances https://marcofoco.com/blog/2016/10/03/the-power-of-devirtualization/
Replies: >>105696220
Anonymous
6/25/2025, 4:10:09 AM No.105696035
>>105695877
Plenty of decisions CPP took adds extra overhead when it is not needed. Their design philosophy was supposed to be "you don't pay for things you don't use" but that is simply not true. The simplest counter example I can think of is static variables in function scope initialization being thread safe. You are paying for that overhead even if your entire program is thread safe.

Writing performant c++ often involves learning how language and also your compilers behave. For example consider these two functions

float add1(std::pair<float, float> p) { return p.first + p.second; }
float add2(float a, float b) { return a + b; }

You might think both are equivalent but your compilers will surprise you.
Anonymous
6/25/2025, 4:24:57 AM No.105696093
Did you know that std containers will refuse to move your objects during reallocations if your constructors aren't marked noexcept? Instead they'll silently fall back to copying. Now you do.

Too bad you didn’t read the footnote on page 93627 that explains this behavior, C++ has been ignoring your move constructors all along.

Think twice before using C++ and std.
Anonymous
6/25/2025, 4:51:02 AM No.105696220
>>105696001
Incorrect. You still pay for the vtable pointer memory cost on that object. "Zero cost" is a very objective term.
Anonymous
6/25/2025, 4:54:43 AM No.105696236
>>105683226
26th century is in this century anon
Replies: >>105696250
Anonymous
6/25/2025, 4:58:00 AM No.105696250
>>105696236
millenium*
Anonymous
6/25/2025, 5:04:09 AM No.105696284
>>105683226
it is a feature pushed by trannies in committee and no one cares. No big code base wants to rewrite their code base using modules and thus no one is pushing for it. And compilers have no incentive to support this mess

>b b but muh compile times
There are several solutions to this problem, this is more of a you problem.
Replies: >>105696483
Anonymous
6/25/2025, 5:06:00 AM No.105696288
1644807184503
1644807184503
md5: c181d927373b099262eff3164d05f1ef🔍
>>105681001 (OP)
>an idiot admires complexity, a genius admires simplicity
Replies: >>105701379 >>105703120
Anonymous
6/25/2025, 5:36:31 AM No.105696460
>>105694717
Even unique_ptr is not zero cost.
Replies: >>105698080 >>105698106
Anonymous
6/25/2025, 5:40:20 AM No.105696483
>>105696284
So naive
Anonymous
6/25/2025, 5:50:43 AM No.105696552
>>105681001 (OP)
i use c++23 and it works on my machine
imagine using anything before c++20
might as well use C instead
Anonymous
6/25/2025, 10:41:50 AM No.105698080
>>105696460
Even delete is not zero cost, who the fuck asked for nullptr check and early return
Replies: >>105698106
Anonymous
6/25/2025, 10:45:52 AM No.105698106
>>105696460
>>105698080
>zero cost
it's not zero cost, it's zero overhead
https://en.cppreference.com/w/cpp/language/Zero-overhead_principle.html
>The zero-overhead principle is a C++ design principle that states:
> 1. You don't pay for what you don't use.
> 2. What you do use is just as efficient as what you could reasonably write by hand.
Replies: >>105698147 >>105698165
Anonymous
6/25/2025, 10:52:57 AM No.105698147
>>105698106
Which is a very retarded argument from cpp committee. Implementation perhaps not adding any cost over what is being asked but it is the standard that adds the overhead.

Null check for delete is a silly example but it is still one. There was no reason to add that requirement that makes delete nullptr safe but they did. And now you have to pay for it for each delete even if your program guarantees it never calls delete using null.

If people wished a null safe delete it they could create their own.

Worse examples are probably std containers like unordered maps. The standard is extremely rigid and basically limits to implementation to a very specific one and it sucks.
Replies: >>105699288
Anonymous
6/25/2025, 10:55:03 AM No.105698165
>>105698106
Ok, unique ptr is not zero overhead then.
Anonymous
6/25/2025, 2:12:21 PM No.105699288
>>105698147
just use C
Anonymous
6/25/2025, 6:05:29 PM No.105701379
>>105696288
Your C printf(“Hello world”) isn’t impressive.
Replies: >>105701670
Anonymous
6/25/2025, 6:32:33 PM No.105701670
vfprintf-internal.c
vfprintf-internal.c
md5: ea3c82a0aed234a8e25cda4fdada7502🔍
>>105701379
If only printf was simple
Replies: >>105702724
Anonymous
6/25/2025, 8:19:20 PM No.105702724
>>105701670
your challenge, if you choose to accept it:
give a printf format string and a list of arguments, calculate the length of the output string.

so you can confidently use v/s(n)printf without buffer overflow problems.
Replies: >>105702839 >>105702977
Anonymous
6/25/2025, 8:29:52 PM No.105702839
>>105702724
snprintf(nullptr, 0, ....);
Replies: >>105702929 >>105702994
Anonymous
6/25/2025, 8:40:40 PM No.105702929
>>105702839
You have forgotten +1 for the null terminator.
Like pottery
Replies: >>105702949 >>105702965
Anonymous
6/25/2025, 8:43:22 PM No.105702949
>>105702929
>The snprintf function is equivalent to fprintf, except that the output is written into an array (specified by argument s) rather than to a stream. If n is zero, nothing is written, and s may be a null pointer.
Replies: >>105702988
Anonymous
6/25/2025, 8:45:20 PM No.105702965
>>105702929
Retard, you obviously had no idea one usage of snprintf to calculate needed buffer size since you think this is a "challenge". Stop trying to save face.
Replies: >>105702993
Anonymous
6/25/2025, 8:47:12 PM No.105702977
>>105702724
why is it puts(string, stream) and fprintf(stream, string)?
clearly that was retarded even 50 years ago
Replies: >>105702998
Anonymous
6/25/2025, 8:47:58 PM No.105702988
>>105702949
>Return Value
>The number of characters that would have been written if n had been sufficiently large, not counting the terminating null character.
The question was
>calculate the length of the output string.
So it will be
snprintf(nullptr, 0, ...) + 1;
Replies: >>105703011
Anonymous
6/25/2025, 8:48:59 PM No.105702993
17081826596307809692393941736217
17081826596307809692393941736217
md5: 5755da660336efd7a15cf4e743d620cd🔍
>>105702965
I'm not the anon who posted the challenge.
Anonymous
6/25/2025, 8:49:04 PM No.105702994
>>105702839
neat trick. i didn't know about that.
Anonymous
6/25/2025, 8:50:05 PM No.105702998
>>105702977
i meant fputs. derp
Anonymous
6/25/2025, 8:51:23 PM No.105703011
>>105702988
But then +1 is incorrect \0 is not considered part of string and not counted in strlen
Replies: >>105703029
Anonymous
6/25/2025, 8:53:58 PM No.105703029
>>105703011
Oh ok. This really is confusing when the length of string is the length of a memory slice that backs it up minus one.
Anonymous
6/25/2025, 8:54:37 PM No.105703032
more retards getting filtered by having to read the libs. C chads just cant stop winning and having sex.
Anonymous
6/25/2025, 9:00:08 PM No.105703081
>>105681001 (OP)
>>105683279
>>105683367
In Haskell, this is just
palindrome str = str == reverse str
Anonymous
6/25/2025, 9:04:26 PM No.105703120
>>105696288
t. idiot that cannot understand anything complex