// #include "stdafx.h" #include "stdlib.h" int _tmain(int argc, _TCHAR* argv[]) { int *q=(int*)malloc(sizeof(int)*5); //malloc函數動態分配5個整型數的地址空間。 printf("Please input:"); for(int i=0;i<5;i++) scanf("%d",q+i); for(int i=0;i<5;i++) printf("%d ",*(q+i)); system("pause"); return 0; }
#include "stdafx.h" #include "stdlib.h" int _tmain(int argc, _TCHAR* argv[]) { char *str=(char*)malloc(100); //malloc函數動態分配地址空間。 printf("Please input:"); scanf("%s",str); printf("%s",str); //注意 不用加 * system("pause"); return 0; }