another C++ compiler situation
Results 1 to 7 of 7

Thread: another C++ compiler situation

  1. #1
    Junior Member
    Join Date
    Jun 2003
    Posts
    13

    another C++ compiler situation

    I just got DEv- C++ compiler from a cd contained in a book I just bought. I can't get it to compile anything!! I write the program:

    #include <iostream.h>

    int main()
    {
    cout<<"Hello world";
    }
    return 0;

    Then I compile(which by the way, do I have to save in a certain location?) and i click on the icon which is just for the source code, not the exe file. Then if i click run, it says the source is not compiled. Anyone have suggestions?
    -0ri0n
    With what weapons World War Three will be fought, I do not know, but World War Four will be fought with sticks and stones.
    -Albert Einstein

  2. #2
    Banned
    Join Date
    Mar 2002
    Posts
    594
    Add a "cin >> " statement, the window closes at the end of every program, you need something to keep it open and the "cin >>" statement should do it.

    The "return" statement should also be in the "int main()", additionally, are you hitting run after it says that the source has been compiled?

  3. #3
    If you do not specify a location to which the compiled code must be saved it get saved into the default location.
    With borland it is somewhere deep inside the 'program files' but I don't know for your compiler.
    You must have givin it a name so do a search for the program.
    Like 'dir /s hello.exe'. (use the name you gave the proggie).

  4. #4
    Banned
    Join Date
    Mar 2002
    Posts
    594
    noODle, no I have Dev and you don't need to specify anything, everything is done for you... it has a GUI... you ought to try it.

  5. #5
    Member
    Join Date
    Jun 2003
    Posts
    86
    The same thing happened to me... i think the one in the book is defective... i just downloaded another one from www.bloodshed.net/ but if you really want to keep that one all you have to do is modify the sample apps that come with the cd.
    You laugh because im different, i laugh because your all the same.

  6. #6
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    when you return a value, you must be inside a function?
    when you type "return 0;" that is the value you are returning for "int main()"

    Code:
    #include <iostream.h>
    
    int main()
    {
    cout<<"Hello world";
    return 0; 
    }
    yeah, I\'m gonna need that by friday...

  7. #7
    Senior Member
    Join Date
    May 2002
    Posts
    344
    yeah tampabay was right, you must have a main() function and your return 0; has to be inside of main() Also, you shouldnt use #include <iostream.h> That is bad programming style because it is so old. If your using a very old compiler that is ok, but hopefully you are not. Instead use:
    #include <iostream>
    using namespace std;
    This is better style.
    Also i would suggest that you read the little book that teachs you how to use your compiler...i think it will answer a lot of your questions
    Support your right to arm bears.


    ^^This was the first video game which i played on an old win3.1 box

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •