How to play with strings in C


There are many Standard C library functions which can be used devastatingly! If the programmer is not careful, s/he can leave bugs in his/her program deep inside. These bugs are very difficult to debug as they produce very unexpected behaviour and leave no trace. Many of the functions that deal with C strings fall into this category. In recent revisions of the standard many alternative safe functions are introduced. These safe functions are recommended to use. However, they are not strictly maintained by all compilers as the compiler developers are not forced to include all safe functions in their compiler package.

There will be many safety notes throughout this tutorial. Please read the safety warnings carefully and make sure you understand the consequence of using a function the wrong way. Follow best practices and avoid bad programming practice.

Create your playground on
This playground was created on, our hands-on, knowledge-sharing platform for developers.
Go to