Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve and explain all steps Task 1: Rightmost occurrence In this program(https://www.onlinegdb.com/tas/32618), a sample function strindex is given which has two parameters - char

please solve and explain all steps image text in transcribed
image text in transcribed
image text in transcribed
Task 1: Rightmost occurrence In this program(https://www.onlinegdb.com/tas/32618), a sample function "strindex" is given which has two parameters - char s[] and char t(). It returns the left most position of tin s. You are going to complete the function "strindexr" which has two same parameters but returns the right most position of t in s. Return-1 if there is none. The main function is used to test your function. It will print out both the left and right most index of occurrence of pattern in line. 1 #include 2 #define MAXLINE 1000 3 4 int strindex (char source(), char searchfor[]); 5 int strindexr (char source(, char searchfor(); 6 7 char pattern ] "ould"; /* pattern to search */ 8 9 int 10 main () 11- { 12 extern char posterno; 13 char line[MAXLINE) - "I would would like to test this if i could"; 14 printf ("strindex: %d\tstrindexr: %d ", strindex (line, pattern), strindexr (line, pattern)); 17 18 return 0; 19 } 20 21 int 22 strindex (char s[], char to)) 23- { 24 int i, j, k; 15 16 t[k]; j++, K++) 32 23- { 24 int i, j, k; 25 26 for (i = 0; s[i] != '\0'; i++) 27 { 28 for (j = i, k = 0; t[k] != '\0' && s[j] 29 30 if (k > 0 && t[k] '\0') 31 return i; } 33 return -1; 34 } 35 36 int 37 strindexr (char source(), char searchfor() 38 - { // YOUR CODE HERE 40 return -1; 41 } 42 43 44 39

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions