Enter-tainer / cxx2flow

将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart
MIT License
738 stars 61 forks source link

switch出现的一点问题 #4

Closed vaaandark closed 2 years ago

vaaandark commented 2 years ago

代码

int main(void)
{
    struct grades_list list = {NULL, NULL, 0};
    struct grades *g;
    int is_exit = 0;
    while (is_exit == 0) {
        int choice, num, i, sub_choice;
        char ID[16];
        scanf("%d", &choice);
        switch (choice) {
        case 0:
            clean_info(&list);
            is_exit = 1;
            break;
        case 1: /* 输入 */
            scanf("%d", &num);
            for (i = 0; i < num; ++i) {
                get_grades(&list);
            }
            sort_grades(&list);
            break;
        case 2: /* 输出 */
            for_each(&list, print_basic_info);
            break;
        case 3: /* 修改 */
            scanf("%s%d", ID, &sub_choice);
            g = find_grades(&list, ID);
            if (g == NULL)
                break;
            switch (sub_choice) {
            case 1:
                scanf("%d", &(g->english));
                break;
            case 2:
                scanf("%d", &(g->math));
                break;
            case 3:
                scanf("%d", &(g->physics));
                break;
            case 4:
                scanf("%d", &(g->c_lang));
                break;
            default:
                break;
            }
            count_grades(g);
            break;
        case 4: /* 统计平均 */
            for_each(&list, print_average);
            break;
        case 5: /* 输出总成绩及平均成绩 */
            for_each(&list, print_sum_and_average);
            break;
        default:
            break;
        }
    }
    return 0;
}

报错信息

% ./cxx2flow b.c -c | dot -Tpng -o a.png
Error: UnexpectedOutgoingNodes { node_index: NodeIndex(22), neighbors: [] }
Enter-tainer commented 2 years ago

fixed