[讨论]老师吩咐要背这几个代码请大家讨论一下这几个代码的好处。
(1)#include <stdio.h>
void main()
{
char ch;
while(( ch = getchar()) !=EOF)
{
putchar(ch);
}
}
(2)
#include <stdio.h>
void main()
{
char *ps="We change lives";
int n=10;
ps=ps+n;
printf("%s\n",ps);
}
(3)
void mystrcpy(char dest[],char src[])
{
int i=0;
while(src[i] != '\0')
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
}
(4)
int mystrlen(char *s)
{
int n=0;
while(*s != '\0')
{
++s;
++n;
}
return n;
}