Professional Documents
Culture Documents
Strings
a A string is an array of characters.
a Strings must have a 0 or null character after
the last character to show where the string
ends. The null character is not included in the
string.
a Two ways of using strings are:
The first is with a character array and
the second is with a string pointer.
a A character array is declared in the same
way as a normal array.
Example: O O
Strings
a The function
O can be used repeatedly
to read a sequence of successive single
characters and store it in the array.
a ºe cannot manipulate strings since C does not
provide any operators for string. For instance we
cannot assign one string to another directly.
Ñ x
a The example about is not valid. To copy the
chars in one string to another string we may do
so on a character to character basis.
O O
O
O
O
O
O
O
ë O
a String pointers are declared as a pointer to a
char.
O
String handling functions
a à
à
à
üoins the destination and source strings and
puts the joined string into the destination
string.
O
O åå
String handling functions
a à à à
Compares the first and second strings. If the
first string is greater than the second one then
a number higher than 0 is returned. If the first
string is less than the second then a number
lower than 0 is returned. If the strings are
equal then 0 is returned.
O
O
O åå
String handling functions
a à à à
O
will return zero because the two strings are equal.
O
will return a 9 which is the numeric difference
between ASCII µi¶ and ASCII ¶r¶.
O
will return 32 which is the numeric difference
between ASCII ³T´ & ASCII ³t´.
String handling functions
a à
This function is same as strcmp() which compares
two strings but not case sensitive.
Ex
O !
"
String handling functions
a à à
Returns the amount of characters in a string.
O
åå
String handling functions
a à à
Returns the amount of characters in a string.
O
åå
a å Everyone¶s first C program. å
oO"
# $
O
%
&'
()*
%
O O
ë )
O
*