2010年5月6日 星期四

Ch3-4-1e.c

#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;
}

1 則留言:

JCCL 提到...

評分: ★★★★
Good Job !
pls format your source code!