无法找到细分错误发生的原因

时间:2020-08-24 09:12:50

标签: c

我是编程的新手,试图了解通过控制台询问信息的概念。当我执行该程序时,出现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);
        }  
    }
}

0 个答案:

没有答案