| Home » General Discussions » General Discussion » I hate to bring this over here, but I need some C++ help 
	| 
		
			| I hate to bring this over here, but I need some C++ help [message #95062] | Sun, 13 June 2004 15:51  |  
			| 
				
				|  |  liberator Messages: 246
 Registered: May 2003
 Location: Classified, Level Phi cle...
 
	Karma: 
 | Recruit |  |  |  
	| My instructor has us writing a thing to write skeleton programs. It takes input from the user in the as strings(library/header names, class names, ect) and outputs them along with certain basic code to a separate source file in the same directory. It looks like this 
 //John Mynard
//CS-318
//Purpose:  This program interacts with the programmer
//         to generate the skeleton of a second program
//         that the programmer with complete and debug.
//Date Created: Monday, June 7, 2004
//Date Last Edited: Monday, June 11, 2004
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main()
{
//initialization of output file
   ofstream out_stream;
     out_stream.open ("sourcegen.cpp");
int menuchoice;
string name;
string type;
char loopcon = 'y';
//interactivity
   while (menuchoice !=0)
   {
      cout << "Welcome to Code Generator" << endl;
      cout << "Please enter a selection" << endl << endl;
      cout << "Select 1 to add C++ Library/Header files" << endl;
      cout << "Select 2 to add C++ Class declarations" << endl;
      cout << "Select 3 to add C++ Structure declarations" << endl;
      cout << "Select 4 to add constant variable declarations" << endl;
      cout << "Select 5 to add variable declarations" << endl;
      cout << "Select 0 to exit Code Generator" << endl;
      cin >> menuchoice;
      switch (menuchoice)
      {
      case  1:
         {
            while (loopcon == 'y' || loopcon == 'Y')
            {
            cout << "Enter the Library/Header name" << endl;
            cin >> name;
            out_stream << "#include <" << name << ">" << endl;
            cout << "Are there any other Library/Header file you wish to include?" << endl;
            cin >> loopcon;
            }
            out_stream << "using namespace std;" << endl << endl;
            break;
         }
      case  2:
         {
            while (loopcon == 'y' || loopcon == 'Y')
            {
            cout << "Enter the Class name" << endl;
            cin >> name;
            out_stream << "struct " << name << endl;
            cout << "Are there any other classes you wish to include?" << endl;
            cin >> loopcon;
            }
            out_stream << endl << endl;
            break;
         }
         
      case  3:
         {
            while (loopcon == 'y' || loopcon == 'Y')
            {
            cout << "Enter the Structure name" << endl;
            cin >> name;
            out_stream << "class " << name << endl;
            out_stream << "{" << endl << "public:" << endl << "private:" << endl << endl;
            cout << "Are there any other structures you wish to include?" << endl;
            cin >> loopcon;
            }
            out_stream << endl << endl;
            break;
         }
         
      case  4:
         {
   //         Choice.ConstantQuery();
            break;
         }
         
      case  5:
         {
   //         Choice.VariableQuery();
            break;
         }
      }
   }
}
 Excuse the quotes at the bottom, I had tried putting everything in a class but it wouldn't let me open an output file in the class for the class to use.
 
 Anyway, it compiles and runs fine on the first selection, but when it get's back to the menu and you make a second selection it starts cycling through the menu over and over and won't go down to the switch statement.
 
 I don't understand why it's doing this unless there is something wrong with my switch statement/menu system, in which case I'll primitize even more and switch it to $$$$ing "if" statements.
 
 Any help would be appreciaed. Thanks in advance!
 
 There was a time when people were impressed that I have the firepower to decimate a planet in under 10 minutes.
 |  
	|  |  | 
	Goto Forum:
	|  |  | I hate to bring this over here, but I need some C++ help |  
	|  |  | I hate to bring this over here, but I need some C++ help By: z310  on Sun, 13 June 2004 17:44 |  
	|  |  | I hate to bring this over here, but I need some C++ help |  
	|  |  | I hate to bring this over here, but I need some C++ help By: MrBob  on Sun, 13 June 2004 20:43 |  
	|  |  | I hate to bring this over here, but I need some C++ help |  
	|  |  | I hate to bring this over here, but I need some C++ help By: MrBob  on Sun, 13 June 2004 21:07 |  
	|  |  | I hate to bring this over here, but I need some C++ help |  
	|  |  | I hate to bring this over here, but I need some C++ help By: Weirdo  on Mon, 14 June 2004 00:37 |  
	|  |  | I hate to bring this over here, but I need some C++ help |  
	|  |  | I hate to bring this over here, but I need some C++ help By: Weirdo  on Mon, 14 June 2004 11:07 |  
	|  |  | I hate to bring this over here, but I need some C++ help By: rm5248  on Mon, 14 June 2004 13:02 |  
	|  |  | I hate to bring this over here, but I need some C++ help By: Weirdo  on Mon, 14 June 2004 13:37 |  
	|  |  | I hate to bring this over here, but I need some C++ help By: MrBob  on Mon, 14 June 2004 17:20 |  
	|  |  | I hate to bring this over here, but I need some C++ help |  
 
 Current Time: Thu Oct 30 19:47:54 MST 2025 
 Total time taken to generate the page: 0.00820 seconds |