Simple Error, but couldn't find.

This is a discussion on Simple Error, but couldn't find. within the C++ Programming forums, part of the General Programming Boards category; Hi, I have a simple code. Code: #include "stdafx.h" #include <iostream> using namespace std; #include <cstdlib> #include <ctime> typedef int ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Location
    Ankara, Turkey
    Posts
    18

    Simple Error, but couldn't find.

    Hi, I have a simple code.

    Code:
    #include "stdafx.h"
    #include <iostream>
    using namespace std;
    
    #include <cstdlib>
    #include <ctime>
    typedef int DataType;
    
    void selectionSort( DataType theArray[], int n );
    int indexOfLargest( const DataType theArray[], int size );
    void mySwap( DataType& x, DataType& y );
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	return 0;
    }
    
    void selectionSort( DataType theArray[], int n )
    {
       for (int last = n-1; last >= 1; --last)
       {  
    	  int largest = indexOfLargest(theArray, last+1);
    
    	  // Descending order.
          mySwap(theArray[largest], theArray[n - last]);
    
       }  // end for
    }  // end selectionSort
    
    int indexOfLargest( const DataType theArray[], int size )
    {
       int indexSoFar = 0;  // index of largest item 
                            // found so far
       for (int currentIndex = 1; currentIndex < size; ++currentIndex)
       {  // Invariant: theArray[indexSoFar] >= 
          //            theArray[0..currentIndex-1]
         if (theArray[currentIndex] > theArray[indexSoFar])
             indexSoFar = currentIndex;
       }  // end for
    
       return indexSoFar;  // index of largest item
    }  // end indexOfLargest
    
    void mySwap( DataType& x, DataType& y )
    {
       DataType temp = x;
       x = y;
       y = temp;
    }  // end swap
    Compiler gives the error
    d:\CD\myProjects\hw2Q4\hw2Q4.cpp(14): fatal error C1075: end of file found before the left brace '{' at 'd:\CD\myProjects\hw2Q4\hw2Q4.cpp(13)' was matched

    There is no unmatched curly, any help would be appricated.
    Sarp Arda Coskun
    www.bilgiciftligi.com

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    try puting something other than return 0 in _tmain. othjer than that i don't know
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  3. #3
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    I can compile it with no errors!
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 18
    Last Post: 05-26-2008, 11:23 PM
  2. Replies: 5
    Last Post: 04-16-2004, 01:29 AM
  3. find and replace command?
    By p0wp0wpanda in forum C Programming
    Replies: 2
    Last Post: 05-24-2002, 11:42 PM
  4. Variable question I can't find answer to
    By joelmon in forum C++ Programming
    Replies: 3
    Last Post: 02-12-2002, 03:11 AM
  5. Linker errors with simple static library
    By Dang in forum Windows Programming
    Replies: 5
    Last Post: 09-08-2001, 09:38 AM

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