Help with GoalKeeper '03

This is a discussion on Help with GoalKeeper '03 within the C++ Programming forums, part of the General Programming Boards category; Help with code, please. the problem is with the fstream Errors: Code: c:\dev-c_~1\goalke~1.cpp: In function `int main()': c:\dev-c_~1\goalke~1.cpp:14: no matching ...

  1. #1
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942

    Help with GoalKeeper '03

    Help with code, please. the problem is with the fstream

    Errors:
    Code:
    c:\dev-c_~1\goalke~1.cpp: In function `int main()':
    c:\dev-c_~1\goalke~1.cpp:14: no matching function for call to `fstream::fstream (const char[9])'
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:83: candidates are: fstream::fstream()
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:84:                 fstream::fstream(int)
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:86:                 fstream::fstream(const char *, int, int = 436)
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:87:                 fstream::fstream(int, char *, int)
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:90:                 fstream::fstream(const fstream &)
    c:\dev-c_~1\goalke~1.cpp:15: no matching function for call to `fstream::open ()'
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:89: candidates are: void fstream::open(const char *, int, int = 436)
    c:\dev-c_~1\goalke~1.cpp:34: assignment to `char' from `const char *' lacks a cast
    c:\dev-c_~1\goalke~1.cpp:37: `toupper' undeclared (first use this function)
    c:\dev-c_~1\goalke~1.cpp:37: (Each undeclared identifier is reported only once
    c:\dev-c_~1\goalke~1.cpp:37: for each function it appears in.)
    c:\dev-c_~1\goalke~1.cpp:43: implicit declaration of function `int system(...)'
    c:\dev-c_~1\goalke~1.cpp: In function `int first()':
    c:\dev-c_~1\goalke~1.cpp:54: no matching function for call to `fstream::fstream (const char[9])'
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:83: candidates are: fstream::fstream()
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:84:                 fstream::fstream(int)
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:86:                 fstream::fstream(const char *, int, int = 436)
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:87:                 fstream::fstream(int, char *, int)
    C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:90:                 fstream::fstream(const fstream &)
    I suck, huh
    The Code:
    Code:
    #include <iostream.h>
    #include <fstream.h>
    int first();
    int main()
    {
          char goal[20];
          int show;
          int done;
          char quitting;
          bool check;
          cout <<"Neurosoft Technology presents"<< endl;
          cout <<"Goalkeeper 2003"<< endl;
          cin.get();
          fstream a_file("goal.goa");
          check = a_file.open();
          if(check = "TRUE")
          {
                     goto prog;
          }
          else
          {
                     first();
          }
          prog:
          for(show=0; show < 20; show ++)
          {
                      cout << show + 1 << ". " << goal[show] << endl;
          }
          int going = 0;
          while(going == 0)
          {
                      cout << "Which goal is done?" << endl;
                      cin >> done;
                      goal[done-1] += " --- DONE";
                      cout << "[Q] - Quit /n [S] - Stay /n" << endl;
                      cin >> quitting;
                      quitting = toupper[quitting];
                      if(quitting == 'Q')
                      {
                                  cout << "Thank you for using NeuroSoft Technology's /n Goalkeeper 2003 /n";
                                  going = 1;
                      }
          system("PAUSE");
          return 0;
          }
    }
    
    int first()
    {
         int turn = 0;
         char quit;
         char goal[20] = {0};
         int max = 0;
         fstream a_file("goal.goa");
         for(turn=0; turn=0; max++)
         {
                     cout <<"Insert Goal " << max + 1 << "." << endl;
                     cin >> goal[max];
                     cout << "That is "<< max+1 << "out of 20 goals" << endl;
                     a_file << goal[max];
                     cout << "[Q]-Quit /n [C]-Continue /n ";
                     cin >> quit;
                     quit = toupper(quit);
                     if(quit=='Q')
                     {
                                  a_file.close();
                                  turn=1;
                     }
         }
         system("PAUSE");
         return 0;
    }

  2. #2
    Registered User xlnk's Avatar
    Join Date
    Mar 2002
    Posts
    186

    Re: Help with GoalKeeper '03

    Code:
    #include <iostream.h>
    #include <fstream.h>
    #include <ctype.h>       // toupper 
    int first();
    int main()
    {
          char goal[20];
          int show;
          int done;
          char quitting;
          bool check;
          cout <<"Neurosoft Technology presents"<< endl;
          cout <<"Goalkeeper 2003"<< endl;
          cin.get();
          ifstream a_file("goal.goa");
          check = a_file.open();
          if(check = "TRUE")
          {
                     goto prog;
          }
          else
          {
                     first();
          }
          prog:
          for(show=0; show < 20; show ++)
          {
                      cout << show + 1 << ". " << goal[show] << endl;
          }
          int going = 0;
          while(going == 0)
          {
                      cout << "Which goal is done?" << endl;
                      cin >> done;
                      goal[done-1] += " --- DONE";
                      cout << "[Q] - Quit /n [S] - Stay /n" << endl;
                      cin >> quitting;
                      quitting = toupper[quitting];
                      if(quitting == 'Q')
                      {
                                  cout << "Thank you for using NeuroSoft Technology's /n Goalkeeper 2003 /n";
                                  going = 1;
                      }
          system("PAUSE");
          return 0;
          }
    }
    
    int first()
    {
         int turn = 0;
         char quit;
         char goal[20] = {0};
         int max = 0;
         ifstream a_file("goal.goa");
         for(turn=0; turn=0; max++)
         {
                     cout <<"Insert Goal " << max + 1 << "." << endl;
                     cin >> goal[max];
                     cout << "That is "<< max+1 << "out of 20 goals" << endl;
                     a_file << goal[max];
                     cout << "[Q]-Quit /n [C]-Continue /n ";
                     cin >> quit;
                     quit = toupper(quit);
                     if(quit=='Q')
                     {
                                  a_file.close();
                                  turn=1;
                     }
         }
         system("PAUSE");
         return 0;
    }
    [/B][/QUOTE]
    Last edited by xlnk; 05-07-2003 at 08:39 PM.
    the best things in life are simple.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    162
    Code:
    #include <iostream.h>
    #include <fstream.h>
    #include <stdlib.h>
    #include <string.h>
    
    int first();
    int main()
    {
          char goal[20];
          int show;
          int done;
          char quitting;
          cout <<"Neurosoft Technology presents"<< endl;
          cout <<"Goalkeeper 2003"<< endl;
          cin.get();
          ifstream a_file("goal.goa");
      
    	  if ((a_file))
          {
                     goto prog;
          }
          else
          {
                     first();
          }
    	  prog:
          for(show=0; show < 20; show ++)
          {
                      cout << show + 1 << ". " << goal[show] << endl;
          }
          int going = 0;
          while(going == 0)
          {
                      cout << "Which goal is done?" << endl;
                      cin >> done;
                      strcat (goal, " --- DONE");
                      cout << "[Q] - Quit /n [S] - Stay /n" << endl;
                      cin >> quitting;
                      quitting = toupper(quitting);
                      if(quitting == 'Q')
                      {
                                  cout << "Thank you for using NeuroSoft Technology's /n Goalkeeper 2003 /n";
                                  going = 1;
                      }
    	  }
          system("PAUSE");
          return 0;
       
    }
    
    int first()
    {
         int turn = 0;
         char quit;
         char goal[20] = {0};
         int max = 0;
         ifstream a_file("goal.goa");
         for(turn=0; turn=0; max++)
         {
                     cout <<"Insert Goal " << max + 1 << "." << endl;
                     cin >> goal[max];
                     cout << "That is "<< max+1 << "out of 20 goals" << endl;
                     a_file >> goal[max];
                     cout << "[Q]-Quit /n [C]-Continue /n ";
                     cin >> quit;
                     quit = toupper(quit);
                     if(quit=='Q')
                     {
                                  a_file.close();
                                  turn=1;
                     }
         }
         system("PAUSE");
         return 0;
    }
    goto

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    And in a totally useless way too!
    Code:
          if ((a_file))
          {
                     goto prog;
          }
          else
          {
                     first();
          }
    	  prog:
          for(show=0; show < 20; show ++)
    Code:
          if (!(a_file))
          {
                     first();
          }
          for(show=0; show < 20; show ++)
    Oh, and the ifstream constructor that takes a string automatically opens the file, there's no need to call the non-existant method open(void).
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hello World V 03 02 02
    By SRS in forum C++ Programming
    Replies: 15
    Last Post: 11-07-2007, 12:58 PM
  2. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 11:36 AM
  3. Bitunwise
    By Azmeos in forum C++ Programming
    Replies: 28
    Last Post: 07-10-2003, 12:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21