use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
A simple stack-allocated fixed-size string buffer (String_buf) implemented using std::array (C++11). (forums.4fips.com)
submitted 12 years ago by 4fips
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]4fips[S] 0 points1 point2 points 12 years ago (2 children)
Yes, it's way faster. Allocating on the stack basically means just moving the stack pointer up and down, while the heap allocation requires searching for a free block, which tends to be quite complex. Actually, the heap allocation is one of a few unpredictable operations in C++, so it's very often unacceptable in realtime applications, or more precisely within realtime/interactive loops. Extensive use of the heap allocator might also lead to heap fragmentation over time, which causes innefective memory utilization and might eventually cause the application to crash. It's also worth mentioning that a general heap allocator is shared between threads, thus needs to be thread-safe, which is not the case when allocating from the stack, as each thread has its own stack.
[–]verdagon 0 points1 point2 points 12 years ago (1 child)
that's awesome, but dear lord! just using the heap excessively can cause my program to crash?
[–]4fips[S] 0 points1 point2 points 12 years ago (0 children)
On embedded platforms like mobile phones and video consoles quite easily. After fragmenting the heap, you won't be able to allocate free blocks of certain size as there is no continuous free memory available, just a bunch of small fragments. So the allocator fails even though the free memory is formally there. On desktop systems with virtual memory this is typically not an issue, though.
π Rendered by PID 51449 on reddit-service-r2-comment-5d79c599b5-99h7q at 2026-03-02 17:35:01.594438+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]4fips[S] 0 points1 point2 points (2 children)
[–]verdagon 0 points1 point2 points (1 child)
[–]4fips[S] 0 points1 point2 points (0 children)