Posts Tagged ‘strings’

A dynamic string data structure helper implementation.

October 21, 2014 Leave a comment

In this article I will present to you a dynamic string data structure helper implementation. In C, a string is just an array of characters terminated with the null character (NUL in ASCII). Also, some times we handle a string by using a pointer to a buffer containing sequential characters terminated also with the null character. The C standard liibrary provides various functions for string manipulation but it seems that whenever we want to extend a string by using pointers we have to perform all the time memory reallocation which leads to a bad evolution of replicated code. In a recent project, I needed to create a string and append to it any number of new strings in order to extend it without using strcat, strcpy, strlen and realloc functions all the time. So, I created a simple dynamic string data structure which solved my specific problem and I would like to share it with you people.

Read more…

Implementation of an application for the sorting of an array of strings.

March 8, 2011 2 comments

The following program demonstrates a significant processing operation on arrays of strings. More precisely, we present the re-sorting of a set of strings in order to classify them. So, we read the strings and place them in a temporary storage area (buffer) large enough to be able to store all, keeping in an array a pointer to each string. Then we re-sort the pointers (only pointers and not strings to increase the performance) to place the pointer to the “smallest” string at the first position of the array, the pointer to the next “largest” string at the second position of the array, and so on.

Read more…