C++中调试的时候报错:0x00007FFE903CAFEC (ucrtbased.dll) (Project2.exe 中)处有未经处理的异常: 将一个无效参数传递给了将无效参数视为严重错误的函数。
#include<iostream>
#include<vector>
using namespace std;
vector <int>a;
int main()
{
int i, teap, j, l;
i = 0, teap = 0, j = 0, l = 0;
cout << "请输入数字(100个以内),我将完成排序" << endl;
for (i = 0; i < j; i++)
{
cin >> a[i];
}
j = sizeof(a);
cout << j;
for (i = 0; i < j; i++)
{
for (l = i + 1; l < j; l++)
{
if (a[i] < a[l])
{
teap = a[l];
a[l] = a[i];
a[i] = teap;
}
}
}
cout << "排序后是:" << endl;
for (i = 0; i < j; i++)
{
cout << a[i] << ">";
}
return 0;
}
报错:0x00007FFE903CAFEC (ucrtbased.dll) (Project2.exe 中)处有未经处理的异常: 将一个无效参数传递给了将无效参数视为严重错误的函数。
报错页面
Microsoft Visual C++ Runtime Library
Debug Assertion Failed!
Program:D:\C++\C++\Project2\x64\Debug\Project2.exe File: D:\22vs1\VC\Tools\MSVC\14.32.31326\include\vector Line:1732
Expression: vector subscript out of range
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
中止(A) 重试(R) 忽略(I)
我想要达到的结果:想要的结果是:声明一个由输入数字的多少来分配内存的数组
哪位可以帮我解决一下,谢谢!