Em muốn chèn 1 số vào mảng , dưới là code của em:
#include <iostream>
#include <cstdint>
int main()
}
int16_t insert_value, insert_position, n_max(7);
int16_t array_4[] = { 1, 2, 3, 4, 5, 6, 7 };
std::cout << "the value you want to insert: "; std::cin >> insert_value;
std::cout << "position that you want to insert: "; std::cin >> insert_position;
n_max++;
for (int16_t number(0); number <= 8; number++)
{
if(number == insert_position)
{
while (n_max >= insert_position + 1)
{
array_4[n_max] = array_4[n_max - 1];
n_max--;
}
array_4[insert_position] = insert_value;
}
}
for (int16_t number(0); number <= 8; number++)
{
std::cout << array_4[number] << " " << std::endl;
}
system("pause");
return 0;
}
xong nó lại hiện ra lỗi này:
Run-Time Check Failure #2 - Stack around the variable ‘array_4’ was corrupted.
Em ko hiểu lắm mong được giúp đỡ