编译通过,程序却遇到问题,这样最让我纠结了!!!!
#include<stdio.h>#include<stdlib.h>
#define MAXLEN 15
int main(void)
{
int i;
char *p;
char str[MAXLEN];
if((p=(char * )malloc(MAXLEN))==NULL)
{
puts("Not able to allocate memory.");
exit(1);
}
printf("Please enter str:\n");
scanf("%s",str);
p=&str;
for(i=0;i<sizeof(str);i++)
printf("%s",*(p+i));
free(p);
return 0;
}