1.//**************************************************************************************
char* reverse(char* Array)
{
int len = strlen(Array);
for(int i=0;i<len/2;i++)
{
char temp=*(Array+i);
*(Array+i)=*(Array+len-1-i);
*(Array+len-1-i)=temp;
}
*(Array+len)='/0';
return Array;
}
2.//**************************************************************************************
long __cdecl atol(
const char *nptr
)
{
int c; /* current char */
long total; /* current total */
int sign; /* if '-', then negative, otherwise positive */
/* skip whitespace */
while ( isspace((int)(unsigned char)*nptr) )
++nptr;
c = (int)(unsigned char)*nptr++;
sign = c; /* save sign indication */
if (c == '-' || c == '+')
c = (int)(unsigned char)*nptr++; /* skip sign */
total = 0;
while (isdigit(c)) {
total = 10 * total + (c - '0'); /* accumulate digit */
c = (int)(unsigned char)*nptr++; /* get next char */
}
if (sign == '-')
return -total;
else
return total; /* return result, negated if necessary */
}
3.//**************************************************************************************
判断一个链表是否为循环链表(追赶法)
bool isLoop(link *head)
{
link *p = head;
link *q = head;
while(p != NULL && q != NULL && q->next != NULL)
{
p = p->next;
q = q->next->next;
if(p == q)
return true;
}
return false;
}
4.//**************************************************************************************
char * strchr (
const char * string,
int ch
一些常用的C语言函数源代码
最新推荐文章于 2023-09-06 10:09:27 发布
本文分享了几个C语言中常见的函数实现,包括字符串反转、长整型转换、检查循环链表、查找子串、字符串比较、计算字符串长度、标准输出、内存复制、内存比较、内存设置、字符串拼接、字符查找、内存定位、内存移动等,帮助理解C语言的基础操作。

最低0.47元/天 解锁文章

1897

被折叠的 条评论
为什么被折叠?



