Click here to Skip to main content
15,921,793 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: About Clipping algorithms Pin
Anonymous1-Dec-04 21:40
Anonymous1-Dec-04 21:40 
QuestionWhat is runtime Pin
Imtiaz Murtaza1-Dec-04 16:46
Imtiaz Murtaza1-Dec-04 16:46 
AnswerRe: What is runtime Pin
Ritu Kwatra1-Dec-04 18:10
Ritu Kwatra1-Dec-04 18:10 
QuestionAll code samples here are safe? Pin
nne-vitamin1-Dec-04 16:28
nne-vitamin1-Dec-04 16:28 
AnswerRe: All code samples here are safe? Pin
Ryan Binns1-Dec-04 17:09
Ryan Binns1-Dec-04 17:09 
GeneralForce a minimum size for an ActiveX control Pin
Ian Bowler1-Dec-04 15:16
Ian Bowler1-Dec-04 15:16 
Generalmultiplicative inverse in finite field Pin
Tiza1-Dec-04 15:16
Tiza1-Dec-04 15:16 
GeneralCreateDirectory w/ permissions Pin
Anonymous1-Dec-04 12:12
Anonymous1-Dec-04 12:12 
GeneralRe: CreateDirectory w/ permissions Pin
Graham Bradshaw1-Dec-04 13:40
Graham Bradshaw1-Dec-04 13:40 
GeneralRe: CreateDirectory w/ permissions Pin
Ravi Bhavnani2-Dec-04 0:15
professionalRavi Bhavnani2-Dec-04 0:15 
GeneralSet tab order of controls in VC++ 7 Pin
Aaron Schaefer1-Dec-04 11:51
Aaron Schaefer1-Dec-04 11:51 
GeneralRe: Set tab order of controls in VC++ 7 Pin
Wes Aday1-Dec-04 13:01
professionalWes Aday1-Dec-04 13:01 
GeneralActiveX question, please help. Pin
Anonymous1-Dec-04 11:38
Anonymous1-Dec-04 11:38 
GeneralRe: ActiveX question, please help. Pin
bryce1-Dec-04 11:48
bryce1-Dec-04 11:48 
GeneralRe: ActiveX question, please help. Pin
Anonymous1-Dec-04 11:54
Anonymous1-Dec-04 11:54 
GeneralRe: ActiveX question, please help. Pin
bryce1-Dec-04 12:00
bryce1-Dec-04 12:00 
GeneralRe: ActiveX question, please help. Pin
Anonymous1-Dec-04 12:41
Anonymous1-Dec-04 12:41 
GeneralRe: ActiveX question, please help. Pin
Anonymous1-Dec-04 13:04
Anonymous1-Dec-04 13:04 
GeneralRe: ActiveX question, please help. Pin
Wes Aday1-Dec-04 13:05
professionalWes Aday1-Dec-04 13:05 
GeneralOutput from screen to printer Pin
BRIMID1-Dec-04 8:29
BRIMID1-Dec-04 8:29 
GeneralRe: Output from screen to printer Pin
David Crow1-Dec-04 9:52
David Crow1-Dec-04 9:52 
GeneralRe: Output from screen to printer Pin
Mike Danberg1-Dec-04 11:40
Mike Danberg1-Dec-04 11:40 
GeneralRe: Output from screen to printer Pin
Mike Danberg1-Dec-04 11:57
Mike Danberg1-Dec-04 11:57 
GeneralRe: Output from screen to printer Pin
PJ Arends1-Dec-04 12:04
professionalPJ Arends1-Dec-04 12:04 
GeneralCArray RemoveAt Questions Pin
ayajiang1-Dec-04 7:45
ayajiang1-Dec-04 7:45 
Hi all,

I got a really weird problem when I tried to use RemoveAt() function to remove elements from a CArray.

I have two parallel arrays called carrURL (a CString array) and carrHit (an int array). What I want to do is:

If an element in carrURL has duplicated elements, then add its corresponding values from carrHit together and then remove these duplicated elements from carrURL. If an element is unique in the array, just keep it and go next.

For example: suppose carrURL[0], carrURL[4], carrURL [100] are the same string, add the values of carrHit[4], carrHit[100] to carrURL[0] and remove carrURL[4] and carrURL[100] (also remove carrHit[4] and carrHit[100]).

The code is below:

for (int nIndex = 0; nIndex < carrURL.GetSize(); nIndex++){
for (int ncItem = nIndex + 1; ncItem < carrURL.GetSize(); ncItem++){
if (carrURL[ncItem].Compare(carrURL[nIndex]) == 0){
carrHit[nIndex] += carrHit[ncItem];
carrHit.RemoveAt(ncItem);
carrURL.RemoveAt(ncItem);
}
}
carrHit.FreeExtra(); // free extra memory
carrURL.FreeExtra(); // free extra memory
}

However, the result is not what I supposed. It shows something like that:

carrURL carrHit
a 500 -- good
b 333 -- good
c 450 -- weird!
c 61 -- weird!
d 11 -- good
e 10 -- good
c 1 -- weird!

I can't understand why there are still some duplicated values which can not be found out after running a proper loop.

Any suggestions?

Thanks a lot!

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.