满意答案
指点江山988
2016.06.01
采纳率:49% 等级:7
已帮助:362人
1.
#include
#include
#include
char* cat(char* des, char* src)
{
char* p;
assert(des != NULL);
assert(src != NULL);
p = des + strlen(des);
while (*p++ = *src++);
return des;
}
int main()
{
char s1[100] = "Computer";
char s2[100] = "Language";
cat(s1, s2);
printf("%s\n", s1);
return 0;
}
2.#include
#include
int main()
{
char s[] = "C is a general purpose, procedural, imperative computer \
programming language developed in 1972 by Dennis Ritchie at the \
Bell Telephone Laboratories for use with the Unix operating system.";
int up, low, num, space, dot;
char* p = s;
up = low = num = space = dot = 0;
while (*p)
{
if (isupper(*p))
up++;
else if (islower(*p))
low++;
else if (isdigit(*p))
num++;
else if (' ' == *p)
space++;
else if (',' == *p)
dot++;
p++;
}
printf("大写字母: %d\n", up);
printf("小写字母: %d\n", low);
printf("数字: %d\n", num);
printf("空格: %d\n", space);
printf("逗号: %d\n", dot);
return 0;
}
3.
#include
#include char* copy(char* des, char* src)
{
char* p = des;
assert(des != NULL);
assert(src != NULL);
while (*p++ = *src++);
return des;
}int main()
{
char s1[100];
char s2[] = "abcdefg";
copy(s1, s2);
printf("%s\n", s1);
return 0;
}追问: 你编的我看不懂啊T^T
追答:第几个程序看不懂?哪一行看不懂你标出来,我给你解释
追问: 指针我们没讲过
追答:好吧,我彻底无语了,等你什么时候看懂了再来采纳我的回答吧
00分享举报