C Program

by

This program expects two command-line arguments: the first is a string, the second a number n. The program must determine and list all distinct substrings of length n that ex- ist in the given string. In addition to listing the strings, your program must also list the number of occurrences of each substring, both with and with- out overlap. You might consider defining a function based on the solution to … countsubs.c that can be called (twice) when outputting each string to provide the requisite information. If the number of command-line ar- guments is incorrect or if the second command-line argument represents an integer 6 0, an appropriate usage message must be printed to standard error and the program must halt with exit status 1. The following are some sample, non-exhaustive test cases. Your program is expected to produce identical output. Do not prompt for input.
1 $ ./a . out aaabccbcbcebcebfff
2 Usage : string n (where n must be > 0 )
3 $ echo $?
4 1
5 $ ./a . out aaabccbcbcebcebfff 3
6
7 Unique substrings of length 3 :
8
9 aaa / 1 / 1
10 aab / 1 / 1
11 abc / 1 / 1
12 bcc / 1 / 1
13 ccb / 1 / 1
14 cbc / 2 / 1
15 bcb / 1 / 1
16 bce / 2 / 2
17 ceb / 2 / 2
18 ebc / 1 / 1
19 ebf / 1 / 1
20 bff / 1 / 1
21 fff / 1 / 1
22 $ ./a . out aaabccbcbcebcebfff 2
23
24 Unique substrings of length 2 :
25
26 aa / 2 / 1
27 ab / 1 / 1
28 bc / 4 / 4
29 cc / 1 / 1
30 cb / 2 / 2
31 ce / 2 / 2
32 eb / 2 / 2
33 bf / 1 / 1
34 ff / 2 / 1
35 $ ./a . out aaabccbcbcebcebfff 4
36
37 Unique substrings of length 4 :
38
39 aaab / 1 / 1
40 aabc / 1 / 1
41 abcc / 1 / 1
42 bccb / 1 / 1
43 ccbc / 1 / 1
44 cbcb / 1 / 1
45 bcbc / 1 / 1
46 cbce / 1 / 1
47 bceb / 2 / 1
48 cebc / 1 / 1
49 ebce / 1 / 1
50 cebf / 1 / 1
51 ebff / 1 / 1
52 bfff / 1 / 1
53 $ ./a . out aaabccbcbcebcebfff 10
 
Problem 2:
Write a C program, namely “parsestring.c”, that does the fol- lowing until EOF: i) reads a line from standard input, including an empty line, with getline, ii) tokenizes the line based on spaces and tabs, iii) builds an array of character arrays (pointers) to store the token of the line, iv) write each token to standard output from that array of character pointers, and v) frees the array of character pointers. For instance, if the input line is one two three four, the structure built is:And the output is:
1 : one :
2 : two :
3 : three:
4 : four :The following are some sample, non-exhaustive test cases. Your program
is expected to produce identical output. Do not prompt for input.
1 $ ./a . out
2 one two three four
3 : one :
4 : two :
5 : three:
6 : four :
7 apple orange pear lemon lime
8 : apple:
9 : orange:
10 : pear :
11 : lemon:
12 : lime :
13
14 −a −b −c −d −e −f −h
15 :−a :
16 :−b :
17 :−c :
18 :−d :
19 :−e :
20 :−f :
21 :−h :
22 ^D
23 $
24 $ c a t input . txt
25 one two three four
26 apple orange pear lemon lime
27
28 −a −b −c −d −e −f −h
29 $
30 $ ./a . out < input. txt
31 : one :
32 : two :
33 : three:
34 : four :
35 : apple:
36 : orange:
37 : pear :
38 : lemon:
39 : lime :
40 :−a :
41 :−b :
42 :−c :
43 :−d :
44 :−e :
45 :−f :
46 :−h :
Approximate price: $22
We value our customers and so we ensure that what we do is 100% original..

With us you are guaranteed of quality work done by our qualified experts.Your information and everything that you do with us is kept completely confidential.You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.The Product ordered is guaranteed to be original. Orders are checked by the most advanced anti-plagiarism software in the market to assure that the Product is 100% original. The Company has a zero tolerance policy for plagiarism.The Free Revision policy is a courtesy service that the Company provides to help ensure Customer’s total satisfaction with the completed Order. To receive free revision the Company requires that the Customer provide the request within fourteen (14) days from the first completion date and within a period of thirty (30) days for dissertations.The Company is committed to protect the privacy of the Customer and it will never resell or share any of Customer’s personal information, including credit card data, with any third party. All the online transactions are processed through the secure and reliable online payment systems.By placing an order with us, you agree to the service we provide. We will endear to do all that it takes to deliver a comprehensive paper as per your requirements. We also count on your cooperation to ensure that we deliver on this mandate.

Never use plagiarized sources. Get Your Original Essay on
C Program
Hire Professionals Just from $11/Page
Order Now Click here