23 lines
387 B
C
23 lines
387 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
void create(char **p, int n) // **p = p[0]; *p = p[0]; p = &p[0]
|
|
{
|
|
*p = (char *)malloc(n); // *p = p[0]
|
|
memset(*p, '\0', n);
|
|
if (NULL == *p)
|
|
{
|
|
perror("malloc error");
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
char *p = NULL;
|
|
create(&p, 32);
|
|
scanf("%s", p);
|
|
printf("==>%s\n", p);
|
|
free(p);
|
|
return 0;
|
|
} |