Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include unsigned char* strstr(const char *str, const char *target) { unsigned char *s; if (!*target) return (unsigned char *)str; s = (unsigned char*)str; while

#include #include

unsigned char* strstr(const char *str, const char *target) {

unsigned char *s; if (!*target) return (unsigned char *)str;

s = (unsigned char*)str;

while (*s) { char *start = s, *t = (char*)target;

while (*s && *t && *s == *t) { s++; t++; } if (!*t) return (unsigned char *) start;

s = start + 1; }

return (unsigned char *) 0; }

int main(){

char str1[] = "123456565656987";

char str2[] = "698";

unsigned char *p;

volatile int position = -1;

p = strstr (str1, str2);

if ( p != 0) position = (void *)p - (void *)str1 + 1;

printf("%d ", position); printf("%s ", p); getch(); }''

image text in transcribed

this is the output of this code. can anyone explain me the output.

Select C:\UsersitasnilDesktop\yhm.exe 12 6987

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

More Books

Students also viewed these Databases questions