Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Posts by Lundin
The C standard does not speak of "errors" and "warnings", those are not formal terms. The compiler is only required to produce a diagnostic message, as specified in C11 5.1.1.3: Diagnostics A c...
So it appears that we've gotten our first "company tag", Apple. We know from SO that company name tags were always problematic since: Questions are about products, not companies. Given that the pr...
Whenever registering to diverse sites on the net, you are often forced to enter a so called "strong password", which would ideally contain both upper case letters, lower case letters, digits, and s...
What exactly must a C compiler do when it finds a compile-time error? The most obvious kind of errors are language syntax errors, but the C standard also speaks of constraints, which are rules tha...
The C language has gone through many iterations and the latest one not yet released is informally called "C23", supposedly because they hoped to release it in 2023. The latest draft version N3096 i...
By having decent source code formatting that isn't completely inferior to other sites like Stack Overflow. We might want to post/view snippets longer than 13 lines without suffering some scroll whe...
The concept you are looking for is referred to as opaque type or opaque pointers. This is the proper method to achieve private encapsulation in C and can also be used for inheritance/polymorphism (...
We can't go and shamelessly promote Codidact in SO comments etc just for the sake of it - that's regarded as spamming and might get you banned, plus it will give Codidact a nasty rep. Similarly, SE...
I heard rumours that the strcpy function is dangerous and shouldn't be used. Supposedly it can be exploited to create buffer overflows somehow. And indeed when I compile my C code in the admittedl...
C23 will be a major revision, certainly the biggest one since C99. It contains lots of changes and new features, both big and small. The linked draft in the question contains a complete list of cha...
What exactly does the static keyword do in C? I have seen it used in several diverse contexts: 1) As a variable outside a function: #include <stdio.h> static int x = 5; int main (void) ...
After some more experience from this bot over a couple of months, I would say that we should ban it simply because: The answers it gives are often wrong. ChatGPT has been hyped up ridiculously. I...
"Stack vs heap" is a common over-simplification and not really a meaningful one, since those two areas have quite different, specialized uses. And no, those are not the only memory regions used by ...
Storage class specifiers static is strictly speaking a storage class specifier, which is an attribute given to a variable or a function stating how it is allocated, how it is accessible and how lo...
Search engine optimization? I thought this goes without saying, but apparently we aren't doing too well there for some reason. The other day I was having a discussion with someone at SO regarding...
Undefined behavior (informally "UB") is a formal term in the C language, defined in C17 3.4.3 undefined behavior behavior, upon use of a nonportable or erroneous program construct or of erroneous ...
Not using braces is considered bad practice by widely recognized industry coding standards (MISRA-C:2012 rule, 15.6, CERT C EXP19-C and others). Once upon a time I liked to skip out braces too, bu...
My recommended beginner setup for gcc-like compilers is: -std=c11 -pedantic-errors -Wall -Wextra -Werror Here is an explanation of what these options do: -std=c11. gcc & friends are by d...
When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chas...
Generally speaking, pointer arithmetic is undefined behavior unless carried out on arrays. This is how the additive operators behave, C17 6.5.6: For the purposes of these operators, a pointer to...
When writing any form of custom function such as this: void func (int* a, int* b) Should I add code to check if a and b are null pointers or not? if(a == NULL) /* error handling */ When po...
I'm using an object-oriented design for my C project and trying to implement classes with private encapsulation. How do I do this? Some things I've tried that are problematic: Using a struct f...
Codidact has already managed somewhat to separate domain knowledge from moderator suitability. So far so good, but reputation is also a measurement of activity. It might make sense that being acti...
This goes back to the various CPU architecture "wars" in the 1970s-1980s between the competitors Intel and Motorola (for example Intel 8086 vs Motorola 68000). For various reasons, CPUs from these ...
I have created this sensational program: #include <stdio.h> int* func (void) { int local=5; return &local; } int main (void) { printf("%d\n", *func()); } This prints 5 even thoug...