0
0
Cprogramming~5 mins

String handling using library functions - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the strlen() function in C?
The strlen() function returns the length of a string, not counting the null character \0 at the end.
Click to reveal answer
beginner
How does strcpy() function work in C?
strcpy() copies the content of one string (source) into another string (destination), including the null terminator.
Click to reveal answer
beginner
What does strcmp() return when two strings are equal?
strcmp() returns 0 if the two strings are exactly the same.
Click to reveal answer
intermediate
Explain the difference between strcat() and strncat().
strcat() appends one string to another until it hits the null character. strncat() appends up to a specified number of characters, helping to avoid buffer overflow.
Click to reveal answer
beginner
Why is it important to include string.h when using string library functions?
Including string.h provides the declarations of string handling functions so the compiler knows how to use them correctly.
Click to reveal answer
Which function is used to find the length of a string in C?
Astrcpy()
Bstrcmp()
Cstrlen()
Dstrcat()
What does strcpy(dest, src) do?
AReturns length of src
BCompares dest and src strings
CConcatenates src to dest
DCopies src string into dest string
If strcmp(s1, s2) returns a negative value, what does it mean?
As1 is lexicographically less than s2
Bs1 is equal to s2
Cs1 is lexicographically greater than s2
DThere is an error
Which function safely appends a limited number of characters from one string to another?
Astrncat()
Bstrcpy()
Cstrlen()
Dstrcmp()
What header file must be included to use string handling functions like strlen() and strcpy()?
Astdio.h
Bstring.h
Cmath.h
Dstdlib.h
Describe how to copy one string into another using C library functions. What should you be careful about?
Think about how strcpy works and what can go wrong if the destination is too small.
You got /4 concepts.
    Explain how to compare two strings in C and interpret the result of the comparison.
    Consider what strcmp returns when strings are equal or different.
    You got /3 concepts.