New answers tagged

4 votes

Maze generator in C

There is quite a bit that can be improved here. I see you are trying to do things in a correct way, but you miss the mark here and there. I'll explain below. Avoid macros Giving name to constants is a ...
user avatar
  • 33.4k
1 vote
Accepted

Code for setting all child controls to the default message font on Windows

Came over from the SO question because admittedly I never look in here. Firstly, it's not DPI aware. This is fine if you didn't intend it to be. Not applicable here, but if it were a dialog, MSDN ...
user avatar
  • 271
1 vote
Accepted

Function that get 3 word for strings, than combine them to 1 string and finally print the string in reverse

Bug strcat(s1, s2) requires that s1 point to a string. new_w does not point to a string as ...
user avatar
3 votes

Commented Parser Combinators in Lisp-style C

Makefile improvements At first glance, the makefile looks OK, but a few improvements can be made. First, you always override CFLAGS, although you allow to add ...
user avatar
  • 33.4k
3 votes

Function that get 3 word for strings, than combine them to 1 string and finally print the string in reverse

free(new_w) has no effect. It is unreachable. And unnecessary (and dangerous if placed before return). ...
user avatar
  • 53.4k
1 vote
Accepted

Simple Brainfuck interpreter in C with support for nested subroutines

Advice 1 #define MIN_MEMORY_SIZE 30000 Later... ...
user avatar
  • 25.7k
2 votes

Is my "insertion sort" correct?

Don't write, never publish/commit undocumented code. I think your insertion_sort() does not truthfully implement insertion sort: While it terminates the search for ...
user avatar
  • 4,563
1 vote

A (Sort of) Generic Stack Implementation in C using Macros

Overall, your code looks good. On naming I would rename stackdef to DEFINE_STACK_TYPE since, in C, macros are UPPER_CASE. ...
user avatar
  • 25.7k
2 votes

Is my "insertion sort" correct?

Take a look at Wikipedia. It presents two implementations of the insertion sort: Swapping insertion sort, Faster insertion sort. In C, (1) would seem like: ...
user avatar
  • 25.7k
1 vote
Accepted

Simple networking framework in C

Create a platform-independent header file Instead of an application having to write code to choose between liomux.h and wiomux.h, create a header file named iomux.h that does this internally. This ...
user avatar
  • 33.4k
2 votes
Accepted

Parser Combinators in C redux

General Observations The code is not maintainable. While the code seems to follow some general software development principles such as the Single Responsibility Principle there is no documentation (...
user avatar
  • 18.5k
1 vote
Accepted

Load and execute shared library

Prefer = default over {} Prefer using = default instead of using an empty function body for ...
user avatar
  • 33.4k
1 vote

Re-designing c-style Input Output

I agree with Roland Illig's review. Some other remarks I would like to add: Needs 2 functions for input output [ namely printf() and ...
user avatar
  • 33.4k
3 votes
Accepted

Re-designing c-style Input Output

So here we go. As usual, be prepared that the feedback here is quite detailed. The first thing I did was to load your code into my IDE and run ...
user avatar
5 votes
Accepted

Proper way to send and receive buffer in Winsock

General Observations The code is mostly readable and except in one case maintainable. The exception may be a copy-and-paste error. Generally code isn't considered ready for review when it contains ...
user avatar
  • 18.5k
0 votes

Printing an array of numbers without duplicates

You can guarantee \$\Theta(n)\$ running time if you store already seen ints in a hash table: ...
user avatar
  • 25.7k
0 votes

Printing an array of numbers without duplicates

Suggest sorting the array then only a single pass through the array, comparing the current array value with the next array value will tell you if the value is a duplicate or not
user avatar
  • 2,758
1 vote
Accepted

Printing an array of numbers without duplicates

The method you used to solve this problem is correct and the implementation is correct. The changes I suggest below are about making the code correct and making the code easier to read so that someone ...
user avatar
  • 1,063
0 votes
Accepted

Type safe generic array in c

Reduce clutter const of an object serves little purpose in declarations other than to clutter code. This is the interface users often reference to understand the ...
user avatar
0 votes

Sum and bubble-sort student scores

Including some specification in cal_total_score() & student_bb_sort() is the way to go, credit going to the creators of the &...
user avatar
  • 4,563
0 votes

Sum and bubble-sort student scores

Here is what I think: Do not use bubble sort(BS), except it is your teacher's requirement. Because the time complexity for BS is n*n (n are the elements) if you want to sort ...
user avatar
2 votes

Simple snake game with C and raylib

In addition to @Reinderien good review. Allocate consistently Consider: ...
user avatar
3 votes

Sum and bubble-sort student scores

But I wonder if there is a more efficient way. Instead of bubble-sort, use qsort(). Yet I expect OP's assignment may oblige bubble-sort. ...
user avatar
2 votes
Accepted

Simple snake game with C and raylib

Since there's only one translation unit here, mark your functions static similar to what you've already done with your global variables. I don't see a lot of value ...
user avatar
  • 49.6k
3 votes

Sum and bubble-sort student scores

Advice 1 typedef struct student { int id; int prob_1; int prob_2; int prob_3; int total_score; char grade; }Student; Since ...
user avatar
  • 25.7k
1 vote

touch command in C

Avoid overflow With exceptional long names, below overflows the buffer. ...
user avatar
1 vote

daemon in a producer-consumer

Use Header Files For Common Code The 2 programs share some common code, this code should be in a header file that is used by both programs. If the code isn't in a header file used by both, then both ...
user avatar
  • 18.5k
1 vote

System V signal API using the standard POSIX API

Unsafe definition of SIG_HOLD There are several issues with your definition of SIG_HOLD. First, since you ...
user avatar
  • 33.4k
1 vote

nice utility in C

"I implemented the nice linux command" You wrote a program that modifies its own process priority. This is not event remotely what the nice command does. ...
user avatar
4 votes

touch command in C

There is no need to deal with directories There is no reason to pass touch() both a dir and a ...
user avatar
  • 33.4k
3 votes

nice utility in C

Error paths When getpriority(), my_nice() returns -1, do not go on. Code should return non-zero. Report failure Rather than only exit on failure, print the reason ...
user avatar

Top 50 recent answers are included