Start New Discussion within our Software Development Community

I need to make a program to do the following:
1. ask the user for the name of the input file, and open/read it.
2. For each well-formed cout statement, i must execute it. For any malfunctioned cout statement, print an error message.

the syntax of a well-formed cout statement is: cout-statement, output-list, quoted-string, regular-char, and special-char.

If anybody has an idea on how i should start this, please do. Thanks.

I need to make a program to do the following:
1. ask the user for the name of the input file, and open/read it.
2. For each well-formed cout statement, i must execute it. For any malfunctioned cout statement, print an error message.

the syntax of a well-formed cout statement is: cout-statement, output-list, quoted-string, regular-char, and special-char.

If anybody has an idea on how i should start this, please do. Thanks.

First thing to do is to make sure YOU can recognize a well-formed cout statement. Prepare some good ones and bad ones and then paste them into a program and compile and try to run it. See if you were right. If not, fix it.

Decide EXACTLY what is legal and what is not and try to figure out all the rules that go along with that. How in detail are you getting as far as legal and illegal cout statements? For example, are you responsible for being able to implement everything from iomanip?

cout << setw(8) << left  << "Hello" << setw (10) <<  right << "World";

Get a good idea of what is legal on paper before even trying to code it. Then create a boolean function that accepts a string, parses it, and decides whether the string is a valid cout statement. If so, return true. Otherwise, return false.

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