Multi-dimensional array in C
Multi-dimensional array in C
�Types of Multidimensional Arrays�
Types of Multidimensional Arrays
Two-dimensional arrays in C
Two-dimensional arrays in C Declaration
data_type array_name[rows][columns];
Int a[3][3]={{5,10,20},{25,30,35},{1,3,4}};
2D array Initialization:�
After Declaration:�
Strings
Strings in C�
Declaration and Initialization:
INDEX | 0 | 1 | 2 | 3 | 4 | 5 |
VALUE | H | e | l | l | o | ‘\0’ |
Strings in C�
Specifying size:
String Manipulation:�
�Update�
�String built-in functions.�
�strlen()�
strlen():
�strcpy()�
strcpy():�
strncpy()�
strncpy():�
�strcat()�
strcat():�
�strncat()�
�strncat():�
�strcmp()�
strcmp():�
�strncmp()�
strncmp():�
�strchr()�
strchr():�
�strrchr()�
strrchr()
�strstr()�
strstr()
�
strlwr()
strlwr
strupr()
Strupr()
Strrev()
strrev()
sprintf()�
Function | Description | Syntax |
Find the length of a string excluding '\0' NULL character. | strlen(str); | |
Copies a string from the source to the destination. | strcpy(dest, src); | |
Copies n characters from source to the destination. | strncpy( dest, src, n ); | |
Concatenate one string to the end of another. | strcat(dest, src); | |
Concatenate n characters from the string pointed to by src to the end of the string pointed to by dest. | strncat(dest, src, n); | |
Compares these two strings lexicographically. | strcmp(s1, s2); | |
strncmp() | Compares first n characters from the two strings lexicographically. | strncmp(s1, s2, n); |
Find the first occurrence of a character in a string. | strchr(s, c); | |
Find the last occurrence of a character in a string. | strchr(s, ch); | |
First occurrence of a substring in another string. | strstr(s, subS); | |
Format a string and store it in a string buffer. | sprintf(s, format, ...); | |
Split a string into tokens based on specified delimiters. | strtok(s, delim); |
Function | Description | Syntax |
Find the length of a string excluding '\0' NULL character. | strlen(str); | |
Copies a string from the source to the destination. | strcpy(dest, src); |
Copies n characters from source to the destination. | strncpy( dest, src, n ); | |
Concatenate one string to the end of another. | strcat(dest, src); | |
Concatenate n characters from the string pointed to by src to the end of the string pointed to by dest. | strncat(dest, src, n); |
Compares these two strings lexicographically. | strcmp(s1, s2); | |
strncmp() | Compares first n characters from the two strings lexicographically. | strncmp(s1, s2, n); |
Find the first occurrence of a character in a string. | strchr(s, c); |