Link to home
Start Free TrialLog in
Avatar of vikasgkutty
vikasgkutty

asked on

check if a string is substring of another(Easy q)

I have a string named in a variable lets say X
I have another string variable called Y
All I need to do is check if X is a subset of Y

for example if X="S1P1"
and Y= "S1P1s"
then it should give me true when i check this

Easy question,rt..
                         
Avatar of ankuratvb
ankuratvb
Flag of United States of America image

use strstr() provided in string.h
ASKER CERTIFIED SOLUTION
Avatar of ankuratvb
ankuratvb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For your e.g.

char *ptr=strstr(Y,X);
Avatar of crazycomputers
crazycomputers

vikasgkutty:

This is homework, isn't it?
Avatar of Avik Dasgupta
Absolutely, this looks nothing but a homework. These type of assignments we used to get in our semesters and of course we had to implement them without using string libraries.

Avik.
Avatar of vikasgkutty

ASKER

how can this be homework, crazycomputers?
this is a very small check i wanted to do, in a project, tht I have been doing all sem,as Avik said