|
|
#2
rjsp2019-11-23 20:59
|
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
char *p1;
char *p2;
p1 = (char *)malloc(sizeof(char));
p2 = (char *)malloc(sizeof(char[10]));
fgets(p1,11,stdin);
for (; *p1 != '\n'; p1++,p2++)
{
p2 = p1;
}
printf("p1:%s\np2:%s\n", p1,p2);
}
我想请问一下能用指针变量p2输出字符串吗,还是只能使用数组输出
程序代码: