Hello and welcome to our community! Is this your first visit?
Register
Results 1 to 2 of 2

Thread: Problem

  1. #1
    .va
    .va is offline
    Dedicated Member
    Join Date
    Aug 2008
    Location
    Wherever I am right now.
    Posts
    947

    Problem

    I'm new to C++, so don't fucking flame me >:C
    I whipped this up a few moments ago, and it will not run correctly.
    Dev-C++ doesn't detect any errors/problems, but when the program runs it instantly closes. Can you help me?
    Code:
    #include <iostream>
    #include <string>
    #include <time.h>
    using namespace std;
    int level = 1;
    int money = 500;
    int soldier = 1;
    
    string name;
    string option;
    
    void start();
    void middle();
    
    void start() {
        cout << "Hello there. What is your name?" << endl;
        cin >> name;
        system("pause");
        system("cls");
        void midddle();
    }
    int main() {
        void start();
    }
    void middle() {
         int option;
         cout << "Press 1 to buy a soldier." << endl;
         cout << "Press 2 to sell a soldier." << endl;
         cout << "Press 3 to go to war!" << endl;
         cin >> option;
         
         
    switch ( option ) {
         case 1: 
              soldier = soldier + 1;
              money = money - 20;
              system("cls");
              void begin();
              break;
         case 2:
              soldier = soldier - 1;
              money = money + 20;
              system("cls");
              void begin();
         case 3:
              soldier - soldier - 5;
              money = money + 20;
              system("cls");
              void begin();
              }
              }
    [center:37qg4wyd][img]http://**********.com/img/1251903906.png[/img]
    the noob flamer[/center:37qg4wyd]

  2. #2
    .va
    .va is offline
    Dedicated Member
    Join Date
    Aug 2008
    Location
    Wherever I am right now.
    Posts
    947

    Re: Problem

    Aha. I got it.
    Thanks, somebody can lock this, I guess.
    [center:37qg4wyd][img]http://**********.com/img/1251903906.png[/img]
    the noob flamer[/center:37qg4wyd]


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •