Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #10405
| From | sravanreddy001 <sravanreddy001@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Vector push_back() giving SIGSEGV error |
| Date | 2011-09-22 12:48 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <29403061.2519.1316720927293.JavaMail.geo-discussion-forums@yqaa12> (permalink) |
Hi,
I've the below piece of code. I'm collecting all the links in text_files.
This code worked fine for the first 26 files and giving this error for 27th
When I skip 27th file using continue, its giving error at 89, and also at..
121 122 131.
For all the other files also. this piece of code is being executed.
When i traced it using (eclipse) i think this is because, the memory is not being alloted to this vector.
Additional Information:
I'm using around 6-7 other vector<string> objects to store other information.
And all these will have a max of 1 MB data all of them combined. and these vectors are recreated in the loop.
Could this be because, i'm not erasing the contents of vector. I don't think this is the reason.
Any inputs will be very helpful..
while(begin != string::npos && end != string::npos){
string link = line.substr(begin+2,end-begin-2);
try{
Links.push_back(link);
}
catch(...){
printf("%d - ",Links.size());
}
File_Content.push_back("L: "+link);
//printf("%s\n", line.substr(begin+2,end-begin-2).c_str());
begin = line.find("[[",end);
end = line.find("]]",begin+2);
//begin = end+1; // can be end+2, but end+1 for safety
}
Thanks,
Sravan.
Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread
Vector push_back() giving SIGSEGV error sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-22 12:48 -0700
Re: Vector push_back() giving SIGSEGV error Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-22 15:26 -0500
Re: Vector push_back() giving SIGSEGV error sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-22 17:17 -0700
Re: Vector push_back() giving SIGSEGV error Ian Collins <ian-news@hotmail.com> - 2011-09-23 13:54 +1200
Re: Vector push_back() giving SIGSEGV error Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-23 09:24 +0000
Re: Vector push_back() giving SIGSEGV error Victor Bazarov <v.bazarov@comcast.invalid> - 2011-09-22 16:30 -0400
Re: Vector push_back() giving SIGSEGV error sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-22 17:20 -0700
Re: Vector push_back() giving SIGSEGV error Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-23 00:20 -0500
csiph-web