Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c program 1 - WAP to implement strtok function Description: Read string1 and string2 from user. Call my_strtok (string1, string2); Should treat string2 as delimitter

c program

1 - WAP to implement strtok function

Description:

Read string1 and string2 from user.

Call my_strtok (string1, string2);

Should treat string2 as delimitter in string1 and should return 1 st field.

If you call again my_strtok (NULL, string2), it should return second field in string1 treating string2 as delimitter.

Pr-requisites:-

Storage Classes

Strings

Pointers

Objective: -

To understand the concept of

Strings functions

Inputs: - 2 Strings Sample execution: - Test Case 1: user@emertxe] ./my_strtok Enter string1 : Bangalore;;::---Chennai:;Kolkata:;Delhi:-:Mumbai Enter string2 : ;./-: Tokens : Bangalore Chennai Kolkata Delhi Mumbai Test Case 2: user@emertxe] ./my_strtok Enter string1 : -;Bangalore;;::---Chennai:;Kolkata:;Delhi:- Enter string2 : ;./-: Tokens : Bangalore Chennai Kolkata Delhi

requested file

#include #include #include

char *my_strtok(char str[], const char delim[]);

int main() { char str[50], delim[50]; printf("Enter the string : "); scanf("%s", str); __fpurge(stdout); printf("Enter the delimeter : "); scanf(" %s", delim); __fpurge(stdout); char *token = my_strtok(str, delim); printf("Tokens : "); while (token) { printf("%s ", token); token = my_strtok(NULL, delim); } }

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

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

Students also viewed these Databases questions