zhiye_wang

向星空仰望的越深,越发现自己的渺小

博客园 首页 新随笔 联系 订阅 管理
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
posted on 2016-02-23 10:26  zhiye_wang  阅读(113)  评论(0编辑  收藏  举报