write the function. if all the character in string B appear in
string A, return true, otherwise return false.

Answers were Sorted based on User's Feedback



write the function. if all the character in string B appear in string A, return true, otherwise ret..

Answer / kathiresan

#include<stdio.h>
#include<string.h>

int main()
{
char *str1 = "Hello";
char *str2 = "Hello";

int len1,len2;
len1 = strlen(str1);
len2 = strlen(str2);
if(len1 != len2)
{
printf("\nBoth Strings are not matched");
return 0;
}

while(*str1)
{
if(*str1 == *str2)
{
*str1++;
*str2++;
}
else
{
printf("\nString Not Matched\n");
return 0;
}
}
printf("\nBoth String are EQual");
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Code Interview Questions

void main() { int i=5; printf("%d",i+++++i); }

3 Answers  


main() { show(); } void show() { printf("I'm the greatest"); }

2 Answers  


main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }

1 Answers  


Write a program that find and print how many odd numbers in a binary tree

1 Answers  


Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);

1 Answers  


why array index always strats wuth zero?

2 Answers  


Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.

21 Answers   ABC, eBay, Goldman Sachs, Google, HUP, Microsoft, TATA,


main() { struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }

1 Answers  


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(“%d” ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(“%d ” ,*p); p++; } }

1 Answers  


write a c program to Reverse a given string using string function and also without string function

1 Answers  


#include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); }

1 Answers  


Categories