Chat with us, powered by LiveChat C Program | Writedemy

C Program

C Program

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 :

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order