strcmp 使用说明
来源:互联网 发布:自学java看什么书 知乎 编辑:程序博客网 时间:2024/06/06 09:16
function
http://www.cplusplus.com/reference/clibrary/cstring/strcmp/
http://www.cplusplus.com/reference/clibrary/cstring/strcmp/
strcmp
<cstring>
int strcmp ( const char * str1, const char * str2 );
Compare two strings
Compares the C string str1 to the C string str2.This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminating null-character is reached.
Parameters
- str1
- C string to be compared.
- str2
- C string to be compared.
Return Value
Returns an integral value indicating the relationship between the strings:A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value instr1 than instr2; And a value less than zero indicates the opposite.
Example
123456789101112131415
/* strcmp example */#include <stdio.h>#include <string.h>int main (){ char szKey[] = "apple"; char szInput[80]; do { printf ("Guess my favourite fruit? "); gets (szInput); } while (strcmp (szKey,szInput) != 0); puts ("Correct answer!"); return 0;}
Output:
Guess my favourite fruit? orangeGuess my favourite fruit? appleCorrect answer!
- strcmp 使用说明
- strcmp
- strcmp
- strcmp
- strcmp
- StrCmp
- strcmp
- strcmp
- strcmp
- strcmp
- strcmp
- strcmp
- strcmp
- strcmp
- strcmp
- strcmp
- strcmp
- strcmp
- UDP协议复习
- How to Perfectly Uninstall Ask Toolbar
- 标点符号全角转半角
- HTML5与JQuery.Mobile(三)
- 寻找马鞍点
- strcmp 使用说明
- JDBC连接oracle 10g express Edition 的时候报错error while performing database login with ** driver
- 3D Cross-Platform 3rd Person Shooter - To Intel x86 Android
- 【数据结构】选择排序
- linux 安装python的postgres库
- Android屏幕亮度调节
- FileUtiles文件上传
- android 多媒体部分学习笔记十五-----视频录制
- windows下访问Ext2/Ext3的一些解决方案