惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
B
Blog
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
A
About on SuperTechFans
H
Heimdal Security Blog
AI
AI
F
Full Disclosure
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
量子位
I
InfoQ
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
N
News and Events Feed by Topic
腾讯CDC
L
LINUX DO - 最新话题
Attack and Defense Labs
Attack and Defense Labs
Hacker News: Ask HN
Hacker News: Ask HN
Google Online Security Blog
Google Online Security Blog
博客园_首页
Forbes - Security
Forbes - Security
The Register - Security
The Register - Security
博客园 - 三生石上(FineUI控件)
PCI Perspectives
PCI Perspectives
V
Vulnerabilities – Threatpost
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
LangChain Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
NISL@THU
NISL@THU
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
H
Hacker News: Front Page
Project Zero
Project Zero
P
Privacy International News Feed
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - LeeXiaoLiang

自己写的一个javascript下拉列表类 jquery1.5.1根据元素ID获取元素对象 jquery向.ashx文件post中文乱码问题的解决 【转】通过在RowDataBound事件中把行索引绑定到控件的CommandArgument,然后在RowCommand事件中取出 - LeeXiaoLiang - 博客园 【转】GridView的RowCommand事件中取得行索引 - LeeXiaoLiang - 博客园 【转】GridView 实现服务器端和客户端全选的两种方法 ASP.NET之GridView数据绑定 - LeeXiaoLiang - 博客园 希尔排序的C语言实现(2) 希尔排序的C语言实现(1) 简单插入排序的C语言实现 堆排序的C语言实现 对于堆排序算法的理解 【转】sqlserver中分页方法集锦 【转】高效的MySQL分页 【摘】完全二叉树 【原创】连接字符串数组 【原创】用C实现Trim()函数 - LeeXiaoLiang - 博客园 【转】浅谈数据库设计技巧 [转]数据库设计范式的理解
【摘】用C实现将数组转换为字符串
LeeXiaoLiang · 2010-08-05 · via 博客园 - LeeXiaoLiang

代码

#include <stdio.h>
#include 
<stdlib.h>char *digitToAlpha (int val, char *buf, unsigned radix);int main(int argc, char *argv[])
{
  
int iNum=1000;
  
char strNum[10]="";
  digitToAlpha(iNum,strNum,
10);
  printf(
"%s\n",strNum);
  
  system(
"PAUSE");    
  
return 0;
}
/*
功能:将数值转换为字符串
参数:第一个是要转化的整数   
     第二个是转化后的字符串
     第三个是要转化整数的基数,就是说如果基数是10,就可以直接转化,如果不是10,是其他值(2-36之间),则先把该整数转化为该基数的数后,再转化为字符串
*/
char *digitToAlpha (int val, char *buf, unsigned radix) 

    
char *p; /* pointer to traverse string */ 
    
char *firstdig;/* pointer to first digit */ 
    
char temp; /* temp char */ 
    unsigned digval; 
/* value of digit */ 

    p 

= buf; if(val<0)
    { 
        
/* negative, so output '-' and negate */ 
        
*p++= '-'
        val 
= (unsigned long)(-(long)val); 
    } 

    firstdig 

= p;/* save pointer to first digit */ do { 
        digval 
= (unsigned)(val%radix); 
        val 
/=radix; /* get next digit */ /* convert to ascii and store */ 
        
if (digval > 9
            
*p++ = (char) (digval - 10 + 'a'); /* a letter */ 
        
else 
            
*p++ = (char) (digval + '0'); /* a digit */ 
    } 
while(val > 0); /* We now have the digit of the number in the buffer, but in reverse 
    order. Thus we reverse them now. 
*/ *p-- = '\0'/* terminate string; p points to last digit */ do 
    { 
        temp 
= *p; 
        
*=*firstdig; 
        
*firstdig= temp; /* swap *p and *firstdig */ 
        
--p; 
        
++firstdig;     /* advance to next two digits */ 
    } 
while (firstdig < p); /* repeat until halfway */ return buf; 
}

该程序的测试环境:

WinXPSP2,Dev C++ 4.9.9.2