咨询一个glibc中strcat的实现的一个疑点
咨询一个glibc中strcat的实现的一个疑问
/* Append SRC on the end of DEST. */
char *
strcat (dest, src)
char *dest;
const char *src;
{
char *s1 = dest;
const char *s2 = src;
reg_char c;
/* Find the end of the string. */
do
c = *s1++;
while (c != '\0');
/* Make S1 point before the next character, so we can increment
it while memory is read (wins on pipelined cpus). */
s1 -= 2;
do
{
c = *s2++;
*++s1 = c;
}
while (c != '\0');
return dest;
}
在glibc 的sting文件下的strcat.c源代码中为什么函数的定义可以是下面的这种形式,我模仿一个函数却不能编译通过
strcat (dest, src)
char *dest;
模仿的函数如下
#include <stdio.h>
int strhhh (a)
int *a;
{
printf("a is(%u)",*a);
return 1;
}
int main(void)
{
int b =3;
strhhh(&b);
}
const char *src;
------解决思路----------------------
不要纠结了,这是二十多年前的语法,早就淘汰了。
int strhhh (a)
int *a;
{
......
这个相当于 int strhhh (int *a)
{
...
/* Append SRC on the end of DEST. */
char *
strcat (dest, src)
char *dest;
const char *src;
{
char *s1 = dest;
const char *s2 = src;
reg_char c;
/* Find the end of the string. */
do
c = *s1++;
while (c != '\0');
/* Make S1 point before the next character, so we can increment
it while memory is read (wins on pipelined cpus). */
s1 -= 2;
do
{
c = *s2++;
*++s1 = c;
}
while (c != '\0');
return dest;
}
在glibc 的sting文件下的strcat.c源代码中为什么函数的定义可以是下面的这种形式,我模仿一个函数却不能编译通过
strcat (dest, src)
char *dest;
模仿的函数如下
#include <stdio.h>
int strhhh (a)
int *a;
{
printf("a is(%u)",*a);
return 1;
}
int main(void)
{
int b =3;
strhhh(&b);
}
const char *src;
------解决思路----------------------
不要纠结了,这是二十多年前的语法,早就淘汰了。
int strhhh (a)
int *a;
{
......
这个相当于 int strhhh (int *a)
{
...