All Questions
36 questions
7
votes
3
answers
990
views
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 ...
3
votes
1
answer
126
views
Read a line from a stream
Since the standard fgets() does not suffice for my use cases, as it doesn't automatically enlarge the target buffer if needed, and ...
3
votes
1
answer
112
views
Trailing delimiter string splicing, implemented for Lua in C
I've been writing with C for a couple days, so this is a relatively advanced function compared to the simple things I've been doing previously. It's written for the Lua API, but it's still C.
...
3
votes
3
answers
2k
views
Replace string with another string in C
I have written a program that replaces a given c-string with another c-string. My code works well with small files but takes too much time while working with large files (50 Megabytes and larger).
...
6
votes
2
answers
2k
views
Entropy of String in C
I have written a C program that calculates Shannon entropy for a C-String (const char *). It works well but in many ...
1
vote
1
answer
51
views
tokenize char array with PolarSSL library
I'm trying to perform a decryption operation using RSA. I'm using the PolarSSl library. I have a char array key[] that contains RSA private key like the following,
<...
9
votes
7
answers
3k
views
Remove all unwanted characters from a string buffer, in-place
The following code was written with the intent to be as efficient as possible, where efficiency includes speed of execution, memory usage, and lines of code, all in support of the primary design ...
3
votes
2
answers
298
views
2
votes
1
answer
115
views
Finding the longest word without these characters follow-up
Here I asked this question:
My goal is to go through the list of all English words (separated by
'\n' characters) and find the longest word which doesn't have ...
6
votes
2
answers
484
views
Extract specific positions from a char array
I have two arrays:
char input[] = "ughIuytLikeretC";
and
...
1
vote
3
answers
264
views
Functions to handle big numbers in C
I'm working to implement some simple bigint functions for addition, multiplication and powers. They work correctly but the larger the numbers the longer the time it takes.
For example 210000 takes a ...
1
vote
1
answer
107
views
Optimizing string handling function
How can I optimize the following function? It checks whether two strings have a certain number of similar consecutive characters. As it is now, it is very slow, so how can it be improved in terms of ...
10
votes
8
answers
2k
views
Determining if a C-style string is alphabetic
I'm looking for the fastest way to determine if a C-style string contains only alphabetic characters.
For this question, there are a few assumptions:
...
1
vote
1
answer
2k
views
Using a linked list as a char buffer for strings
I've been getting into data structures in C lately, and I got the idea of making a char buffer which grows dinamically has you type by adding each character into a Linked List, and whose contents can ...
7
votes
1
answer
147
views
Fastest way to find a string delimited by two words
Motivated by this question, I created a simple benchmark for investigating what is the fastest way to extract a substring given two delimiting words:
...