📄 toolfun.cpp
字号:
#include "ToolFun.h"
bool strCompare(char *ch1,char *ch2)
/* this strCompare function is little diffrent to normal string *
* compare. If all charactor of two string are same, then It *
* return true, else return false. */
{
while(*ch1!='\0' || *ch2!='\0'){
if( *ch1!=*ch2 )
{ return false; }
ch1++;
ch2++;
}
if( *ch1=='\0' && *ch2=='\0' )
{ return true; }
else
{ return false; }
}
int toInt( char* str )
/* convert digital string to integer. If success return a integer, *
* else return 0. */
{
int i;
istrstream intStr( str,sizeof(str) );
if( intStr>>i ) { return i; }
else { return 0; }
}
int toInt( const string& str)
/* convert digital string to integer. If success return a integer, *
* else return 0. */
{
int i;
istrstream intStr( str.data(),str.length() );
if( intStr>>i ) { return i; }
else { return 0; }
}
float toFloat( char* str)
/* convert digital string to float. If success return a float, *
* else return 0. */
{
float f;
istrstream intStr( str,sizeof(str) );
if( intStr>>f ) { return f; }
else { return 0; }
}
float toFloat( const string& str)
/* convert digital string to float. If success return a float, *
* else return 0. */
{
float f;
istrstream intStr( str.data(),str.length() );
if( intStr>>f ) { return f; }
else { return 0; }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -