Question: The program should first take string inputs (line by line) and get rid of the empty space before each line's first non-blank character, the program

The program should first take string inputs (line by line) and get rid of the empty space before each line's first non-blank character, the program will then iterate through the strings (keeping track of the { and } braces) and indent properly (like the last example given), outputting the correct indented strings. THE CORRECT OUTPUT INDENTATION OF INPUTTED STRINGS IS THIS PROGRAM'S PURPOSE! Please solve as soon as you can (due in a few hours!). Thank you.

The program should first take string inputs (line by line) and get

rid of the empty space before each line's first non-blank character, the

Task B. Counting blocks opened and closed by and , and adding real indentation To count open blocks, we need to count how many curly braces get opened and closed on each line, so we need to count f and ) Write a function t countchar(string line, char c)i that scans the line and returns the number of occurrences of the character c . Write a new program indent.cpp that enhances the program from the previous task. As it reads the input line by line, it should also count the number of open and closed in it, and keep track of how many blocks is currently open at the beginning of each line. In the listing below, the number of open blocks is shown on the left 0 int main)( // Hi, I'm a program! 0 int main( 1 int x -1; 1 for int i -0; i 10; i+) 2 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!