Posts

String Handling in C Language

  String Handling in C A string in C Language can be defined as a character array terminated with a special character ‘\0’ to mark the end of the string. Unlike some other high-level languages like BASIC language, C does not have built-in “string” type data. So, C has no built-in facilities for manipulating entire arrays(such as copying and comparing them, etc). It also has very few built-in facilities for manipulating strings. In fact, C’s only truly built-in string-handling is that it allows us to use string constants (also called string literals) in our code, Whenever we write a string, enclosed in double   quotes, C automatically creates an array of characters for us, containing that string, terminated by the   ‘\0‘ character. The reason why the last character in a character array should be a ‘\0’ (called null character , a character with the value 0) is that in most programs that manipulate character arrays expect it. For example, printf uses the ‘\0’ to detect the end of a c