?? mystring.c
字號:
//**********************************************************************************
//楊屹 2002/08/20 第一版
//字符串操作函數
//聯系方法:gdtyy@ri.gdt.com.cn(2003/07/31以前有效)
//**********************************************************************************
//使用方法:
//自包含
//與標準庫函數用法相同。
//**********************************************************************************
#include <includes.h>
void yystrlwr(unsigned char *str)//將字符串全部轉換成小寫格式
{
int i;
unsigned char ch;
for(i=0;1;i++){
ch=*(str+i);
if(ch=='\0') break;
else if(ch>='A'&&ch<='Z') *(str+i)=ch-'A'+'a';
}
}
char yystrcmp(unsigned char *stra,unsigned char *strb)//比較a和b兩個字符串的大小,a>b 1 a=b 0 a<b -1
{
int i;
unsigned char cha,chb;
for(i=0;1;i++){
cha=*(stra+i);
chb=*(strb+i);
if(cha=='\0'&&chb=='\0') return 0;
else if(cha>chb) return 1;
else if(cha<chb) return -1;
}
}
unsigned int yystrlen(unsigned char *str)//計算字符串長度,不包括'\0'標志。
{
unsigned int i=0;
while(*str++!='\0'){
i++;
}
return i;
}
bit StrToNum(unsigned char *Str,long int *Num)//字符串轉換成數值(自動區分十進制“無前綴”和十六進制“0x”)
{
int i=0;
unsigned char ch;
long int x=0;
if(Str[0]=='0'&&(Str[1]=='x'|Str[1]=='X')){
i=2;
ch=Str[i];
while(ch!='\0'&&i<MaxLenStr){
if((ch<'0'||ch>'9')&&(ch<'a'||ch>'z')&&(ch<'A'||ch>'Z')) return 0;
else{
if(ch>='0'&&ch<='9') x=x*16+(ch-'0');
else if(ch>='a'&&ch<='z') x=x*16+(ch-'a'+10);
else x=x*16+(ch-'A'+10);
//x=x*10+(ch-'0');
}
i=i+1;
ch=Str[i];
}
if(i<MaxLenStr||Str[MaxLenStr]=='\0'){
*Num=x;
return 1;
}
else return 0;
}
else{
i=0;
ch=Str[i];
while(ch!='\0'&&i<MaxLenStr){
if(ch<'0'||ch>'9') return 0;
else x=x*10+(ch-'0');
i=i+1;
ch=Str[i];
}
if(i<MaxLenStr||Str[MaxLenStr]=='\0'){
*Num=x;
return 1;
}
else return 0;
}
}
bit StrToHEX(unsigned char *Str,long int *Num)//字符串轉換成數值(默認字符串為十六進制數值表示)
{
int i=0;
unsigned char ch;
long int x=0;
ch=Str[i];
while(ch!='\0'&&i<MaxLenStr){
if((ch<'0'||ch>'9')&&(ch<'a'||ch>'z')&&(ch<'A'||ch>'Z')) return 0;
else{
if(ch>='0'&&ch<='9') x=x*16+(ch-'0');
else if(ch>='a'&&ch<='z') x=x*16+(ch-'a'+10);
else x=x*16+(ch-'A'+10);
}
i=i+1;
ch=Str[i];
}
if(i<MaxLenStr||Str[MaxLenStr]=='\0'){
*Num=x;
return 1;
}
else return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -