Skip to content

Commit 3c55708

Browse files
committed
strings
1 parent f5dfc21 commit 3c55708

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

String/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Strings in C
2+
#### Strings are used for storing text/characters.
3+
#### For example, "Hello World" is a string of character
4+
#### Strings are used to store sequence of characters as information.
5+
#### string.h header file provides some built-in string manipulation functions.
6+
7+
```
8+
char greetings[] = "Hello World!";
9+
char a[5] = {‘H’,’o’,’l’,’a’};
10+
char a [ ] = “Hola”;
11+
```
12+
13+
# String functions are accessible by importing *<string.h>*.
14+
#### strlen() Find length of string
15+
#### strcpy() Copy one string to other
16+
#### strcat() Join two strings
17+
#### strcmp() Compare two strings
18+
#### strlwr() Converts string to lowercase
19+
#### strupr() Converts string to uppercase
20+

String/string.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
4+
int main()
5+
{
6+
// declare and initialize string
7+
char str[] = "nazu";
8+
9+
// print string
10+
printf("%s\n", str);
11+
12+
int length = 0;
13+
length = strlen(str);
14+
15+
// displaying the length of string
16+
printf("Length of string str is %d", length);
17+
18+
return 0;
19+
}

0 commit comments

Comments
 (0)