does anyone know why i'm getting these errors?

This is a discussion on does anyone know why i'm getting these errors? within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> #include <fstream> #include <cassert> using namespace std; void ReadAndSum(ifstream& dataFile, int& numberOfValues, float& average); // Reads, counts, ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    13

    does anyone know why i'm getting these errors?

    Code:
    #include <iostream>
    #include <fstream>
    #include <cassert>
    using namespace std;
    
    void  ReadAndSum(ifstream& dataFile, int& numberOfValues, float& average);
    // Reads, counts, and averages the integers stored in a file
    int main ()
    {
        ifstream  dataFile;
        int  numberOfValues;
        float  average;
    
        cout.setf(ios::fixed, ios::floatfield);
        cout.setf(ios::showpoint);
    
        dataFile.open("Shell4.dat");
    
    	assert(dataFile.is_open());	//check to make sure file opened
    
    	if (dataFile.fail())
    	{
    		cout<<"Input file opening failed.\n";
    		exit(1);
    	}
    	
    	//dataFile >> num1 >> num2;
    		
    		
    
    	ReadAndSum(dataFile, numberOfValues, average)
    
        cout  << "The average of "  << numberOfValues
              << " values is "  << average  << endl;
    
    	dataFile.close();
    
        return 0;
    }
    //***************************************
    
    void ReadAndSum(ifstream& dataFile, int& numberOfValues, float& average);
    
    {
    	double next;
    	while (dataFile>>next)
    	{
    		cout<<next<<endl;
    	}
    
    }
    these are the error message that i'm getting:

    error C2146: syntax error : missing ';' before identifier 'cout'
    error C2447: missing function header (old-style formal list?)

    what am i doing wrong? any help with this is greatly appreciated!

    thanks!

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    36
    ReadAndSum(dataFile, numberOfValues, average)

    is missing a ; as I see it

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    also, when you defined ReadAndSum, you accidentally put a semicolon

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    13
    thank you! i also needed to take the ; from the function heading.... woooppppsss........

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 02:57 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 05:51 PM

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