strcmp... please.. elp T_T

i need your help
please help me convert strcmp() to a program C++ program..
I mean a program that will work like strcmp.. thanks!!

here is my email:
m3rilix@yahoo.com
If you're looking to put the function in your project, the library function is pretty much works like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

int strcmp(char*s, char*t);

int main()
{	
	char string1[] = "summer";
	char string2[] = "winter";
	int x;

	x = strcmp( string1, string2 );

	cout << x << endl;
}

int strcmp( char*s, char*t )
{
	while( *s && *s == *t ) {
		s++;
		t++;
	}
	return *s - *t;
}


ex. returns -4, s is 4 less than w when comparing the integer ascii values.
returns 0 if they are the same word.
returns >0 if string1 is larger.

use the return value if your logical statements.
Last edited on
Topic archived. No new replies allowed.