Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

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 celtschk‭

Type On... Excerpt Status Date
Comment Post #293247 course here the actual storage is not in `*items` but in `*item_memory`. You cannot avoid that if you want to use double index on `items`; the only thing in C you can apply the index operator to are pointers, therefore `*index` must be a pointer.
(more)
13 days ago
Comment Post #293247 If you don't mind the extra memory, you can do it with an extra array: ```c struct basket { char *item_memory; char **items; int itemcount; }; /* I omitted any error handling */ void initialize(basket *b, int itemlen, int itemcount) { int item_index; b->item_memory = malloc(itemlen * itemcount); b->i...
(more)
13 days ago
Comment Post #293247 Not really. In C, `a[b]` is defined to be the same as `*(a+b)`. And in that expression, the array decays into a pointer. Thus when you apply the subscript operator, its first operand is always a pointer, even if by decay. Note that also `3[a]` is a valid expression if `a` is a pointer.
(more)
13 days ago
Edit Post #293247 Initial revision 14 days ago
Answer A: 2D-array pointer as a struct member
If you don't mind the extra memory, you can do it with an extra array: ```c struct basket { char itemmemory; char items; int itemcount; }; / I omitted any error handling / void initialize(basket b, int itemlen, int itemcount) { int itemindex; b->itemmemory = malloc(i...
(more)
14 days ago
Edit Post #293220 Post edited:
Added the actual question to the post instead of referring to the title. Also, added proper capitalization and punctuation.
19 days ago
Suggested Edit Post #293220 Suggested edit:
Added the actual question to the post instead of referring to the title. Also, added proper capitalization and punctuation.
(more)
helpful 19 days ago
Edit Post #292750 Initial revision 4 months ago
Answer A: How can I get the same "not all control paths return a value" behaviour across Clang and MSVC?
The reason why it is undefined behaviour instead of a hard error is that the problem of determining it is, quite literally, equivalent to the halting problem. So any implementation will either warn about cases where a return cannot actually happen,or miss cases where it can happen, or both. Different...
(more)
4 months ago
Comment Post #292748 However when it comes to NULL, C and C++ already differ in that C allows NULL to be defined as ((void)0), which C++ does not allow. So C compatibility is probably not the issue. However compatibility with previous C++ versions surely played a role in the decision.
(more)
4 months ago
Comment Post #292393 Thank you. I've used the method in the other file (mostly because I needed to stash some changes, and I'm not sure if that would have worked with your approach), so I can't honestly give you a "worked for me", although I'm sure it would have worked, too.
(more)
5 months ago
Comment Post #292394 Thanks, that worked great.
(more)
5 months ago
Edit Post #292401 Initial revision 5 months ago
Answer A: Why is the new auto keyword from C++11 or C23 dangerous?
A pitfall in C++ that I didn't see mentioned in the other answer is that it might give unexpected results with libraries using expression templates. What are expression templates? In a nutshell, expression templates are a technique that allows to write efficient numeric code with intuitive nota...
(more)
5 months ago
Comment Post #290502 If the password hashing scheme is reasonable (simply storing an SHA256 of the password is *not* reasonable!) then the password hashing rate is in no way comparable to Bitcoin hashing rates (which, indeed, are SHA256 hashes). A good password hashing implementation is tuned to need at least about ha...
(more)
5 months ago
Edit Post #292391 Initial revision 5 months ago
Question Turn all changes after latest origin/main into a branch
I have a git history that basically looks like this: ``` commit: XXX (HEAD -> main) | | commit: YYY | | commit: ZZZ (origin/main) | | ... ``` Now I would like to turn everything after the last origin/main into a named branch (that is, the changed repository would look as if I bran...
(more)
5 months ago
Comment Post #282232 Implementing the algorithm recursively is a bad idea (in languages which don't do tail recursion elimination). However one might implement the stack as string (or even reuse the given string as stack, if it doesn't need to be preserved, with an integer storing the current top of stack; note that the ...
(more)
5 months ago
Comment Post #291928 If you want to allow not implementing set(self, channel), why would you declare it as required to implement to begin with?
(more)
7 months ago
Comment Post #291554 > If a dictionary is passed in as argument to the class init, then after constructing the object, you have two, entirely separate references to a mutable dict in your code. I'm not sure what you mean with "entire separate" here; the class referencing and modifying the original dict is the whole p...
(more)
8 months ago
Comment Post #287289 First, immediate feedback: `README.md` is missing.
(more)
over 2 years ago
Comment Post #287122 It solves the same problem that any strong typing system solves: Catching errors.
(more)
over 2 years ago
Comment Post #286940 The first vector isn't shown completely in your screenshot. So it cannot show what it is intended to show according to the text. You should have copy-pasted the output instead of posting a meaningless (and data wasting) screenshot. Even better, post the actual length of the vectors instead of...
(more)
over 2 years ago
Edit Post #286865 Initial revision over 2 years ago
Answer A: How to manage user-specific application data on Linux?
Just as an additional information: If you are writing Python code, there's the useful package `appdirs` that provides a platform-agnostic interface to user-specific application data directories. For Linux, it implements the XDG specification.
(more)
over 2 years ago
Comment Post #286685 Well, as I had mentioned in the Github thread, starting a new thread is what I had expected to happen, so that would be a point for option 2. Obviously someone who understands the code will have to say what is practical to do.
(more)
over 2 years ago
Comment Post #286773 You're welcome.
(more)
over 2 years ago
Edit Post #286773 Initial revision over 2 years ago
Answer A: How to use grep to print only specific word from a string
While I agree with Dirk Herrmann that `basename` is the right tool for the job, I think it is still worthwhile to know how to do it with `grep`, because you might one day encounter a sufficiently similar situation that is not covered by a specialised tool. The question can be broken into two quest...
(more)
over 2 years ago
Comment Post #286727 It is a slash, followed by an asterisk. From the man page: > The slash / is used as the directory separator. Separators may occur at the beginning, middle or end of the .gitignore search pattern. And: > If there is a separator at the beginning or middle (or both) of the pattern, then the pat...
(more)
over 2 years ago
Comment Post #286588 In principle, there's also the option to write a command line tool accepting sendmail-compatible options which does the signing before passing it on to whatever you use for sending mail, and instruct git to use that as sendmail executable. Maybe there already exists such an executable somewhere.
(more)
over 2 years ago
Comment Post #286575 Sorry, I misread. But then, `r->s` is *not* `const char*`. It is `char* const`. And while it does have a top-level const, that doesn't matter because you are just returning the value anyway. Indeed, your code compiles just fine. And it does so even if you remove `discard_const` completely, changin...
(more)
over 2 years ago
Comment Post #286575 Note that `const struct t*` is *not* a const type, but a *non-const* pointer to a const type. Therefore there's no top-level `const` to discard. You can easily see the non-constness by adding the statement `r = 0;` to the function. If `r` were of a const type, that wouldn't compile.
(more)
over 2 years ago
Comment Post #286552 Thank you for your answer; while the other answer gave me the understanding I needed to do it, the information in your answer made actually correcting my mistake far more easy than it would have been otherwise.
(more)
over 2 years ago
Comment Post #286551 Thank you for the very helpful and informative explanation.
(more)
over 2 years ago
Edit Post #286550 Initial revision over 2 years ago
Question Is it possible to undo a git reset?
For some reason, I just wanted to undo a commit on my git repository, which I've done with the following command: git reset --soft HEAD1 So far, so good. However, by mistake I issued the command a second time, thus deleting also an earlier commit. It also turned out that I had forgotten to ...
(more)
over 2 years ago
Comment Post #286529 Thank you for your feedback. You've got a few good points. I didn't actually think of double-registering observers, and I don't think in my actual use the order would matter. I would have expected bound member functions not to be allowed in a set (because, after all, you can change the object afterwa...
(more)
over 2 years ago
Comment Post #286530 Thank you for your feedback. However I don't see how you get from the term "actions" to "imperative commands". "Actions" here are actions *on* the state machine, not actions *of* the state machine. "Event" may be a better name here, but then, in the code I plan to use it, the term is already used for...
(more)
over 2 years ago
Comment Post #286511 The goal is to use it for my game, but not as game AI, but to manage different phases. I started out with just values for the current state, which originally were only used to report a result (was the level won, lost, saved or quit, was the menu quit or terminates, etc.), then moved on to also encode...
(more)
over 2 years ago
Edit Post #286511 Initial revision over 2 years ago
Question A state machine in Python
I've written the following code implementing a state machine in Python, and I'd like some feedback on it. The basic idea is that each state has a set of corresponding actions that trigger a state change. You can register observer functions with states, which are then called whenever the state is e...
(more)
over 2 years ago
Comment Post #286440 As far as I can tell, you fork exactly one child process, and the function you call for the child process only calculates and outputs the area exactly once. After return from that function, you exit the child process. No matter what the parent process does, I see absolutely no way to get more than on...
(more)
over 2 years ago
Comment Post #286433 @#53196 Thank you.
(more)
over 2 years ago
Edit Post #286433 Initial revision over 2 years ago
Question Reaction comment doesn't appear if previous comment for retracted reaction was deleted
On this answer I just reacted with “works for me” with comment, but then retracted it because of what finally turned out to be a mistake on my end, and deleted also the comment (and thus the comment thread). After figuring out my mistake, I gave again the “works for me” reaction with comment, but thi...
(more)
over 2 years ago
Edit Post #286429 Initial revision over 2 years ago
Question Is it possible to write protocols for enumerations in Python?
Having recently learned about protocols in Python, I now wonder if you can write a protocol for enumerations. That is, a protocol that says that you are supposed to pass an enum that has certain items with certain values, but doesn't specify a specific enum. To explain how I mean it, here's some n...
(more)
over 2 years ago
Edit Post #285813 Initial revision almost 3 years ago
Answer A: Are there references in C?
C does have references, but it does not have pass by reference. A reference is simply an expression that references an object (object here is meant in the general sense, not in the OO sense; for example, a variable is an object). In C, references are implemented using pointers. However C does n...
(more)
almost 3 years ago