Failure while assigning values to a variable: Aborted

M

Moritz Beller

Hi!
string* pWordlist;
pWordlist = new string[elements];

for(int i=0; i < elements; i++)
   pWordlist = "";

...

pWortliste[tmpelement][previous] = buf;


aborts ("Aborted") at

tmpelement = 13;
previous = 0;

where until that point everything went fine (last values for both
variables were 12). tmpelement is still fairly lower than elements is.

"strace ./a.out" says

write(1, "tmpelement: 13 previous"...,
38tmpelement: 13 vorgaenger: 0) = 38
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
getpid() = 32184
kill(32184, SIGABRT) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++

What the hell is wrong with this?

best regards
Moritz Beller
 
M

Moritz Beller

string* pWordlist;
pWordlist = new string[elements];

for(int i=0; i < elements; i++)
   pWordlist = "";

...

pWortliste[tmpelement][previous] = buf;


FYI: Concatenating strings with pWordlist[tmpelement] += buf;

best regards
Moritz Beller
 
J

John Harrison

Hi!
string* pWordlist;
pWordlist = new string[elements];

for(int i=0; i < elements; i++)
pWordlist = "";

....

pWortliste[tmpelement][previous] = buf;


aborts ("Aborted") at

tmpelement = 13;
previous = 0;

where until that point everything went fine (last values for both
variables were 12). tmpelement is still fairly lower than elements is.


What the hell is wrong with this?

Several things could be wrong with it. pWortliste[tmpelement] could be a
zero length string, it certainly started as a zero length string. buf could
be an invalid pointer, or buf could be an array but smaller than i.

All of these are possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top