Strings Flashcards
Literals written using single quotes
Data Type: char
Can only store one character
Characters
outputs the ASCII table in Linux
man ascii
Character functions can be found in the _____ header file
ctype.h
[Character Function] Checks whether the character is alphabetic
isalpha(char c);
[Character Function] Checks whether a character is a decimal digit
isdigit(char c);
[Character Function] Checks if char is alphanumeric
isalnum(char c);
[Character Function] checks if char is in lowercase
islower(char c);
[Character Function] Checks if char is in uppercase
isupper(char c);
[Character Function] Checks if char c is a punctuation
ispunct(char c);
[Character Function] Checks if char is a white space
isspace(char c);
[Character Function] Converts char to lowercase
tolower(char c);
[Character Function] Converts char to uppercase
toupper(char c);
Literals written using double quotes.
An array of characters.
Strings
Strings are terminated by the null character ___
\0
Strings can store up to ____ characters
N-1 (bc a slot is reserved for the terminating character \0)
Ways to initialize a string
- Just like an array, specify each character that will be a part of the string as well as don’t forget to include the terminating character \0 at the end.
- By using a string literal.
- Using a pointer to create a constant string.
String functions can be found in the _____ header file.
string.h
[String Function] Concatenate two strings
strcat(char str1, char str2);
[String Function] Compares two strings. Returns an int.
strcmp(char str1, char str2);
[String Function] Copies a string to the other.
strcpy(char dest, char src);
[String Function] Returns the length of the string.
strlen(char str);