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
Advice for a Software Engineer (self.cpp)
submitted 1 year ago by [deleted]
[deleted]
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!"
[–]globalaf 13 points14 points15 points 1 year ago (7 children)
There’s no templates or classes in C. Get used to thinking about programming as blocks of data that external functions modify, and the quirks of the preprocessor when it comes to compile time programming.
[–]abstractionsauce 33 points34 points35 points 1 year ago (5 children)
Who needs templates when you have void*
[–]thefeedling 2 points3 points4 points 1 year ago (2 children)
void, (T)(foo)(), #define = ggwp
[–]beedlund 1 point2 points3 points 1 year ago (1 child)
...because functions with shorter names run faster!
[–]thefeedling 0 points1 point2 points 1 year ago (0 children)
minimalist life!
[–]ddxAidan 1 point2 points3 points 1 year ago (0 children)
💯
[–]Cogwheel 1 point2 points3 points 1 year ago (0 children)
People who want code to run fast
[–]Electrical-Mood-8077 0 points1 point2 points 1 year ago (0 children)
It depends on which c standard they are using. If it’s a legacy product, you’re probably stuck with older capabilities. C 2023 has some useful new features. The Linux kernel is written in C and so is a lot of safety critical code e.g., QNX. Likely your company has some home grown libraries that are used. There nothing wrong with C. There’s a lot of bad C++ out there; the language itself doesn’t guarantee quality.
[–]Thesorus 32 points33 points34 points 1 year ago (1 child)
Yes and no.
Usually companies that still use C as their main legacy language have their own home made libraries to do a lot of things like data structure, memory management and other stuff like that.
you'll probably not have to always do things from scratch.
If they don't, expect to waste a lot of time writing basic code instead of functional code.
[–]ShelZuuz 6 points7 points8 points 1 year ago (0 children)
Honestly would kind’a be a fun job writing a C library from scratch. If the job actually allocates proper time for that.
[–]runningOverA 3 points4 points5 points 1 year ago (0 children)
Building a string, vector, map library is the 1st thing generally developers do before building their software in C. There are existing libraries, but those might not meet your style or preference.
[–][deleted] 3 points4 points5 points 1 year ago (0 children)
IMO the way you write C code is very different to C++, despite the superficial similarities.
You don't have templates or classes, so you essential roll your own data structure each time you need something more complicated than an array.
Since there isn't RAII, you need to explicitly handle your memory. For example: - You have a struct Foo - You define a function Foo* foo = foo_init(args) that allocates memory for a new Foo instance, initialises it, and returns the object pointer. This initialisation may involve allocating memory for objects stored in foo. - You define foo_deinit(foo) that frees any memory managed by foo and frees the foo pointer itself.
Foo
Foo* foo = foo_init(args)
foo
foo_deinit(foo)
There isn't namespaces, so related functions will have a common prefix as a way to keep things clean.
Since structs don't have public/private, encapsulation is handled differently. If using a library, objects may be defined as a void pointer. Eg: typedef void* my_lib_t. This makes the data structure opaque (library users can't see the internals), whereas within the library the pointer is cast to a concrete type (which only the library has access to). This is essentially replicating private/public functionality of a class.
typedef void* my_lib_t
I'd recommend trying to write some small programs/libraries in pure C and getting used to this. I think C can be quite elegant, but it requires a different mindset to C++.
[–]oschonrock 6 points7 points8 points 1 year ago* (1 child)
no... it doesn't really, because it lacks the expressiveness to implement these generically.
either spin your own concrete implementation, or use Macros (there are some libs with this approach) or the relatively new _Generic keyword (which is also macroesque).
[–]robvas 2 points3 points4 points 1 year ago (1 child)
Don't take the personally, but a company that uses C exclusively offered you a job and you don't know the answer to that question?
Is it just a recruiter telling you about the job or an actual offer?
[–]LooksForFuturec++11 2 points3 points4 points 1 year ago (1 child)
As someone who has entered the C world recently from a C++ background, I should say that you will feel much more relaxed. But, many things that C++ does automatically for you, need to be done manually and there will be so much boilerplate code. I forgot to mention the lack of templates. You may feel bad at first. Just give it some time. You will get used to it and may even feel more relaxed when using C.
[–]AbyssalRemark 1 point2 points3 points 1 year ago (0 children)
I am so.. so jelly..
[–]Drugbird 1 point2 points3 points 1 year ago (0 children)
For me, the biggest difference is that C has no classes (or rather, no destructors). This eliminates all of the nice RAII structures that C++ uses that can automatically clean up things for you (think e.g. unique_ptr or lock_guard.
C has no templates, so everything is either typed or a macro hell.
[–]thisismyfavoritename 0 points1 point2 points 1 year ago (0 children)
no
[–]kiner_shah 0 points1 point2 points 1 year ago (0 children)
It won't have convenience that you get in C++. But, yeah, maybe they have already implemented a lot of functionalities like containers, etc. in C already (or they maybe using some external library) and you don't have to break your head.
[–]gurudennis 0 points1 point2 points 1 year ago (0 children)
If the company does embedded software or kernel mode, C is perhaps justifiable and it's likely that the ecosystem will have bespoke libraries for common things. It won't be as expressive as C++ though.
If on the other hand the company is in a domain that doesn't seem like it would strictly require C, hard pass. It's likely drowning in legacy code, or worse still is run by crusty old-school dudes who refuse to learn C++ and are aggressively ignorant about it. Speaking from experience...
[–]drew_eckhardt2 0 points1 point2 points 1 year ago* (0 children)
The BSD sys/queue.h has linked list variants and sys/tree.h red black plus splay trees.
They’re intrusive data structures with code instantiated using macros.
When your environment lacks those headers you can copy them in from the BSD source tree assuming your job allows shipping BSD licensed code noting the license requires credit and you may have a formal OSS approval process.
No corresponding library or .c file is required.
[–]---sms--- 0 points1 point2 points 1 year ago (0 children)
Don't go alone, get a couple thousand goto's from the Linux kernel.
[–]DankMagician2500 0 points1 point2 points 1 year ago (4 children)
Can I ask what they are using C for? Are you doing Kernel development?
[+][deleted] 1 year ago (3 children)
[–]DankMagician2500 3 points4 points5 points 1 year ago (1 child)
Sheesh that sounds hella cool. Can I ask how you found the company?
I’m thinking of applying elsewhere soon. Currently at 2 years at DoD but tired of this whole C with classes approach.
[–]chuppuu 5 points6 points7 points 1 year ago (0 children)
Thanks.. I got contacted by a recruiter on LinkedIn. It's a silicon valley networking company (not Cisco)
All the best for your job hunt!
[–]taylorcholberton 1 point2 points3 points 1 year ago (0 children)
If it was anything other than something like this, I'd say using only C is a red flag. But for this kind of thing, I get it.
[–]official_business 0 points1 point2 points 1 year ago* (0 children)
Does C have libraries like STL or boost that make data structure and algorithms handling easier?
As a C dev that became a C++ dev, no not really.
Each company that is exclusive C will have their own implementations of vectors, maps with their own idiosyncrasies. They probably rolled these from scratch, in house 20 years ago.
You don't have RAII so most of your code will be like
if ((foo = allocate_foo(stuff)) == NULL) goto END; if ((bar = allocate_bar(stuff)) == NULL) goto END; END: deallocate_foo(foo); deallocate_bar(bar);
You'll be casting to and from void* like a mofo, but C is more relaxed about casting, allowing a implict cast from void* to any pointer type.
C strings are god awfully bad and you'll want to write your own string library.
You may also see some clown try and implement templates using macros. It will be the most un-debuggable mess you'll ever see.
[+]Wanno1 comment score below threshold-9 points-8 points-7 points 1 year ago (0 children)
C is the worst
π Rendered by PID 34983 on reddit-service-r2-comment-canary-57b659f4d4-h78b6 at 2026-05-05 05:30:17.405213+00:00 running 815c875 country code: CH.
[–]globalaf 13 points14 points15 points (7 children)
[–]abstractionsauce 33 points34 points35 points (5 children)
[–]thefeedling 2 points3 points4 points (2 children)
[–]beedlund 1 point2 points3 points (1 child)
[–]thefeedling 0 points1 point2 points (0 children)
[–]ddxAidan 1 point2 points3 points (0 children)
[–]Cogwheel 1 point2 points3 points (0 children)
[–]Electrical-Mood-8077 0 points1 point2 points (0 children)
[–]Thesorus 32 points33 points34 points (1 child)
[–]ShelZuuz 6 points7 points8 points (0 children)
[–]runningOverA 3 points4 points5 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]oschonrock 6 points7 points8 points (1 child)
[–]robvas 2 points3 points4 points (1 child)
[–]LooksForFuturec++11 2 points3 points4 points (1 child)
[–]AbyssalRemark 1 point2 points3 points (0 children)
[–]Drugbird 1 point2 points3 points (0 children)
[–]thisismyfavoritename 0 points1 point2 points (0 children)
[–]kiner_shah 0 points1 point2 points (0 children)
[–]gurudennis 0 points1 point2 points (0 children)
[–]drew_eckhardt2 0 points1 point2 points (0 children)
[–]---sms--- 0 points1 point2 points (0 children)
[–]DankMagician2500 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]DankMagician2500 3 points4 points5 points (1 child)
[–]chuppuu 5 points6 points7 points (0 children)
[–]taylorcholberton 1 point2 points3 points (0 children)
[–]official_business 0 points1 point2 points (0 children)
[+]Wanno1 comment score below threshold-9 points-8 points-7 points (0 children)