
知道我做错了什么吗?
#include <vector>#include <string>#include <iostream>#include <iomanip>#include <fstream>#include <sstream>using namespace std;//(int argc,char* argv[]int main(){ fstream bookread("test.txt"); vector<string> words; bookread.open("test.txt"); if(bookread.is_open()){ cout << "opening textfile"; while(bookread.good()){ string input; //getline(bookread,input); bookread>>input; //string cleaneDWord=preprocess(input); //char first=cleaneDWord[0]; //if(first<=*/ //cout << "getting words"; //getWords(words,input); } } cout << "all done"; words[0];getchar();}解决方法 你永远不会在单词vector中插入任何东西,所以行字[0];是非法的,因为它访问它的第一个元素,它不存在. 总结 以上是内存溢出为你收集整理的向量下标超出范围错误,C全部内容,希望文章能够帮你解决向量下标超出范围错误,C所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)