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 |
Do you know the use of fflush() function?
Where we use clrscr in c?
what is the output of the below code? main( ) { printf ( "\nOnly stupids use C?" ) ; display( ) ; } display( ) { printf ( "\nFools too use C!" ) ; main( ) ; }
main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }
What is ambagious result in C? explain with an example.
What is the best way to store flag values in a program?
When should the volatile modifier be used?
program for swapping two strings by using pointers in c language
Suppose I want to write a function that takes a generic pointer as an argument and I want to simulate passing it by reference. Can I give the formal parameter type void **, and do something like this? void f(void **); double *dp; f((void **)&dp);
Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
5 Answers TCS, Vimukti Technologies,
Write a small C program to determine whether a machine's type is little-endian or big-endian.