Solved

For loop problems

Posted on 2004-04-25
2
190 Views
Last Modified: 2013-11-20
Hi

I have a for loop performing pretty strangely

//MAX_CHANNELS = 1024

void CNewRunView::Accumulate(const double dblSpectra[], double dblAccum[])
{
      CString s;

      long l;

      for(l = MAX_CHANNELS; l > 0; l--);    //for(l = 0; l < MAX_CHANNELS; l++) also tried this for loop declaration
      {
            s.Format("\nAccum[%d] = %5.2f Spectra[%d] = %5.2f", l, dblAccum[l], l, dblSpectra[l]);
            TRACE(s);
            dblAccum[l] += dblSpectra[l];

            s.Format(" New Accum[%d] = %6.2f", l, dblAccum[l]);

            TRACE(s);
      }
}

When I debug the application if l = MAX_CHANNELS then l = 0 first time in the loop and it exits after one itteration.

if l = 0 then l = MAX_CHANNELS first time in the loop and then we exit.

Seriously confused on this one


Can anyone explain whats going on??


Thanks in advance
LittlePerson
0
Comment
Question by:LittlePerson
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 50 total points
ID: 10911691
for(l = MAX_CHANNELS; l > 0; l--);

Remove ; in the end
0
 

Author Comment

by:LittlePerson
ID: 10911729
Thanks

I really need to take a break!

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 69
Installing Microsoft R server on REDHAT or SUSE Linux 4 131
notReplace  challenge 53 116
Window placement 17 75
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now