通用C语言程序

来源:互联网 发布:管道安装算法 编辑:程序博客网 时间:2024/05/01 12:54
//字符串按空格分割void data_to_convert(char *ucStr)  {               // char ucStr[MAX] ="qwe 982 uowop 24554";      int uiCount = 0, uiLine = 0, uiRow = 0,uiI;      os_memset(ucData,0,sizeof(ucData));      while( '\0'!=ucStr[uiCount] )      {          if( ' '!=ucStr[uiCount] )         {              ucData[uiLine][uiRow] = ucStr[uiCount];              ++uiRow;              ++uiCount;         }          else          {              ucData[uiLine][uiRow]='\0';              ++uiLine;              uiRow = 0;              ++uiCount;          }      }      for(uiI=0;uiI<=uiLine ;uiI++)      {          os_printf("%s ",ucData[uiI]);    } }  // 将月份英文简写转化成数字int GetMon(char *str_mon){    int month = 0;    int i = 0;    const char *list_mon[] = {"Jua","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};    const char *month_id = str_mon;    for(i=0; i<12; i++)    {        if(os_strcmp(str_mon, list_mon[i]) == 0)        {            month = i+1;            return month;        }    }    return month;                                                                                                 }/*将字符串中字母全部变成大写*/void  aConvertA(char *str, int len){    int i = 0;    for (i = 0; i < len; i++)    {        if (str[i] >= 'a' && str[i] <= 'z')        {            str[i] -= 32;        }    }}/*将字符串变成十六进制--> "12f122bc33"--->0x12 0xf1 0x22 0xbc 0x33*/void  str2hex(char* str){    char var = 0;    char t;    int i = 0;    int j = 0;    int len = os_strlen(str);    aConvertA(str, len);    for (; *str; str++)    {        if (*str >= 'A' && *str <= 'F')            t = *str - 55;//a-f之间的ascii与对应数值相差55如'A'为65,65-55即为A        else            t = *str - 48;        var <<= 4;        var |= t;        i++;        if (i % 2 == 0)        {            tempdata[j++] = var;            var = 0;        }    }}
0 0
原创粉丝点击