It is error free but it just doesnt cout for the user to continue or discontinue and it does now stop

#include <iostream.h>
#include <stdlib.h>
#include "simmons.h"
#include <fstream.h>

const int MAXCHARS = 500;
char st_line[MAXCHARS];
char ch_option;
int i_va;
int i_ve;
int i_vi;
int i_vo;
int i_vu;
int i_letters = 0;
int i_count = 1;
int x = 0;
int i_vowel = 0;
char ch_char;

void hope();
void vowels();
void letter();
void mike();

void main()
{
ifstream HopeData;
HopeData.open("getdata");
ofstream MikeData;
MikeData.open("putdata");

if(HopeData.fail())
   {
        cout << "\n\nFile not successfully opened\n\n";
   }
else
   {
        cout << "\n\nFile successfully opened\n\n";
   }

hope();
while(st_line[x] != '\0');
        HopeData >> st_line;
        cin.get();
do{
vowels();
letter();
}while(ch_option != 'y');
mike();


cout << "\n\nDo you want to continue(Y/N)? ";
        cin.get(ch_option);

        MikeData << "\nInputted String";
        MikeData << "\n\n************************************\n\n" << st_line;
        MikeData << "\n\nNumber of a's: " << i_va;
        MikeData << "\nNumber of e's: " << i_ve;
        MikeData << "\nNumber of i's: " << i_vi;
        MikeData << "\nNumber of o's: " << i_vo;
        MikeData << "\nNumber of u's: " << i_vu;
        MikeData << "\nTotal Vowels: " << i_vowel;
        MikeData << "\n\nNumber of Letters: " << i_letters;

 cout << "                   End of Program";

        HopeData.close();
        MikeData.close();
}

void vowels()
{
while((ch_char = st_line[x++]) != '\0')
switch(ch_char)
  {
        case 'a': case 'A':
          i_va++;
        break;
        case 'e': case 'E':
          i_ve++;
        break;
        case 'i': case 'I':
          i_vi++;
        break;
        case 'o': case 'O':
          i_vo++;
        break;
        case 'u': case 'U':
          i_vu++;
        break;
  }
        i_vowel = i_va + i_ve + i_vi + i_vo + i_vu;
}

void letter()
{
for(x=0;x<500;x++)
if(st_line[i_letters] == ' ' || st_line[i_letters] == '\0')
        i_count--;
while(st_line[i_letters] != '\0')
 {
  if(st_line[i_letters++] != ' ' && (st_line[i_letters++] != ' ' && st_line[i_letters++] != '\0'))
        i_count++;
        i_letters++;
  }

Recommended Answers

All 2 Replies

I'd need the complete code to get it to compile. And if you want anyone to take a really good look at code, use [CODE] tags.

But why do you have a strangely worded loop here?

while ( st_line[x] != '\0' )

that's likely the problem. There's only 1 possibility for that not to be an infinite loop in which case the loop terminates immediately.
It's also an empty loop...

Most likely the semicolon shouldn't be there and some braces were forgotten.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.