All Questions
115 questions
14
votes
5
answers
2k
views
I implemented FFT in C
I wrote Cooley-Tukey's FFT algorithm in C. And I want to know how safe is this code? Is it just trash? How can I make it more memory safe?
...
10
votes
6
answers
2k
views
k-Nearest Neighbors algorithm in C
I've been learning C for a while, and I decided to make a simple kNN program. What can I do to improve the program?
Am I doing memory management right? Can the structure of the code be improved in ...
5
votes
3
answers
384
views
Implementation of arrays that store their size
In this code I implemented arrays that store their own size before the first element. To access it you need to go back exactly sizeof(size_t) bytes back. To free it,...
3
votes
2
answers
160
views
Todo List app using C
I just learned to deal with pointers and memory allocation stuff. Using that, I built a todo list app, and it works as far as I tested it.
I didn't account for many user errors, so any suggestion to ...
5
votes
3
answers
869
views
Safe(r) / Easier Pointer Allocation Interface in C (ISO C11)
I spent like half an hour programming up a set of functions to make the allocation / deallocate of pointers easier within a bigger project. I felt that they were satisfactory, but was wondering if ...
2
votes
2
answers
292
views
Optimizing Subarray Removal: Can the Removal Process be Enhanced for Better Efficiency?
The only requirement is that it has to be done by pointers:
And it returns the amount of removed numbers because of the way of output that is set in the main.
The function, using exclusively pointer ...
8
votes
3
answers
2k
views
"Smart" (ish) pointer in C
I am a programmer with a primarily Rust-based background who has nonetheless taken an interest in C lately due to its simplicity and minimalism. However, one of the things I miss most from Rust is ...
2
votes
3
answers
141
views
Exercises 5.1 from K&R (function to read an integer value)
As written [above], getint treats a + or - not followed by a digit as a
valid representation ...
7
votes
2
answers
246
views
simple connect four game
I made a simple connect four terminal game in C and was wondering if I could get feedback on it. I mainly want to know where pointers could have optimised my code, and if there are any major ...
5
votes
1
answer
1k
views
Dynamic array type using void pointers C
I made my own dynamic array type using void pointers. I'd like to know what you think of my implementation. void pointers are nice but I fear they may be inefficient. The compiler cannot tell what ...
12
votes
10
answers
3k
views
Trim leading/trailing space in a string
I'm practicing C and wrote a function to trim leading/trailing spaces in a string:
...
3
votes
1
answer
324
views
C void* Generic Hash Table
Some time ago I tried to make a generic linked list in pure C (no external libraries, only the C standard library) using void*s here. Building on top of that and ...
8
votes
1
answer
724
views
C void* Generic Linked List
I once tried to make a generic linked list in pure C (no external libraries, only the C standard library) here using C macros. With the same restrictions as in the previous attempt, this time I'm ...
4
votes
1
answer
522
views
Simple slab allocator in C
Here is the plan:
a slab takes up 1 page and it has PGSIZE / blocksize amount of blocks
the minimum blocksize is 8 bytes, otherwise the pointer to the next block ...
2
votes
1
answer
456
views
C Program - Camel Case (creates or splits camel case variables, methods and class names.)
I have written a program in C, which does the following operations:
creates or splits Camel Case variable, method, class names.
Input format
Each line of the input file will begin with an operation ...