【发布时间】:2018-02-23 02:03:57
【问题描述】:
#include <stdio.h>
#include <stdlib.h>
static void get_string(char *ac)
{
ac = (char *)malloc (1 * sizeof (char));
printf("Enter the string to count vowels and consonants in a string using pointers: ");
scanf("%s", ac);
}
main(int argc, char *argv[])
{
char *ac = NULL;
get_string(ac);
printf("The Entered string is:%s", ac);
for(;;);
}
无法从函数堆栈中获取输入的字符串。返回 null。谁能帮我调试一下?
【问题讨论】:
-
如果你只为 1 个字符分配空间,你希望得到什么字符串?
标签: c pass-by-value function-call