Skip to main content

All Questions

Tagged with
1vote
2answers
266views

Count the number of mismatches between two arrays

This function may compute the amount of unequal elements of two char-arrays of the length n: ...
7votes
3answers
990views

Dynamic Arrays with Count / Capacity in C

I write in C for several projects (e.g. learning / teaching, coding competitions, data processing) and frequently need arrays (e.g. strings) with fast appending / concatenation / reversing. I've ...
156votes
20answers
32kviews

Searching an element in a sorted array

I was applying for a position, and they asked me to complete a coding problem for them. I did so and submitted it, but I later found out I was rejected from the position. Anyways, I have an eclectic ...
3votes
2answers
178views

Two-dimensional arrays in C

The concrete purpose is transferring a string array to a matrix of coefficients and the solving it as a linear system of equations. I have a bit of trouble with two-dimensional arrays in C. I want to ...
6votes
3answers
333views

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,...
3votes
2answers
145views

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 ...
2votes
2answers
135views

Generic Dynamic Array Implementation

I wrote a dynamic array implementation in ISO C11 using void pointers. Everything I've implemented works--at least in all my tests--on a 64-bit machine. It has some vague type-checking and resizes ...
6votes
4answers
1kviews

Automate character search in C

THE TASK We are dealing with a string of symbols and need quick responses to queries of the following types: What is the position of the k-th occurrence of symbol X in the string? Reading from ...
2votes
2answers
283views

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 ...
6votes
1answer
61views

Chessboard configuartions with no possible capture on the next move

THE TASK: Given an NxM "chess"board and Q,R,B,K where Q is the number of queens, R the number of rooks, B the number of bishops, and K the number of knights find out how many possible ...
4votes
2answers
2kviews

Linked list and array list performance comparison in C

After watching Stroustrup's presentation on performance comparison between vectors and linked lists (https://youtu.be/YQs6IC-vgmo?si=9r5wXqnwkmN29xqn), I've decided it would be a good problem to get a ...
6votes
3answers
647views

Redefining queue with different front and rear

...
8votes
3answers
377views

Automation of array allocation in C

I recently have been working on moving from projects written in Java and C++ to C and realized that the lack of std::vector in C makes it a bit more difficult to ...
3votes
3answers
53views

Filter a list of integers to exact multiples of a given factor

There is a sequence of integer values, and a separate integer. I was required to write a method to get all numbers from the given number sequence which can be divided exactly by the given separate ...
3votes
3answers
1kviews

Small code exercise with 3D arrays in C

I wrote a small program that initializes a 3D array in C based on command-line arguments and prints it. I did my best to avoid undefined behavior and memory errors. I wrote comments as if I had an ...

153050per page
close