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 |
---|---|---|---|---|
Comment | Post #285899 |
The difference between `(int*)malloc` and `(int)42` is that malloc does actually return a different type. In your integer examples, the type is already the expected `int`. Furthermore, the C language does actually not allow _any_ implicit pointer conversions except during pointer assignment. 6.5.4 _C... (more) |
— | over 2 years ago |
Comment | Post #285826 |
It's the very same thing as I mentioned here: https://software.codidact.com/posts/278910/278932#answer-278932. In fact I've stopped writing self-answered Q&A on SO and post all such content here instead. Because such posts tend to be of significantly higher quality than the average Q&A (and require a... (more) |
— | over 2 years ago |
Comment | Post #285875 |
So how about dropping the latter part of that sentence and go with something like "Best practices as long as a clear 'best' criteria is present. Examples could be: what code gives fastest execution, least memory use, widest tool support for a target, most beginner-friendly IDE for a certain language ... (more) |
— | over 2 years ago |
Comment | Post #285875 |
I think the rationale for the "best" criteria needs to be there to prevent really bad questions like "what compiler is best". Asking "what compiler is best _for a beginner using Windows_" is however quite some improvement of that question. Perhaps this should be rephrased focusing on the quality of t... (more) |
— | over 2 years ago |
Comment | Post #285836 |
Since cyclomatic complexity is the number of possible execution paths, it is expected behavior. What one can do is to keep switches simple - if they only check an integer enum which has a contiguous sequence, the switch will get optimized well. In case of floating point or strings etc, not so much. T... (more) |
— | over 2 years ago |
Comment | Post #285813 |
Similarly, how can you explain passing a function to a function, is this pass by value: `void func (void f(void));` Of course not. (more) |
— | over 2 years ago |
Comment | Post #285813 |
"if you want to pass a reference to an object you always have to be explicit about it" How do you explain this then? `void func (int arr[n]);` (more) |
— | over 2 years ago |
Comment | Post #285800 |
@#53177 Maybe give it a week at least to let more people vote and give feedback? (more) |
— | over 2 years ago |
Comment | Post #285575 |
@#54720 You could ask that as a separate question. (more) |
— | over 2 years ago |
Comment | Post #285462 |
@#54706 Essentially; if there is no rule against it people will post endless floods of copy/paste homework dumps with no effort made. This is already a massive problem at SO and they have rules against it - they even suspend people who keep posting such crap for 6 months. We should only help people w... (more) |
— | over 2 years ago |
Comment | Post #285396 |
The beginner tour: https://meta.codidact.com/tour (more) |
— | over 2 years ago |
Comment | Post #285398 |
If you intent to post in a specific group or if you know that your network contains mainly of "x" technology developers, then naturally use a post about "x". In your case maybe something about .NET? Though I'm not sure if we got many good posts about that specifically? (more) |
— | over 2 years ago |
Comment | Post #285399 |
One of the greatest benefits ought to be community-driven open source. So if we want to change something, we can. No need to scrape and bow for some non-responsive private company. (more) |
— | over 2 years ago |
Comment | Post #285351 |
I don't think this is correct - see the quote in my posted answer. Also the memory returned by malloc does not have a declared or effective type, so normal array out of bounds rules do not apply, at least not until it gets an effective type. (more) |
— | over 2 years ago |
Comment | Post #285298 |
Any variable dealing with `EOF` must be `int`, not `char`. (more) |
— | over 2 years ago |
Comment | Post #285218 |
@#54706 I don't think such an answer will be of particular high quality. This is best answered by studying the string handling chapter in a C book, then make an attempt to solve the problem and ask specific questions about the code when stuck. (more) |
— | over 2 years ago |
Comment | Post #285259 |
I now proposed to add code golf as off-topic here: https://software.codidact.com/posts/278648/285266#answer-285266 (more) |
— | over 2 years ago |
Comment | Post #285259 |
@#54706 It's always good to have a meta thread pointing out that something is off-topic, since I just now noticed that code golf and puzzles/challenges aren't covered by our on-topic page. https://software.codidact.com/help/on-topic (more) |
— | over 2 years ago |
Comment | Post #285259 |
If one checks history, the exact data is posted. The question here was posted at 2020-08-14 but Code Golf was launched 2020-11-13. I think everyone agrees that code challenges should be posted at Code Golf and that they are off-topic here. (more) |
— | over 2 years ago |
Comment | Post #285243 |
An even worse case: since this is undefined behavior, the compiler is by no means required to generate deterministic code. Check out this example with clang for x86_64 https://godbolt.org/z/EbTGWMx93. The calling convention here is that the `esi` register must be set with the value to print. Since I... (more) |
— | over 2 years ago |
Comment | Post #285218 |
I started to write a pseudo-code answer but the question is simply too broad. You need to use `strstr`, you need to use `strcpy`, you need to write a loop. Explaining how to do these things in detail is the task of the string handling chapter in your C book. I voted to close it as "too generic", plea... (more) |
— | over 2 years ago |
Comment | Post #285169 |
@#53410 It's not trivial to get 100k+ rep and a C gold badge at SO. Also it's people I've interacted with for many years and I know how good they are at C programming. Unlike random people in the average open-source project, who tend to range between mediocre and average. As for "wildly used", that c... (more) |
— | over 2 years ago |
Comment | Post #285169 |
@#53410 You aren't going to prove anything by linking random open source libraries by random people - only by providing the take from well-known C gurus. Now as it happens on SO we have some 20-30 of such very skilled C programmers pretty much unanimously agreeing that hiding pointers behind typedefs... (more) |
— | over 2 years ago |
Comment | Post #285169 |
@#53410 I'd say that the vast majority of C programmers find it bad practice. You can for example check out all the close to unanimous criticism regarding how bad the Windows API type system was designed, where the main arguments against it was its use of "Hungarian notation" and pointers hidden behi... (more) |
— | over 2 years ago |
Comment | Post #285169 |
Hiding pointers behind typedef is considered very bad practice. If you got that from a book, it's not a good book. The actual parameters here are `struct listNode **sPtr` which explains why the pointed-at address can be modified - to for example point at space obtained by a `malloc` call inside the f... (more) |
— | over 2 years ago |
Comment | Post #285177 |
Please edit the post and fix the code formatting - you have non-existent indention. (more) |
— | over 2 years ago |
Comment | Post #285148 |
Unless the strings contain any exotic characters beyond Latin English (7 bit ASCII), just type it as you would in any text editor. (more) |
— | over 2 years ago |
Comment | Post #285136 |
@#54710 Some versions of Codeblocks include old gcc/mingw versions before version 5.0.0. Those default to gnu90 and not to a modern C standard - they would exhibit this very bug about missing include that I mention. If you follow the advise in the link I gave, you should be able to use fairly old gcc... (more) |
— | over 2 years ago |
Comment | Post #285035 |
We had this very discussion before here: [Growing software.codidact](https://software.codidact.com/posts/278910). We didn't have the ability to do advertising then though, so maybe it isn't a duplicate. (more) |
— | over 2 years ago |
Comment | Post #284806 |
I know nothing of Python but this sounds like a perfect case for multi-threaded execution in parallel. Split up the 300,000 tasks over a number of threads in charge of calculating their part of the total work. (more) |
— | over 2 years ago |
Comment | Post #284849 |
@#53185 No, but unfortunately some mainstream compilers like the gcc-like ones are not set to strictly conforming C by default. Hence the provided link below bug 1, which instructs how to configure the compiler correctly to prevent the compiler from generating an executable when given non-conforming ... (more) |
— | over 2 years ago |
Comment | Post #284552 |
I suspect that what Alexei is trying to create here is a canonical meta post that we can use as reference for all meta questions of the "why did I get a down vote" flavour. Since such meta questions are both tedious and subjective (and cannot really be answered), they could be closed as duplicate to ... (more) |
— | over 2 years ago |
Comment | Post #284510 |
As for the technical content, why would you do this with multiple processes and IPC (pipes) instead of multithreading? (more) |
— | over 2 years ago |
Comment | Post #284510 |
@#53734 There's no beef as such with Stack Overflow, if that's what you refer to (references like "Somewhere Else" etc are mostly tongue-in-cheek). It's perfectly fine to refer to it (and import your content from there to here). Codidact simply strives to be something else: community-driven open-sour... (more) |
— | over 2 years ago |
Comment | Post #284413 |
This is some random library made by some random person and the link is dead. So unless you have the files on your harddrive, you can't use the lib. (more) |
— | over 2 years ago |
Comment | Post #282566 |
@#53249 The context of this post is how beginners should compile their programs. They should most definitely not be compiling code that old. In case of professionals, we all have our cross to bear in the form of maintaining old, bade code. I'm still maintaining some (naive) old code written by myself... (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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |