#include <stdio.h>
#include <cs50.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char *argv[]) {
printf("Input a string:");
char *text=GetString();
char *tmp=(char *)malloc(sizeof(char) * strlen(text));
memcpy(tmp,text,strlen(text));
printf("%s\n%s\n",text,tmp);
return 0;
}
鍐嶈創(chuàng)濂囨殑鐜拌薄
zhihua@ThinkPad (~/cs50/2009fall/psets/2): make test
gcc -ggdb -std=c99 -Wall -Werror -Wformat=0 test.c -lcs50 -lm -o test
zhihua@ThinkPad (~/cs50/2009fall/psets/2): ./test
Input a string:HELLO WORLD
HELLO WORLD
HELLO WORLD
zhihua@ThinkPad (~/cs50/2009fall/psets/2): ./test
Input a string:HELLO,WORLD
HELLO,WORLD
HELLO,WORLD
zhihua@ThinkPad (~/cs50/2009fall/psets/2): ./test
Input a string:HELLO, WORLD
HELLO, WORLD
HELLO, WORLDy
寰堝鎬繖涓?#8216;y'鏄庝箞鍑虹幇鐨勫憿錛?
鍙堟祴浜嗕竴鎶婏紝鍙戠幇鍙鏄緭鍏?2涓瓧絎﹂暱搴︾殑鏃跺欙紝榪欎釜‘y’灝變細(xì)鍑虹幇銆傝楂樻墜鐩稿憡

]]>