我是编程的新手,试图了解通过控制台询问信息的概念。当我执行该程序时,出现SEGV错误,但找不到我做错的事情。据我所知,当我尝试修改字符串文字时会发生这种情况,但是必须有其他东西。这是我的代码:
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#define BUFFSIZE 255
int main()
{
char *action;
char buffer[BUFFSIZE], *aux1, *aux2;
bool end = false;
while (!end)
{
size_t ct;
fgets(buffer, BUFFSIZE, stdin);
sscanf(buffer,"%s%s%s", action, aux1, aux2);
if (strcmp(action, "finish") == 0)
{
end = true;
}
else if (strcmp(action, "option2") == 0)
{
printf("%s", action);
}
else if (strcmp(action, "option3") == 0)
{
printf("%s", action);
}
}
}