Thread: Newbie Problem: Stupid Compiler Error

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    16

    Red face Newbie Problem: Stupid Compiler Error

    Code:
    #include <iostream>
    #include <stdlib.h>
    
    using namespace std;
    
    char coord [3][3];
    char winner;
    
    void function DisplayBoard()
    {
    
    }
    
    int main()
    {
    	return 0;
    }
    I can't get this to compile for the life of me. I'm getting the following compiler errors with the Visual C++ compiler:
    Code:
    error C2146: syntax error : missing ';' before identifier 'DisplayBoard'
    error C2182: 'function' : illegal use of type 'void'
    fatal error C1004: unexpected end of file found

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Code:
    void DisplayBoard()
    {
    
    }
    All you need. No "function" specifier. Should make all three errors go away.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    And to call DisplayBoard() . . .

    Code:
    int main() {
        DisplayBoard();
    
        return 0;
    }
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    16
    Quote Originally Posted by Tonto
    Code:
    void DisplayBoard()
    {
    
    }
    All you need. No "function" specifier. Should make all three errors go away.
    Thank you! I've been programming in Unrealscript all day and confused myself something fierce there.

  5. #5
    Dragoon Lover wyvern's Avatar
    Join Date
    Jul 2005
    Location
    dragooncity
    Posts
    28
    btw i rather using inline functions they are much easier to understand

    code:
    Code:
    inline void DisplayBoard()
    {
          //do this
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  2. Class Include Problem (I Think)
    By gpr1me in forum C++ Programming
    Replies: 8
    Last Post: 03-21-2006, 12:47 PM
  3. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  4. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM