LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-12-2005, 02:06 AM   #1
twirl
Member
 
Registered: Aug 2005
Posts: 168

Rep: Reputation: 15
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;
}
 
Old 09-12-2005, 02:34 AM   #2
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Rep: Reputation: 15
system(s3+" > system_errors"()));

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

Last edited by cyb0rg777; 09-12-2005 at 02:36 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to debug GTK+ program asahlot Programming 4 10-19-2005 04:23 AM
how can I debug the interactinve program with GDB bigapple Programming 1 08-03-2005 09:55 PM
Can someone debug this 4 line program? (C) Squall Programming 3 03-22-2004 10:48 PM
How do I debug a C program mfeoli Programming 3 03-12-2004 01:58 PM
c++ newbie - help debug simple program please mymojo Programming 4 11-27-2003 04:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration