K&R C Programs Exercise 5-16

Exercise 5-16. Add the -d (directory order) option, which makes comparisons only on letters, numbers and blanks. Make sure it works in conjunction with -f. Directory order ignores punctuation and control characters — only alphanumeric characters and spaces are considered. The comparison function skips non-directory characters in both strings simultaneously, then compares the next significant …

C Program to demonstrate the strtok function.

C Program to demonstrate the strtok function.strtok function breaks pointed by the string1 into sequence of tokens, which are sequences of contiguous characters separated by any of the characters that are part of delimiters.In this program we split the test_string, i,e “string to split up ” tostringtosplitupRead more about C Programming Language . /************************************************************ You …

K&R C Programs Exercise 5-14

Exercise 5-14. Modify the sort program to handle a -r flag, which indicates sorting in reverse (decreasing) order. Be sure that -r works with -n. The K&R sort from Section 5.11 calls qsort with a comparison function strcmp. Adding -r requires the comparison function to negate its result. The cleanest approach: add a global flag …

C Program to demonstrate the strstr function.

C Program to demonstrate the strstr function.strstr function finds the substring in a string. strstr() returns pointer of the first occurrence of the string other wise it returns the null pointer is returned.In this program strstr returns a pointer into ‘string’ if ‘test’ is found, if not found, NULL is returned. Read more about C …

C Program to demonstrate strpbrk function.

Write C programt to demonstrate strpbrk function.strpbrk function locate the first occurrence pointed by the of string s1 from the string pointed to by s2. In this program, We Turns miscellaneous field separators into just a space separating tokens for easy parsing by SSCANF. Eventually, the character separators and replacement character will be passed in …

K&R C Programs Exercise 5-13

Exercise 5-13. Write the program tail, which prints the last n lines of its input. By default, n is 10, say, but it can be changed by an optional argument, so that tail -n prints the last n lines. The program should behave rationally no matter how unreasonable the input or the value of n. …