Which header file is needed to use string functions like `strlen()` and `strcpy()`?
A
<stdlib.h> B
<stdio.h> C
<string.h> D
<conio.h>
Analysis & Theory
The `<string.h>` header provides common string functions in C.
What does the `strlen()` function return?
A
Number of characters including `\0` B
Number of characters excluding `\0` C
Size in bytes of the string variable D
Always returns an int pointer
Analysis & Theory
`strlen()` returns the number of characters in a string, excluding the null terminator.
Which function copies a string from source to destination?
A
strcat() B
strcpy() C
copystr() D
strmove()
Analysis & Theory
`strcpy(destination, source)` copies the string from source to destination.
What does the `strcmp()` function return if both strings are equal?
A
1 B
0 C
-1 D
true
Analysis & Theory
`strcmp()` returns 0 when both strings are exactly equal.
Which function is used to append (concatenate) two strings?
A
strmerge() B
strcat() C
append() D
addstr()
Analysis & Theory
`strcat(destination, source)` appends the source string to the end of the destination string.
What is the output?
```c
char s[10] = "Hi";
printf("%lu", strlen(s));
```
A
3 B
10 C
2 D
4
Analysis & Theory
`strlen(s)` returns 2, the number of characters excluding the `\0`.
What does `strncpy()` do differently from `strcpy()`?
A
Copies entire memory block B
Copies characters up to given limit C
Converts characters to uppercase D
Encrypts the string
Analysis & Theory
`strncpy(dest, src, n)` copies at most `n` characters from `src` to `dest`.
What does `strchr(str, 'a')` do?
A
Replaces all 'a' with null B
Finds the first occurrence of 'a' in the string C
Deletes all 'a' D
Counts number of 'a'
Analysis & Theory
`strchr()` returns a pointer to the first occurrence of the character in the string.
Which function is used to compare first N characters of two strings?
A
strcmp() B
strncmp() C
strcomp() D
memcmp()
Analysis & Theory
`strncmp(s1, s2, n)` compares first `n` characters of both strings.
Which function sets all bytes of a string to a specific character?
A
strset() B
memset() C
setstr() D
strfill()
Analysis & Theory
`memset(str, c, n)` sets the first `n` bytes of `str` to character `c`.