program for comparing 2 strings without strcmp()

Answer Posted / ankitecian

int StrCmp(const char *_input1, const char *_input2)
{
int _cntr1 = 0;
int _flg = 0;
while(*(_input1 + _cntr1) != NULL || *(_input2 + _cntr1) !
= NULL)
{
if(*(_input1 + _cntr1) != *(_input2 + _cntr1))
{
_flg = -1;
}
_cntr1++;
}
return _flg;
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

which is conditional construct a) if statement b) switch statement c) while/for d) goto

1016


How can I change the size of the dynamically allocated array?

919


What is nested structure with example?

848


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

990


Is c programming hard?

795


Differentiate between new and malloc(), delete and free() ?

931


What is a pragma?

906


Are pointers integers in c?

850


any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above

853


Why does everyone say not to use gets?

830


What are inbuilt functions in c?

803


What are void pointers in c?

799


Explain the difference between malloc() and calloc() in c?

833


What is static memory allocation? Explain

844


number of times a digit is present in a number

1810