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.
Activity for Lundin
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Answer | — |
A: Is this a good fit for Code Reviews, and if so, how to best post it? 400 lines is not that big, it should be fine to post the complete program below the Code Reviews post category. I'd post it as separate code formatted blocks with one block per file indeed. A reviewer can then fairly easily reproduce the project. Plus then you'll get a review on the overall design... (more) |
— | over 2 years ago |
Comment | Post #284178 |
In the old C language version C90 ("ANSI-C") the rounding direction of division of negative integers wasn't well-defined. So C90 compilers could either round up or down, it's implementation-defined. That is, they didn't necessarily round towards zero but could always round "down", which means that ne... (more) |
— | over 2 years ago |
Edit | Post #284085 |
Post edited: |
— | over 2 years ago |
Edit | Post #284085 | Initial revision | — | over 2 years ago |
Answer | — |
A: Are there practical reasons for designing a method-only class/object? Many languages support the concept of functors or function objects which are classes only containing a method/member function. Most notably C++ STL was designed around this - whenever you declare a C++ standard container class object, you have the optional argument defining how that container is s... (more) |
— | over 2 years ago |
Comment | Post #284078 |
@#8049 Aha, in that case ignore my comment. Though in case GPG is an implementation of PGP maybe there should be some tag hierarchy there. (more) |
— | over 2 years ago |
Comment | Post #284078 |
You just invented a tag called GPG? Was that intentional? PGP is some archaic encryption method but I haven't heard of GPG. (more) |
— | over 2 years ago |
Edit | Post #283890 |
Post edited: |
— | over 2 years ago |
Edit | Post #283890 | Initial revision | — | over 2 years ago |
Answer | — |
A: How to do private encapsulation in C? 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 (which I won't address in this answer). It allows multiple object instances of the same class. Opaque ... (more) |
— | over 2 years ago |
Edit | Post #283888 | Initial revision | — | over 2 years ago |
Question | — |
How to do private encapsulation in C? 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 for my class and placing the struct definition in the header file, then designing the API around this and... (more) |
— | over 2 years ago |
Comment | Post #283867 |
@#53919 The programmers who make the compiler port to that specific system sets it up. (more) |
— | over 2 years ago |
Comment | Post #277486 |
@#54212 C (and C++) doesn't have much in the way of program safety. They leave that to the programmer. This is one of the reasons why C is so much faster and suitable for hardware-related programming. More freedom, but more things that can go wrong. You can't really compare it against Java or C# beca... (more) |
— | over 2 years ago |
Edit | Post #283868 |
Post edited: |
— | over 2 years ago |
Edit | Post #283868 | Initial revision | — | over 2 years ago |
Answer | — |
A: What might happen if I ignore warning? Warnings most often mean "here is a bug which will likely cause your program to crash or misbehave". They do not mean "here's something that you can optionally fix when you can spare the time". See What must a C compiler do when it finds an error? In your specific case, ignoring the warning leads ... (more) |
— | over 2 years ago |
Edit | Post #283867 | Initial revision | — | over 2 years ago |
Answer | — |
A: How allocated memory is calculated? The size of the "primitive data types" int, float etc is not defined by the standard. In practice, int is either 16 or 32 bits on all known systems. Because of the unspecified size leading to poor portability of the primitive types, the stdint.h library was introduced back in 1999, containing fixe... (more) |
— | over 2 years ago |
Comment | Post #283671 |
When I click on the score button, I explicitly want to sort the answers by score. But it doesn't happen. If this is by design, then why is the button there, since it does nothing? (more) |
— | over 2 years ago |
Edit | Post #283667 | Initial revision | — | over 2 years ago |
Question | — |
Sorting answers by score appears to be broken https://software.codidact.com/posts/277536/278390?sort=score At the point when I'm posting, the answer by Lundin has +14 score and the answer by dmckee has +11 score. Neither has any down votes. Yet when I sort by score, it doesn't show the answer with highest score first. Clicking on "score"... (more) |
— | over 2 years ago |
Edit | Post #283441 |
Post edited: |
— | over 2 years ago |
Edit | Post #283441 |
Post edited: |
— | over 2 years ago |
Edit | Post #283441 |
Post edited: |
— | over 2 years ago |
Edit | Post #283441 | Initial revision | — | over 2 years ago |
Answer | — |
A: How to declare variable-length arrays correctly? C programs are executed from top to bottom. You can't declare a VLA with an uninitialized variable as its size parameter. For the same reason at you can't do this: ```C int x; printf("%d\n",x); scanf("%d",&x); ``` If I type `5` as input to this program, then it doesn't magically go back and... (more) |
— | over 2 years ago |
Edit | Post #283440 | Initial revision | — | over 2 years ago |
Question | — |
How to declare variable-length arrays correctly? This is meant as a FAQ Q&A regarding variable-length arrays (VLA). The two bugs described below are surprisingly common. I'm trying to use the variable-length arrays feature of C99 (and newer) but I'm facing problems with it. - Whenever I write a program like this, I get strange crashes and... (more) |
— | over 2 years ago |
Comment | Post #282834 |
@istiak Inheritance means an "is a" relation. "A dog is an animal". You can't have polymorphism without inheritance. They aren't mutually exclusive or something. Inheritance without polymorphism means that if the MakeNoise function got called as per my example, the function of the base class would be... (more) |
— | almost 3 years ago |
Edit | Post #282834 | Initial revision | — | almost 3 years ago |
Answer | — |
A: What's the difference between Inheritance and Polymorphism? > Does Inteheritance actually meant return and Polymorphism meant to print out values? This doesn't make the slightest sense... Probably you should forget all you've heard - don't "watch tutorials", start over with a good book on the subject written by an actual expert. To answer the questions,... (more) |
— | almost 3 years ago |
Comment | Post #282685 |
You can ask on their meta if the question would be on-topic there. (more) |
— | almost 3 years ago |
Comment | Post #282708 |
How can an off-topic answer even be good or of high quality? That's contradicting. Unless our ambition is to create an "ask about stuff" community where literally everything is on-topic. (more) |
— | almost 3 years ago |
Comment | Post #282685 |
The question is borderline off-topic... but you might want to consider a format which can be used by parsers to present the text in pretty ways. CSV, XML or Doxygen. (more) |
— | almost 3 years ago |
Edit | Post #282676 |
Post edited: |
— | almost 3 years ago |
Edit | Post #282676 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Why does this code that uses a pointer-to-pointer-to-int segfault? Bugs: - `int range = 0;` should be `int range;` and then call the function like ` ftultimaterange(&range, min, max);`. That's the whole reason the parameter is pointer-to-pointer, so that you can return a malloc:ed pointer through a parameter. - `while (min `length` (more) |
— | almost 3 years ago |
Comment | Post #282567 |
@#54114 Ignoring the "re-inventing C" argument, then your code is still more verbose than canonical C, which would be `char c = 'A'; say((int)c);`. (Though `'A'` is actually of type `int` to begin with) (more) |
— | almost 3 years ago |
Comment | Post #282567 |
@#54114 You don't need to put them in the .c file. Whether to keep them in the .h file or its corresponding .c file is mostly a matter of style. (more) |
— | almost 3 years ago |
Comment | Post #282558 |
Indeed. This doesn't seem to answer the question, but just tosses out a bunch of generic opinions about random assorted programming languages, without any specific context in mind. (more) |
— | almost 3 years ago |
Edit | Post #282567 | Initial revision | — | almost 3 years ago |
Answer | — |
A: BMPL: The language I'll bring to life First of all, I realize that this is mostly a library you've implemented while learning programming, for the sake of learning, which is great. So I would rather not put a "wet blanket" over your attempts of coding and coming up with libraries, keep on doing that! However, I hope you realize that a... (more) |
— | almost 3 years ago |
Comment | Post #282559 |
How is one expected to use this library? It is custom for library APIs to have one "super header" including all other headers of that library, so I'd expect to find some "bmpl.h" and only include that one. (Note that "super headers" is generally bad practice except for front-end to large libraries.) ... (more) |
— | almost 3 years ago |
Edit | Post #282565 |
Post edited: |
— | almost 3 years ago |
Edit | Post #282566 | Initial revision | — | almost 3 years ago |
Answer | — |
A: What compiler options are recommended for beginners learning C? 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 default set to include non-standard language extensions. These extensions are known as "GNU C" and ex... (more) |
— | almost 3 years ago |
Edit | Post #282565 | Initial revision | — | almost 3 years ago |
Question | — |
What compiler options are recommended for beginners learning C? 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 chasing down the bug but failed. Then upon viewing their code, I notice that the code should never have "... (more) |
— | almost 3 years ago |
Edit | Post #282489 |
Post edited: |
— | almost 3 years ago |