পৃষ্ঠাসমূহ

.

Search Your Article

Total Pageviews

Friday, February 3, 2017

String Programs in C

Strings are actually one-dimensional array of characters terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by a null.

The following declaration and initialization create a string consisting of the word "Hello". To hold the null character at the end of the array, the size of the character array containing the string is one more than the number of characters in the word "Hello."
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
If you follow the rule of array initialization then you can write the above statement as follows −
char greeting[] = "Hello";
In this section, we shall learn how to work with string C programming language. We have divided the examples in multiple sub-sections to have a better understanding of what we are doing −

Basic Programs

These programs made specially to understand the basics of strings in C. These program deals with string as an array of characters.

Multi-string Programs

These programs has more than one string variables. These should give you an insight of how to work with multiple string variables in C programming language −

Long String Programs

A sentence or a line can be considered as a long string. The following programs deals with the same concept −

No comments:

Post a Comment