'How do we solve to std_vector>::_M_realloc_insert() crash?

first:std_vector.h 948行: push_back函数插入崩溃

second:new_allocator.h 111行:std_vector>::_M_realloc_insert(__gnu_cxx::normal_iterator>>,float const&)

result:std_vector>::_M_realloc_insert() crash

please all friends give some advinces



Solution 1:[1]

You want to use a while loop. The loop will continuously run the code inside while the expression Tomatoes != 1 && Tomatoes != 0 evaluates to true.

#include <stdio.h>

int main () {
    int Tomatoes = -1;

    printf(" what would you like as your Toppings?\n");
    printf(" Choose YES(1)  or  NO(0) to select your toppings...\n");

    while (Tomatoes != 1 && Tomatoes != 0) {
        printf(" Tomatoes ? ");
        scanf(" %d", &Tomatoes);
        if (Tomatoes != 1 && Tomatoes != 0) printf(" Invalid choice \n");
    }

    return 0;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 codyne