Tag

C-String

Browsing

How to convert a number to C string

Unfortunately in embedded systems sometimes it is not feasible to use strtol function to convert an integer to c string. Using the following C function you will be able to convert any string to an integer number. Although it is not an optimal solution but it will help you solve this kind of problem. Beware that this function is using dynamic memory allocation. Updated Version Here (Please do not hesitate to provide any better alternative method)

Also…

How to left-trim a C string

Reading a file or any output stream usually comes back with leading to trailing whitespace. The following code snippet removes any whitespace on the left of a c string.

You can find the complete source code here : https://gitlab.com/io.d-libraries/extend-c

Merge C strings to a new one

This code snippet provides an essential functionality to merge c strings. Using the build-in c-string function strcpy we are able to merge a lot of different strings to one without worrying about the available memory space. This function requires the Linux Library va_args 

This is a simpler yet equally efficient function without the va_args library

You can find the complete source code here : https://gitlab.com/io.d-libraries/extend-c

How to convert a C string to uppercase

The following code snippet provides an alternative method to convert any C string to uppercase. This is the reverse of How to convert a C string to lowercase.

[wp_ad_camp_1] You can find the complete source code here : https://gitlab.com/io.d-libraries/extend-c

How to convert a C string to lowercase

Sometimes I needed to convert a string to lowercase but it there wasn’t any function that could do that. The following code snippet provides an alternative method to convert any C string to lowercase.

You can find the complete source code here : https://gitlab.com/io.d-libraries/extend-c

How to reverse a C string

Usually reversing a string in C is not as easy as it could be. The following code snippet provides an alternative method to reverse any C string.

You can find the complete source code here : https://gitlab.com/io.d-libraries/extend-c