当我运行这个程序时:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<vector<char> > screen;
char ch = 'a';
unsigned col = 100, row = 100;
if(screen.size() < (unsigned)row)
screen.resize(row);
if(screen[row - 1].size() < (unsigned)col)
screen[row - 1].resize(col);
screen[9][9] = ch;
cout<< "hello";
cout.flush();
}
cout
不打印任何东西,我收到此错误:
Segmentation Fault (core dumped)
在 Linux 中。程序有什么问题吗?
如果col
和row
具有较低的数字,则没有问题。