1. Ints in string Write a function that prints out all numbers (strings of digits with optional sign) from a string given as parameter. Consider only standalone numbers, i.e. numbers that do not have any non-whitespace characters adjacent to them.
2. Span of characters Implement the functions (a) strspn, (b) strcspn. (Read class notes, man page or standard for specifications).
Then, implement a function size_t pieces(const char *s, const char *allow) which counts how many separate substrings containing characters from allow are to be found in s.
3. The Nth field Write a program that reads from input lines that contain numbers separated by commas (and possibly also whitespace), and prints the Nth number from each line. N is a constant defined in the program. Numbers may be missing between two commas, or there may be fewer than N numbers on a line. In either of these cases, print 0.
4. Searching for words
Write a program that counts the number of nonoverlapping occurrences
of a word in the input.
The word is a string constant in the program
(or you may run the program with a command line argument, define main as int main(int argc, char *argv[]), check if argc == 2 and use argv[1]).
Count also occurrences as substrings in other words.
Handle the case where the words in the input may be arbitrarily long.
An oft-ask question is "what does nonoverlapping mean?". Answer: The string "ababa" contains two occurrences of the string "aba": one starting at index 0, the other one at index 2. They overlap: the character 'a' at index 2 is common.
Nonoverlapping strings are strings that do not overlap.
5. Words with line numbers
Write a program that prints all lines from input that contain a given word.
Only the part of the line starting with the word must be printed.
Prefix it with the line number.
a) Consider only standalone words.
b) Count also occurrences as substrings in other words.
Handle arbitrarily long words.
6. HTML character entities
In HTML, some reserved and special characters are written as &name;, for instance & for &, < for <, > for >, € for € etc.
a) Write a program that prints all entities of the form &name; (where name is formed of letters) appearing in the input, separated by one space.
b) The same, for entities of the form &#number; (with nonnegative numbers)
c) Sometimes, people forget the trailing semicolon, resulting in invalid HTML which browsers don't display well, here is an example (with interesting logic problems). Write a program that prints out the input, adding a semicolon ; after each &name where it is missing.
7. XML tags Write a program that reads input and prints out the name of any empty element tags of the form <name some other chars/> where name is assumed to be formed of alphanumeric characters.
8. Running times Write a program that reads from input a list of finishing times in a race (given in increasing order), in the form h:mm:ss, one per line. Print the winning time on a line, and for each of the other finishing times, the difference with respect to the previous time, and with respect to the winning time. For example, for the input
3:51:38 4:05:47 4:11:28the program should print
3:51:38 +0:14:09 0:14:09 +0:05:41 0:19:50
9. Structured text The .srt format for subtitles has the following structure. Each subtitle group is formed of four parts, on separate lines
10. Conjunctive normal form The DIMACS format for a logic formula in conjunctive normal form contains: