I need to insert a control-break in an array after every third line. Can someone help with this? Thanks so much. -R

Can someone help with this?

Sure! But I need you to help me help you.

What problems are you having doing this? Have you tried to design something that would work for this?

Thanks for responding; and yes, this is part of a design of a final project in an Intro C++ class. We have been asked to insert a control-break in an array listing names of students [total 7 in the array] and their grades [mid-term, final, project.] The control-break should appear after every third student and their grades listed. I have everything else designed and running [to my surprise!] but cannot figure out how to insert the extra line in the array[s]. Does this help you help me? Or do you wish for me to include the code. Please advise [and again, thanks!] -R

Well, what have you tried to use for a control break yet? Just show us the code from that section.

Well, what have you tried to use for a control break yet?Just show us the code from that section.

Hi... I believe I got it to work somewhat, except that it delivers the first line, a line feed, then three lines of text, line feed, next three lines, etc.

Here is code:

system ("cls");
outfile << setiosflags(ios::showpoint|ios::fixed)<< setprecision(2);
outfile << setw(50) << "Course Grade Report" << endl;
outfile << setw(50) << "===================" << endl << endl;
outfile << setw(5) << "Professor:  " << prof << endl;
outfile << setw(5) << "Semester:   " << sem << endl;
outfile << setw(5) << "Course:     " << course << endl;
outfile << setw(5) << "Credits:    " << credit << endl << endl;
outfile << setw(5) << "Student" << setw(15) << "Midterm" << setw(15) << "Final" 
        << setw(15) << "Project" << setw(15) << "Average" << setw(12) << "Grade" 
        << endl; 
outfile << setw(5) << "=======" << setw(15) << "=======" << setw(15) << "=====" 
        << setw(15) << "=======" << setw(15) << "=======" << setw(12) << "=====" 
        << endl;   
for(indx = 0; indx < num_std; ++indx)
{
 outfile << setw(5)  << name[indx] 
         << setw(15) << mid_term[indx] 
         << setw(15) << final[indx] 
         << setw(15) << project[indx] 
         << setw(15) << avg[indx]; 
 if (avg[indx] >= 90)
      {outfile << setw(14) << "A" << endl;}
 else if (avg[indx] >= 80)
      {outfile << setw(14) << "B" << endl;}
 else if (avg[indx] >= 70)
      {outfile << setw(14) << "C" << endl;}
 else if (avg[indx] >= 60)
      {outfile << setw(14) << "D" << endl;}
 else 
      {outfile << setw(14) << "F" << endl;} 
 
 if(indx % 3 == 0)
    outfile << endl;      
}

<< moderator edit: added [code][/code] tags >>


Hope this makes some sense; I cut and paste from the middle of the program. Thanks, again. -R

What do you mean by "control-break"?

Here it states,

Pause/Break- CTRL-BREAK traditionally stopped programs.

I don't imagine you want to quit the program, so I could guess that you want to insert a pause. If so, just take and discard user input at the point you want, like this.

This article has been dead for over six months. Start a new discussion instead.