Thread: Strang Error...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    48

    Strang Error...

    Hey,

    I'm writing a simple program that finds the volume of a cylinder, but I keep getting a strange error message: 1>.\Volume.cpp(6) : error C2447: '{' : missing function header (old-style formal list?)

    Here's the code:

    Code:
    #include<iostream>
    
    using namespace std;
    
    int main ();
    {
    	int radius, height, volume;
    
    	cout << "Enter the radius..." << '\n' << endl;
    	cin >> radius;
    
    	cout << '\n' << "Enter the height..." << '\n' << endl;
    	cin >> height;
    
    	volume = 3.1415 * r * r * h;
    
    	cout << '\n' << "The volume is " << volume << endl;
    
    	return (0);
    }
    Hope someone can help...thanks.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Code:
    int main ();
    You only use the semicolon when making function prototypes -- so the compiler thought you were declaring a prototype of int main, and then wondered what all this stuff was in the curly braces.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    Code:
    #include<iostream>
    
    using namespace std;
    
    int main ()
    {
    	int radius, height, volume;
    
    	cout << "Enter the radius..." << endl;
    	cin >> radius;
    
    	cout <<  "Enter the height..." << endl;
    	cin >> height;
    
    	volume =(3.1415 *radius *radius *height);
    
    	cout  << "The volume is " << volume << endl;
    
    	return 0;
    }

  4. #4
    Registered User
    Join Date
    Sep 2007
    Posts
    48
    Thanks....stupid mistake

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM