【发布时间】:2013-09-12 09:31:17
【问题描述】:
当我运行这个程序时:
#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 的数字较小,则没有问题。
【问题讨论】:
-
零索引。一个 100x100 的向量有 100 个元素,从 0 到 99。
标签: c++ linux vector console-application