program to locate string with in a string with using strstr
function

Answer Posted / pradeep

#include<stdio.h>
#include<string.h>
void main()
{
char *str1,*str2,*ptr;
printf("Enter string1:");
scanf("%s",&str1);
printf("Enter string2:");
scanf("%s",&str2);
ptr=strstr(str1,str2);
if(ptr==0)
printf("String not located");
else
printf("string located are %s",ptr);
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c so popular?

871


What are loops in c?

761


What does c mean before a date?

831


In C language, a variable name cannot contain?

997


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

818


Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.

2914


Explain how can I read and write comma-delimited text?

916


What is the purpose of sprintf() function?

802


how do you execute a c program in unix.

850


How can I open a file so that other programs can update it at the same time?

895


What does main () mean in c?

845


What is the role of && operator in a program code?

787


What is the difference between declaring a variable by constant keyword and #define ing that variable?

2996


How do we declare variables in c?

785


write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34

1841