#include < stdio.h>
#include < stdlib.h>
#define LEN 16
int main() {
char str[LEN] = "This is a book.";
char str1[LEN];
char *ptr = str;
char *ptr1;
int i;
ptr1 = "This is a pen.";
printf("str = %s\n", str);
printf("ptr = %s\n", ptr);
printf("ptr1 = %s\n", ptr1);
printf("將字串str複製到str1: \n");
i = 0;
ptr1 = str1;
while ( *ptr != '\0' ) {
*(ptr1++) = *ptr++;
}
*(ptr1++) = '\0';
printf("str1 = %s\n", str1);
printf("ptr1 = %s\n", ptr1);
system("PAUSE");
return 0;
}
評分: ★★★★▲
回覆刪除Good Job !