
/* 字符串的拷贝 */
#include <stdio.h>
#define SIZE 256
int main(void) {
char str1[SIZE] = "\0";
char str2[SIZE] = "\0";
char * p1 = str1;
char * p2 = str2;
/* 从标准输入获得一个字符串,为str1赋值 */
printf("Please input the source string:\n");
gets(p1);
/* 由于两个字符数组大小相同,因此可以不考虑字符溢出 */
while ('\0' != *p1)
*p2++ = *p1++;
/* 输出拷贝完成后的str2的内容 */
p2 = str2;
printf("The destination string is:\n");
puts(p2);
return 0;
}




by: 发表于:2017-08-21 14:30:24 顶(0) | 踩(0) 回复
??
回复评论