Switching from Turbo C++ to gcc/gpp: Some common problems

IARCS home > OLYMPIAD > Current
  • Do not use
    #include <conio.h>
    You will not need any functions from this header (e.g., clrscr(), getch()).

    • Note: The Dev-C++ and Code::Blocks compilers are based on gcc, but both of them allow some non-gcc header files, notably conio.h. Please rememmber not to use conio.h, otherwise your programs will not compile under gcc on the evaluation server.

  • For C++ header files such as iostream.h, leave out the suffix .h when including the file. That is, use
    #include <iostream>
    rather than
    #include <iostream.h>
    Note: The does not apply to C header files such as stdio.h. For C header files, include the suffix .h, as usual. For example:
    #include <stdio.h>
  • After the header files, add the line
    using namespace std;
    to ensure that C++ finds the functions cin and cout.
     
  • Define main as int main() rather than void main().
     
  • To summarize, here is how a typical C++ program using gcc/gpp would look:
    #include <iostream>
    using namespace std;
    
    int main(){
        cout << "Hello world\n";
    }
    
  • It is highly recommended that you try submitting solutions to some of the problems on the IARCS Problems Archive to be sure that you understand what features of gcc will be supported when we evaluate your code.

Copyright (c) IARCS 2003-2014;   Last Updated: 28 Dec 2012