Skip to main content
The 2024 Developer Survey results are live! See the results

New answers tagged

1 vote

Simple CLI based Mastermind clone in C

Check the return values of system and library calls: ...
Harith's user avatar
  • 9,472
4 votes
Accepted

Generic Dynamic Array Implementation

Types typedef int32_t i32; makes it slightly faster to type the type name, but much harder for the experienced C programmer to read. ...
Cris Luengo's user avatar
  • 6,082
2 votes

Generic Dynamic Array Implementation

Stick to ISO C whenever possible: In your custom ASSERT(), you've used a compound statement expression, but that is only pertinent to one dialect of C, GNU C, and ...
Harith's user avatar
  • 9,472
2 votes

Get Terminal Size, Enable and Disable Terminal Raw Mode without NCURSES

Use tcgetwinsize(): POSIX 2024 added tcgetwinsize() and tcsetwinsize() functions in ...
Harith's user avatar
  • 9,472
1 vote
Accepted

Eliminating "implicit conversion changes signedness" warning using _Generic

Here's another stab at it. Given STATIC_IF() (see here for details): ...
Paul J. Lucas's user avatar
2 votes

Type Traits for C with _Generic

Missing Extended Types Implementations are allowed to provide extended integer types, with __int128 being a common one, and these macros fail for them. On an ILP64 ...
Davislor's user avatar
  • 8,071
0 votes

Eliminating "implicit conversion changes signedness" warning using _Generic

My original proposal using _Generic was over-engineered. A much simpler solution seems to be: ...
Paul J. Lucas's user avatar
4 votes

Eliminating "implicit conversion changes signedness" warning using _Generic

This happens because the constants of an enum have (correction:) some implementation-defined integral type, which might be ...
Davislor's user avatar
  • 8,071
0 votes

Finding the Zeckendorf Representation of a Positive Integer (BIO 2023 Q1)

In my opinion you did not just choose an unnecessarily complicated algorithm/implementation but also an unnecessarily complicated language. In that round, "any language" was allowed. And you ...
no comment's user avatar
9 votes
Accepted

Finding the Zeckendorf Representation of a Positive Integer (BIO 2023 Q1)

Review: Again, nice looking code that does what it is supposed to do. Well presented and fairly easy to follow. Kudos! But, the exercise states "in any order", so much of the clerical code (...
Fe2O3's user avatar
  • 1,469
7 votes

Finding the Zeckendorf Representation of a Positive Integer (BIO 2023 Q1)

Node *first; shall be Node *first = NULL;. Otherwise, a test for first == NULL invokes UB. <...
vnp's user avatar
  • 56.9k
4 votes
Accepted

String Decryption in C (BIO 2022 Q1)

First and foremost, you've tested this code with the sample data provided, right? It works... That's fundamental, and something to be proud of! Next is that the code is nicely presented (very readable)...
Fe2O3's user avatar
  • 1,469
5 votes

A simple ray marcher for the command line

float vs. double Avoid mixing types of functions for no gain. ...
chux - Reinstate Monica's user avatar
4 votes
Accepted

Error handling for singly linked list in C

Great questions! Quality of my code, especially my list library Having the caller allocate the newnode and pass them in is a bad idea, especially since you cannot ...
Davislor's user avatar
  • 8,071
6 votes

Error handling for singly linked list in C

One line from main(): node* newnode, *insertedNode; the whitespace and the splats the mix of lowercase and camel case ...
Fe2O3's user avatar
  • 1,469
6 votes

Error handling for singly linked list in C

Quality of my code, especially my list library. OK for a learner, yet needs work. How to handle errors in main (should every errors be handled in main?). list.c/h...
chux - Reinstate Monica's user avatar
4 votes

String separator, similar to strtok

I think you should keep it simple. There's no need for allocating memory in a function that tokenizes. Let the user decide if it needs to strdup(3) the input string before tokenizing, which will ...
alx - recommends codidact's user avatar
2 votes

Implement Huffman code in C17

Be concise; be expressive Code is a recipe expressing a series of operations on data values to achieve a goal. It's ironic that this code whose purpose is to compress (and decompress) data should be ...
Fe2O3's user avatar
  • 1,469
5 votes

Writing a generic makefile for C projects

This looks wrong: $(target): $(objs) | $(obj-dir) $(COMPILE.C) -o $@ $^ Make predefines $(LINK.c) for this command.
Toby Speight's user avatar
  • 77.3k

Top 50 recent answers are included