program to locate string with in a string with using strstr
function
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / gmail
#include<iostream.h>
#include<conio.h>
void main()
{
char str1[15],str2[15];
clrsacr();
cout<<"Enter a string";
cin>>str1;
cout<<"\nEnter another string to be located";
cin>>str2;
int n;
n=strstr(str1,str2);
if(n==0)
cout<<"\nstring not locatd";
else
cout<<"At location "<<(n+1);
getch();
}
Is This Answer Correct ? | 3 Yes | 6 No |
Every time i run a c-code in editor, getting some runtime error and editor is disposing, even after reinstalling the software what may be the problem?
write a program to display & create a rational number
Write a program to print factorial of given number without using recursion?
How is a null pointer different from a dangling pointer?
How many bytes is a struct in c?
what is structuer?
How are Structure passing and returning implemented by the complier?
write a c program for print your name .but,your name may be small letter mean print a capital letter or your name may be capital letter mean print a small letter .example \\enter ur name : sankar The name is: SANKAR (or) enter your name:SAnkar The name is:saNKAR
what is the difference between static variable and register variable?
What is the memory allocated by the following definition ? int (*x)[10];
what is the maximum limit of row and column of a matrix in c programming. in linux .
Which of these statements are false w.r.t File Functions? i)fputs() ii)fdopen() iii)fgetpos() iv)ferror() A)ii B)i,ii C)iii D)iv