Everything is based on a series of uniformly creasing addresses, to which each address has a binary value and that value corresponds to character in the ASCII table.
What is the difference between character array and character pointer ?
Consider the following example:
char arr[] = "Hello World"; // array version
char ptr* = "Hello World"; // pointer version
The type of both the variables is a pointer to char
or (char\*)
, so you can pass either of them to a function whose formal argument accepts an array of characters or character pointer. In C programming, the name of an array always points to the base address, roughly speaking, an array is a pointer.
Here are differences:
- 1
arr
is an array of12
characters. When compiler sees the statement:It allocateschar arr[] = "Hello World";
12
consecutive bytes of memory and associates the address of the first allocated byte witharr
. On the other hand when the compiler sees the statement.It allocateschar ptr* = "Hello World";
12
consecutive bytes for string literal"Hello World"
and4
extra bytes for pointer variableptr
. And assigns the address of the string literal toptr
. So, in this case, a total of16
bytes are allocated.
In this library we have the following functions for manipulating strings:
length
: get the length of a string.equal
: check if two strings are the same.copy
: copy characters from one string to another string.subcopy
: copy a specific portion of a string, using the starting index and an ending index, to another string.subcopy_len
: copy a specific portion of a string, using the length, to another string.subcopy_index_len
: copy a specific portion of a string, using the starting index and the length, to another string.