CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Threaded View

  1. #1
    Join Date
    Mar 2013
    Posts
    25

    control structure outputting wrong iterations via ints.

    all,

    I have this:

    Code:
    			for (chr_min = 0; chr_min <= 24; chr_min += 3)
    			{
    				strOut = "";
    				for (ctr_row = 1; ctr_row <=3; ctr_row++)
    				{
    					switch (ctr_row)
    					{
    					case 1:
    						strOut = strOut + Line1.substr(chr_min, 3);
    						cout << ctr_row << endl;
    					case 2:
    						strOut = strOut + Line2.substr(chr_min, 3);
    						cout << ctr_row << endl;
    					case 3:
    						strOut = strOut + Line3.substr(chr_min, 3);
    						cout << ctr_row << endl;
    					}
    				}
    					cout << strOut << endl;
    			}
    it is outputting to the shell window, this:

    Code:
    1
    1
    1
    2
    2
    3
    and that pattern apparently repeats for every iteration that's specified in the outer loop. am I missing something here?

    I sure hope this is not because my CPP understanding is not up to par! thanks. any help surely appreciated.
    Last edited by ajetrumpet; March 18th, 2013 at 02:32 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured