1 #include "stdafx.h"
2 #include "iostream"
3 #include "assert.h"
4 5 using namespace std;
6 7 int mystrcmp(
const char* dest,
const char* src)
8 {
9 assert (dest!=NULL && src!=NULL);
10 while (*dest++ == *src++)
11 {
12 if (*dest=='\0' || *src=='\0')
13 break;
14 }
15 return *dest > *src ? 1 : (*dest==*src ? 0 : -1);
16 }
17 18 int main(
int argc,
char* argv[])
19 {
20 printf("Hello World!\n");
21 cout << mystrcmp("abc", "abcd");
22 cout << endl;
23 return 0;
24 }
输出:
Hello World!
-1
Press any key to continue