Write a program to compare two strings without using the
strcmp() function
Answer Posted / sujith
#include<stdio.h>
int str_cmp(const char *s1, const char *s2)
{
unsigned int i = 0, diff;
while(*(s1+i) && *(s2+i))
{
diff = (*(s1+i)-*(s2+i));
if(!diff)i++;
else break;
}
return diff;
}
int main()
{
printf("chuma %d ", str_cmp("abcd","abcde"));
return 0;
}
U can use this as a prototype and enhance this. I havent
even tried compilng this.
Sujith
| Is This Answer Correct ? | 115 Yes | 113 No |
Post New Answer View All Answers
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
What is a dynamic array in c?
What are c preprocessors?
Write a program to reverse a linked list in c.
Combinations of fibanocci prime series
Explain high-order bytes.
What is the use of static variable in c?
Tell us two differences between new () and malloc ()?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
Without Computer networks, Computers will be half the use. Comment.
What is calloc in c?
Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
Differentiate between new and malloc(), delete and free() ?