Operating System overview
C programming 101
Print values
I/O
- Input comes from the standard input device,
stdin
- Output is generated by the standard output device,
stdout
- Functions to notice:
Read text input which contains white space
Conditional
Loop
Function
Array
Character array (string
)
Array as function params
Text manipulating
Char Functions
- Library:
ctype.h
Function | Returns TRUE when ch is |
---|---|
isalnum(ch) | A letter of the alphabet (upper- or lowercase) or a number |
isalpha(ch) | An upper- or lowercase letter of the alphabet |
isascii(ch) | An ASCII value in the range of 0 through 127 |
isblank(ch) | A tab or space or another blank character |
iscnctrl(ch) | A control code character, values 0 through 31 and 127 |
isdigit(ch) | A character 0 through 9 |
isgraph(ch) | Any printable character except for the space |
ishexnumber(ch) | Any hexadecimal digit, 0 through 9 or A through F (upperor lowercase) |
islower(ch) | A lowercase letter of the alphabet, a to z |
isnumber(ch) | See isdigit() |
isprint(ch) | Any character that can be displayed, including the space |
ispunct(ch) | A punctuation symbol |
isspace(ch) | A white-space character, space, tab, form feed, or an Enter, for example |
isupper(ch) | An uppercase letter of the alphabet, A to Z |
isxdigit(ch) | See ishexnumber() |
toascii(ch) | The ASCII code value of ch, in the range of 0 through 127 |
tolower(ch) | The lowercase of character ch |
toupper(ch) | The uppercase of character ch |
”String” Functions
- Library:
string.h
Function | What it does |
---|---|
strcmp() | Compares two strings in a case-sensitive way. If the strings match, the function returns 0. |
strncmp() | Compares the first n characters of two strings, returning 0 if the given number of characters match. |
strcasecmp() | Compares two strings, ignoring case differences. If the strings match, the function returns 0. |
strncasecmp() | Compares a specific number of characters between two strings, ignoring case differences. If the number of characters match, the function returns 0 |
strcat() | Appends one string to another, creating a single string out of two |
strncat() | Appends a given number of characters from one string to the end of another. |
strchr() | Searches for a character within a string. The function returns that character’s position from the start of the string as a pointer. |
strrchr() | Searches for a character within a string, but in reverse. The function returns the character’s position from the end of the string as a pointer |
strstr() | Searches for one string inside another string. The function returns a pointer to the string’s location if it’s found. |
strnstr() | Searches for one string within the first n characters of the second string. The function returns a pointer to the string’s location if it’s found. |
strcpy() | Copies (duplicates) one string to another |
strncpy() | Copies a specific number of characters from one string to another. |
strlen() | Returns the length of a string, not counting the \0 or NULL character at the end of the string. |
- Example 1: compare 2 string
- Example 2: concat