Click here to Skip to main content
15,894,740 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionsizeof not working Pin
mike74111-Jan-24 1:31
mike74111-Jan-24 1:31 
AnswerRe: sizeof not working Pin
Richard MacCutchan1-Jan-24 2:28
mveRichard MacCutchan1-Jan-24 2:28 
AnswerRe: sizeof not working Pin
jeron12-Jan-24 5:38
jeron12-Jan-24 5:38 
GeneralRe: sizeof not working Pin
jschell2-Jan-24 6:34
jschell2-Jan-24 6:34 
GeneralRe: sizeof not working Pin
jeron12-Jan-24 7:11
jeron12-Jan-24 7:11 
QuestionPlease - explain the C++ code / function Pin
Salvatore Terress28-Dec-23 6:09
Salvatore Terress28-Dec-23 6:09 
AnswerRe: Please - explain the C++ code / function Pin
Graham Breach28-Dec-23 8:59
Graham Breach28-Dec-23 8:59 
GeneralRe: Please - explain the C++ code / function Pin
Salvatore Terress29-Dec-23 2:56
Salvatore Terress29-Dec-23 2:56 
GeneralRe: Please - explain the C++ code / function Pin
Graham Breach29-Dec-23 3:50
Graham Breach29-Dec-23 3:50 
GeneralMessage Closed Pin
31-Dec-23 8:49
Salvatore Terress31-Dec-23 8:49 
GeneralRe: How to pass xterm -e option as variable? Pin
k505431-Dec-23 17:35
mvek505431-Dec-23 17:35 
GeneralRe: How to pass xterm -e option as variable? Pin
jschell1-Jan-24 2:07
jschell1-Jan-24 2:07 
GeneralMessage Closed Pin
1-Jan-24 9:51
Salvatore Terress1-Jan-24 9:51 
GeneralRe: How to pass xterm -e option as variable? Pin
k50541-Jan-24 13:09
mvek50541-Jan-24 13:09 
GeneralRe: How to pass xterm -e option as variable? Pin
jschell2-Jan-24 6:14
jschell2-Jan-24 6:14 
GeneralRe: How to pass xterm -e option as variable? Pin
Richard MacCutchan1-Jan-24 22:13
mveRichard MacCutchan1-Jan-24 22:13 
GeneralRe: How to pass xterm -e option as variable? Pin
jschell2-Jan-24 6:26
jschell2-Jan-24 6:26 
AnswerRe: Please - explain the C++ code / function Pin
Richard MacCutchan28-Dec-23 22:02
mveRichard MacCutchan28-Dec-23 22:02 
AnswerRe: Please - explain the C++ code / function Pin
jschell29-Dec-23 5:16
jschell29-Dec-23 5:16 
AnswerRe: Please - explain the C++ code / function Pin
jeron112-Jan-24 5:04
jeron112-Jan-24 5:04 
GeneralRe: Please - explain the C++ code / function Pin
Richard MacCutchan12-Jan-24 5:39
mveRichard MacCutchan12-Jan-24 5:39 
GeneralRe: Please - explain the C++ code / function Pin
jeron112-Jan-24 6:16
jeron112-Jan-24 6:16 
Questiondeleting from a vector Pin
mike741124-Dec-23 20:37
mike741124-Dec-23 20:37 
I wrote some C++ code to create a vector and then try to delete all occurrences of 3 in it:

C++
vector<int> myVector = { 1, 2, 3, 4, 5, 3, 2 };

	for (auto i = myVector.begin(); i != myVector.end(); i++)
	{
		if (*i == 3) myVector.erase(i);
	}



However, it doesn't work right. It gives this error:

Expression: can't increment invalidated vector iterator

I guess you can't increment the iterator after you erase the element.

Anyone know how to fix this?

Thanks.
AnswerRe: deleting from a vector Pin
Richard MacCutchan24-Dec-23 21:39
mveRichard MacCutchan24-Dec-23 21:39 
AnswerRe: deleting from a vector Pin
Mircea Neacsu25-Dec-23 2:19
Mircea Neacsu25-Dec-23 2:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.