Dear Sir/Madam,
I am doing my project in C.I need to develop the string comparison program without using the standard functions.Can you please guide me on this issue?
Thank you
S.ashwini
Dear Sir/Madam,
I am doing my project in C.I need to develop the string comparison program without using the standard functions.Can you please guide me on this issue?
Thank you
S.ashwini
Can you show us your attempt first?
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.
So you're supposed to write your own string comparison function? What have you tried? You basically loop through both the strings, one char at a time, until you find a NUL character or the current chars differs.
Hi,
I have tried to campare srtings with equal to sign.If i campare single character with equal to sign then is it going work?
S.ashwini
you cant directly compare two strings using the equals sign, you need to compare each character within the string.
if it makes it easier, it would be the same as comparing these two arrays
how could you determine whether or not the two arrays contain the same numbers?Code:int array1[] = {1, 2, 3}; int array2[] = {1, 2, 4};
Last edited by LordPc; 06-18-2010 at 07:30 AM.
Hi,
Thank you sir.I am getting the idea from your reply.I will try this character comparison in my program at home and get back to you later.
Thank you.
S.ashwini