Do while/if else statement compatible?

I'm writing a program that find the frequency of each letter in a c style string that will be read from a txt file.

I also have to display an error if the file isn't file.
I also have a switch statement that do all the menu inputs.
1) Gets the filename
2) Shows the upper case frequency of each letter
3) Shows the lower case frequency of each letter
4) ends program

The problem is that im having trouble with the error.
While in the menu it has to show the error, and then show that a file is found
If there is no file name then cases 'a' and 'b' can't be user

I've tried using a boolean when reading the file but it doesn't work
What am I doing wrong?

Thank You!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
do
 {
   // function that displays menu
   // get user input
   // reads from file
   
   
      switch( user input ){
        
         case 'a':
             // gets the file name
             break;
 
          if( true ){
             cout << "File is found << endl;
               
                 case 'b':
                      // gets display the upper freq
                      break;

                 case 'c':
                     // gets display the lower freq
                      break;
            
            }
         else
          {
            cout << "File is not found << endl;
          }
         case 'd':
             // ends the program
           return 0;
             break;
     }
 }
while( !false )
Missing ending " on lines 15 and 28
line 14, true is always true, not a boolean variable.

to check if a file exists
http://www.cplusplus.com/forum/general/23392/
Last edited on
@Michaela

1
2
3
4
5
6
7
8
9
10
 bool read( char string[] )
  {
    // open file
    // read file
   
    // return true

    // return false
  }

in the do while
1
2
bool hold;
hold = read( string );



At line 14 it should be if( hold == true ) not if( true )
I just didn;t what write out the program
Topic archived. No new replies allowed.