c25.cpp

来自「本文档含有多个C++程序」· C++ 代码 · 共 31 行

CPP
31
字号
// c25.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream.h>

int strcmp( const char* str1, const char* str2 );

int main(int argc, char* argv[])
{
	char* ps1 = "abc";
	char* ps2 = "ab";

	int compare = strcmp( ps1, ps2 );
	if ( compare > 0 )
		cout << ps1 << " > " << ps2 << endl;
	else if ( compare < 0 )
		cout << ps1 << " < " << ps2 << endl;
	else
		cout << ps1 << " = " << ps2 << endl;

	return 0;
}

int strcmp( const char* str1, const char* str2 )
{
	while( (*str2!=0) && (*str1++==*str2++));

	return *str1-*str2;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?