iCAx开思网

标题: Ug/Open api中的字符串操作函数 [打印本页]

作者: situzhi    时间: 2010-5-11 20:32
标题: Ug/Open api中的字符串操作函数
帮忙提供下api中的字符串操作函数,比如字符串比较函数!
作者: qindongjun88    时间: 2010-5-11 22:07
NX_API中好像没有这样的函数,不过我是使用C++的函数来实现字符比较的.

strcmp
语法:




  #include <string.h>
  int strcmp( const char *str1, const char *str2 );


功能:比较字符串str1 and str2, 返回值如下:

返回值
解释

less than 0
str1 is less than str2

equal to 0
str1 is equal to str2

greater than 0
str1 is greater than str2


例如:

    printf( "Enter your name: " );
    scanf( "%s", name );
    if( strcmp( name, "Mary" ) == 0 )
      printf( "Hello, Dr. Mary!\n" );




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3