Seminar Topics & Project Ideas On Computer Science Electronics Electrical Mechanical Engineering Civil MBA Medicine Nursing Science Physics Mathematics Chemistry ppt pdf doc presentation downloads and Abstract

Full Version: STRINGS pdf
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
STRINGS


[attachment=53600]

INTRODUCTION

In the previous unit, we have discussed numeric arrays, a powerful data storage
method that lets you group a number of same-type data items under the same group
name. Individual items, or elements, in an array are identified using a subscript after
the array name. Computer programming tasks that involve repetitive data processing
lend themselves to array storage. Like non-array variables, arrays must be declared
before they can be used. Optionally, array elements can be initialized when the array
is declared. In the earlier unit, we had just known the concept of character arrays
which are also called strings.
String can be represented as a single-dimensional character type array. C language
does not provide the intrinsic string types. Some problems require that the characters
within a string be processed individually. However, there are many problems which
require that strings be processed as complete entities. Such problems can be
manipulated considerably through the use of special string oriented library functions.
Most of the C compilers include string library functions that allow string comparison,
string copy, concatenation of strings etc. The string functions operate on nullterminated
arrays of characters and require the header <string.h>.The use of the some
of the string library functions are given as examples in this unit.

OBJECTIVES

After going through this unit, you will be able to:
• define, declare and initialize a string;
• discuss various formatting techniques to display the strings; and
• discuss various built-in string functions and their use in manipulation of strings.

DECLARATION AND INITIALIZATION OF STRINGS

Strings in C are group of characters, digits, and symbols enclosed in quotation marks
or simply we can say the string is declared as a “character array”. The end of the
string is marked with a special character, the ‘\0’ (Null character), which has the
decimal value 0. There is a difference between a character stored in memory and a
single character string stored in a memory. The character requires only one byte Strings
whereas the single character string requires two bytes (one byte for the character and
other byte for the delimiter).