FlashKeepers

C and C++ · College · College and University

C III: Strings, Arrays and Structs

C-style strings and the string.h functions, multidimensional arrays, structs, unions, enums, typedef and bit fields.

About this set

40 basic cards for College C and C++. It opens with "What is a C-style string?" and "What does strlen() do?". Study it alongside the other College sets below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is a C-style string?
Show answerA null-terminated character array, where the last character is the null terminator '\0'.
What does strlen() do?
Show answerReturns the number of characters in a string, not including the null terminator.
What does strcpy() do?
Show answerCopies one string to another, including the null terminator.
Why is strcpy() considered dangerous?
Show answerIt does not check buffer size and can cause buffer overflow if the source is too large.
What is the safer alternative to strcpy()?
Show answerstrncpy(), which takes a maximum number of characters to copy.
What does strcat() do?
Show answerConcatenates (appends) one string to the end of another.
What does strcmp() return?
Show answerReturns 0 if strings are equal, negative if first is less, positive if greater.
What does strchr() find?
Show answerLocates the first occurrence of a character in a string and returns a pointer to it.
What does strstr() find?
Show answerLocates the first occurrence of a substring within a string and returns a pointer to it.
What does strtok() do?
Show answerSplits a string into tokens (substrings) based on delimiter characters.
What header file contains string functions?
Show answerstring.h (or cstring in C++)
How do you declare a character array to hold a 50-character string?
Show answerchar str[51]; (the +1 accounts for the null terminator)
What is the difference between a string literal and a character array?
Show answerA string literal is constant and read-only; a character array is mutable storage that can be modified.
How do you initialize a string with a value?
Show answerchar str[] = "hello"; or char str[6] = "hello";
What is a multidimensional array?
Show answerAn array of arrays, such as a 2D array that represents rows and columns.

25 more cards in the app

Study this set free