Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
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 Go to next message
liberator is currently offline  liberator
Messages: 246
Registered: May 2003
Location: Classified, Level Phi cle...
Karma: 0
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.
I hate to bring this over here, but I need some C++ help [message #95074] Sun, 13 June 2004 17:44 Go to previous messageGo to next message
z310
Messages: 2459
Registered: July 2003
Karma: 0
General (2 Stars)
=Errr... i was learning basic C++ but quit, tooo lazy Sad
I hate to bring this over here, but I need some C++ help [message #95136] Sun, 13 June 2004 19:53 Go to previous messageGo to next message
liberator is currently offline  liberator
Messages: 246
Registered: May 2003
Location: Classified, Level Phi cle...
Karma: 0
Recruit
You're not in College yet? Take from someone who is, learn what you can when you can, and the classes in college that are designed for people who have never seen the material before will be easy A's.

But, anyone please I need help. If you can't help with the problem specifically, suggest someplace where I can.


There was a time when people were impressed that I have the firepower to decimate a planet in under 10 minutes.
I hate to bring this over here, but I need some C++ help [message #95145] Sun, 13 June 2004 20:43 Go to previous messageGo to next message
MrBob is currently offline  MrBob
Messages: 474
Registered: February 2003
Location: Virginia, USA
Karma: 0
Commander

Try asking your instructor, isn't that why he's there? Smile

God is the "0wnage". Plain and Simple.

Visit http://www.theoriginalmrbob.com

"If there's one freak to be, it's a Jesus freak"

All your base are belong to us.
I hate to bring this over here, but I need some C++ help [message #95147] Sun, 13 June 2004 20:48 Go to previous messageGo to next message
liberator is currently offline  liberator
Messages: 246
Registered: May 2003
Location: Classified, Level Phi cle...
Karma: 0
Recruit
There's a problem with that.

1)It's the weekend.
2)He's an adjunct, so it's really hard to get in touch with him outside of class
3)When we show him code, he want's it complete and working Mad


There was a time when people were impressed that I have the firepower to decimate a planet in under 10 minutes.
I hate to bring this over here, but I need some C++ help [message #95154] Sun, 13 June 2004 21:07 Go to previous messageGo to next message
MrBob is currently offline  MrBob
Messages: 474
Registered: February 2003
Location: Virginia, USA
Karma: 0
Commander

I was going to ask Dad, but he isn't here. (Business trip) Then, I was going to point to Experts-Exchange, but they changed alot since I've been there, and now you have to pay. Mad

Anyway, these places might help:

http://www.code4u.com/?page=forum&action=view§ionID=3
http://forums.devx.com/forumdisplay.php?s=e0d8d6437216b7ea371fd5055a690af3&forumid=110
http://invisionfree.com/forums/CPPlearningcommunity/index.php
http://www.eng-tips.com/gthreadminder.cfm/lev2/22/lev3/70/pid/536
http://www.techimo.com/forum/index.html
http://www.cuj.com/experts/?topic=experts
http://www.devarticles.com/
http://www.codeguru.com/
http://forums.free2code.net

Hope that helps Smile


God is the "0wnage". Plain and Simple.

Visit http://www.theoriginalmrbob.com

"If there's one freak to be, it's a Jesus freak"

All your base are belong to us.
I hate to bring this over here, but I need some C++ help [message #95160] Sun, 13 June 2004 21:51 Go to previous messageGo to next message
liberator is currently offline  liberator
Messages: 246
Registered: May 2003
Location: Classified, Level Phi cle...
Karma: 0
Recruit
Thanks bunches!http://smilies.jeeptalk.org/kao/otn/pcheers1.gif

There was a time when people were impressed that I have the firepower to decimate a planet in under 10 minutes.
I hate to bring this over here, but I need some C++ help [message #95183] Mon, 14 June 2004 00:37 Go to previous messageGo to next message
Weirdo is currently offline  Weirdo
Messages: 369
Registered: March 2003
Karma: 0
Commander
I don't have much experience in C++, but I think I found something.

First you declare- char loopcon = 'y'; -

Next you do this in your case statement.

while (loopcon == 'y' || loopcon == 'Y') This one is true the first time.

after the loop you to this. cin >> loopcon;
I don't know what this means, but I guess this changes the value of loopcon, wich makes it not anymore value 'y'

So when you go back to a new case.
while (loopcon == 'y' || loopcon == 'Y'), will be false.

Make sure after the while loop, loopcon is again 'y'.

Hope this helps you.


Size doesn't matter.
http://www.n00bstories.com/stats/renegade_stats.php?player=weirdo64
I hate to bring this over here, but I need some C++ help [message #95234] Mon, 14 June 2004 10:41 Go to previous messageGo to next message
liberator is currently offline  liberator
Messages: 246
Registered: May 2003
Location: Classified, Level Phi cle...
Karma: 0
Recruit
That's exactly what was wrong. ben over at DevX helped me with it last night. I don't know why I didn't see it myself.

Edit:
Now that I've thought about some:

While I can give DevX and C++ Learning Community a big thumbs up, I have to give a big thumbs down to free2code.net. I made multiple posts about different problems trying to get help and was promptly ignored on everyone for a long time.


There was a time when people were impressed that I have the firepower to decimate a planet in under 10 minutes.
I hate to bring this over here, but I need some C++ help [message #95237] Mon, 14 June 2004 11:07 Go to previous messageGo to next message
Weirdo is currently offline  Weirdo
Messages: 369
Registered: March 2003
Karma: 0
Commander
liberator

That's exactly what was wrong. ben over at DevX helped me with it last night. I don't know why I didn't see it myself.

Edit:
Now that I've thought about some:

While I can give DevX and C++ Learning Community a big thumbs up, I have to give a big thumbs down to free2code.net. I made multiple posts about different problems trying to get help and was promptly ignored on everyone for a long time.


Good to hear. I think I will learn some C++ in the summertime. At the moment Java is my primary programming language. I know how annoying these things can be, I once searched 3 hours for what was wrong in a very big program, just to find out instead of "case 0x00" I changed it to "case 0x00a". Being a very big school project I had to go trough a lot of code.


Size doesn't matter.
http://www.n00bstories.com/stats/renegade_stats.php?player=weirdo64
I hate to bring this over here, but I need some C++ help [message #95270] Mon, 14 June 2004 13:02 Go to previous messageGo to next message
rm5248 is currently offline  rm5248
Messages: 1156
Registered: November 2003
Location: USA
Karma: 0
General (1 Star)
Or, you know, you could just see if the library has any books... Confused

I got a book on JavaScript out the other day to learn. Smile


w00t?
I hate to bring this over here, but I need some C++ help [message #95273] Mon, 14 June 2004 13:37 Go to previous messageGo to next message
Weirdo is currently offline  Weirdo
Messages: 369
Registered: March 2003
Karma: 0
Commander
That's what I mean with learning, getting a book, but to bad our local library doesn't have any books about programming so I have to buy one.

Also Java, and javascript are a bit diffrent. But if you know how to program in C++, Java isn't that hard to learn.


Size doesn't matter.
http://www.n00bstories.com/stats/renegade_stats.php?player=weirdo64
I hate to bring this over here, but I need some C++ help [message #95334] Mon, 14 June 2004 17:20 Go to previous messageGo to next message
MrBob is currently offline  MrBob
Messages: 474
Registered: February 2003
Location: Virginia, USA
Karma: 0
Commander

Maybe I should pick up that C++ book I bought 3+ years ago and actually read it. Smile

God is the "0wnage". Plain and Simple.

Visit http://www.theoriginalmrbob.com

"If there's one freak to be, it's a Jesus freak"

All your base are belong to us.
I hate to bring this over here, but I need some C++ help [message #95378] Mon, 14 June 2004 22:05 Go to previous message
liberator is currently offline  liberator
Messages: 246
Registered: May 2003
Location: Classified, Level Phi cle...
Karma: 0
Recruit
Be aware, if the book is that old, some stuff will be different. .NET is vitually a new language or so I've been told.

There was a time when people were impressed that I have the firepower to decimate a planet in under 10 minutes.
Previous Topic: Is it just me...
Next Topic: Help out with C&CR: Sole Survivor: Mirrors and Servers
Goto Forum:
  


Current Time: Tue Jan 07 08:57:10 MST 2025

Total time taken to generate the page: 0.00767 seconds