Skip to main content

All Questions

Tagged with
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 ...
Justin Chang's user avatar
  • 2,437
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 ...
Madagascar's user avatar
  • 10.1k
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. ...
wellinthatcase's user avatar
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). ...
Darth-CodeX's user avatar
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 ...
Darth-CodeX's user avatar
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, <...
user45698746's user avatar
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 ...
ryyker's user avatar
  • 338
3 votes
2 answers
298 views

Implementation of itoa

...
Edenia's user avatar
  • 1,578
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 ...
Aykhan Hagverdili's user avatar
6 votes
2 answers
484 views

Extract specific positions from a char array

I have two arrays: char input[] = "ughIuytLikeretC"; and ...
jregalad's user avatar
  • 161
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 ...
Hamza El Bouazizi's user avatar
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 ...
machine_1's user avatar
  • 601
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: ...
esote's user avatar
  • 3,800
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 ...
David Quintero Granadillo's user avatar
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: ...
Håkon Hægland's user avatar

15 30 50 per page