String_Library_in_C
String_Library_in_C
C provides a library of functions for working with strings in the `string.h` header file. These functions
make it easier to manipulate strings, which are essentially arrays of characters terminated by a null
character (`'\0'`).
| Function | Description |
|--------------------|-------------|
| `memset()` | Fills a block of memory with a particular value (often used with strings). |
| `strrev()` (Non-standard) | Reverses a string (available in some compilers like Turbo C). |
---
#### Example of `strlen()` - String Length
```c
#include <stdio.h>
#include <string.h>
int main() {
return 0;
```
---
```c
#include <stdio.h>
#include <string.h>
int main() {
char destination[50];
strcpy(destination, source);
printf("Copied string: %s\n", destination);
return 0;
```
---
```c
#include <stdio.h>
#include <string.h>
int main() {
return 0;
```
---
#### Example of `strcmp()` - String Comparison
```c
#include <stdio.h>
#include <string.h>
int main() {
if (result == 0) {
} else {
return 0;
```
---
#### Example of `strchr()` - Find a Character in a String
```c
#include <stdio.h>
#include <string.h>
int main() {
if (ptr) {
} else {
return 0;
```
---
```c
#include <stdio.h>
#include <string.h>
int main() {
printf("Tokens:\n");
printf("%s\n", token);
return 0;
```
**Output:**
Tokens:
Hello
World
This
Is
---
```c
#include <stdio.h>
#include <string.h>
int main() {
if (ptr) {
} else {
return 0;
```
---
```c
#include <stdio.h>
#include <string.h>
int n = strlen(str);
for (int i = 0; i < n / 2; i++) {
str[n - i - 1] = temp;
int main() {
reverseString(str);
return 0;
```
---