LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How do i debug my c++ program please? (https://www.linuxquestions.org/questions/programming-9/how-do-i-debug-my-c-program-please-362561/)

twirl 09-12-2005 02:06 AM

How do i debug my c++ program please?
 
Hi,

i am trying to debug my program from the run game part of it as it dont seem to be running the game server. When i try and compile my program with system_errors i get these compile errors, please help and thankyou to all who have, without this forum i doubt i would of even got this far! :-

++ gameserverpro14.cpp
gameserverpro14.cpp: In function `int main()':
gameserverpro14.cpp:82: error: `" > system_errors"' cannot be used as a
function
gameserverpro14.cpp:82: error: syntax error before `)' token
gameserverpro14.cpp:83: error: syntax error before `,' token


Code:


#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
int main()
{
 int i=0;
 char s1[30],s2[40],s3[90],s4[100];      // set char size for input
 ofstream outfile("games.db", ios::app);
 string whole,p1,p2;
 ifstream infile;
 
// Start Main Menu
 
 char choice='\0';//NULL;
 bool finished=false;
 while (finished != true)
 {
  cout<<"MAIN MENU\n";
  cout<<"1. AddGame\n";
  cout<<"2. Options\n";
  cout<<"3. RunGame\n";
  cout<<"4. Exit\n";
  cout << "Please enter your choice: ";
  cin>>choice;
  cout<<"\n\n";
 
  // Start function for submenu
  switch(choice)
  {
  case '1': cout << "1. Add Game To DB\n";
            cout << "2. Go back\n";
            cout << "Please enter your choice: ";
            cin>>choice;
 
            if(choice == '1')
            {
              cout << "\n\nPlease enter full-path to game start file: ";
             
                          cin.get();
                          cin.getline (s1, 30); // Input goes in$
                          outfile << s1 << ":";  // add : after eachpath
                          cout << "\n\nPlease enter game name: ";
                          cin.getline (s2, 40);
                          outfile << s2 << "\n";
                if (outfile.is_open())
                          {
                          outfile.close();
                          }
                        }
            /* Just break if choice != 1 */
            break;
  case '2': cout<<"Options\n";
            cout<<"1. Edit Game Config\n";
            cout<<"2. Go back\n";
            cout << "Please enter your choice: ";
            cin>>choice;
           
            if(choice=='1')
            {
              cout << "Please enter full path to config file to edit: ";  // ask user for path to config file
              cin.get();
              cin.getline (s3, 256);        // input goes in
              string cmd = string("pico ") + string(s2);
              system(cmd.data());      // open up pico to edit config
            }
                       
                        // Here we would check 'choice' and probably move to another functi$
            cout<<"\n\n";
            break;
  case '3': cout<<"Run Game";
            i=0;
            infile.open ("games.db", ios::in); 
            while(getline(infile,whole)){
                i++;
                p2=whole.substr(whole.find(':')+1,whole.length()); 
                cout << i << ". " << p2 << endl;
            }                 
            cout << "Please select game you wish to run: ";
            cin.get();
            system(s3+" > system_errors"()));
            cin.getline(s3,, 100); //input goes in
            // Here we would check 'choice' and probably move to another functi$
            cout<<"\n\n";
            break;

  case '4': //Finished so set finished 'true' to break out of loop
            finished=true;
            cout<<"Exiting....\n";
            break;
  default:  //If choice !=1/2/3 then do what it says here
            break;
 
            //  end functions
  }
  choice='\0'; //NULL
 }
 return 1;
}


cyb0rg777 09-12-2005 02:34 AM

system(s3+" > system_errors"()));

looks like you have one too many closing brackets here
just had to count down 82 lines


All times are GMT -5. The time now is 10:25 AM.