K&R C Programs Exercise 5-17

Exercise 5-17. Add a field-handling capability, so sorting may be done on fields within lines, each field sorted according to an independent set of options. (The index for this book was sorted with -df for the index category and -n for the page numbers.) Fields are whitespace-delimited columns. The syntax -k<field>[flags] selects a 1-based field …

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-12

Exercise 5-12. Extend entab and detab to accept the shorthand entab -m +n to mean tab stops every n columns, starting at column m. Choose convenient (for the user) default behavior. Two new argument forms extend the programs from Exercise 5-11: -m sets the starting column and +n sets the interval. So detab -4 +3 …