69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
const int LENGTH = 50;
char str[] = { 0 };//用于存放字符串
printf("sizeof(str):%d\n", sizeof(str));
char *pva = (char *)malloc(LENGTH + 1);
//pva = str; //指针指向数组
printf("\nPlease enter a string up to %d characters:", LENGTH);
scanf("%s", pva);
printf("%s\n", pva);
return 0;
}