1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[C++] First program and it won't compile

Discussion in 'Code Snippets and Tutorials' started by Icegoten, May 1, 2010.

  1. Icegoten

    Icegoten Level III

    Joined:
    Aug 14, 2008
    Messages:
    460
    Likes Received:
    8
    Code (Text):
    1. /*
    2.    This program displays "I love C++" to the Standard Output
    3. */
    4.  
    5. #include <iostream>
    6.  
    7. int main ()
    8. { std::cout << "I Love C++";
    9.  return 0;
    10.  }
    11.  
    I was following a book from 2003 and trying to adjust to changes since most of the websites, programs, and downloads they use and mention are gone or so outdated they don't work anymore.

    I did manage to get Dev C++ 4.9.9.2 to compile. I typed in the above code and when I click on compile it says "Source file not compiled"

    I don't know what I'm doing wrong and if you need more information I can tell you but I don't know what else I could tell you that would help right now.
     
  2. Angelika

    Angelika Moderator

    Joined:
    Dec 25, 2006
    Messages:
    2,905
    Likes Received:
    36
    Location:
    <(^_^)>
    Did you read the manual?
     
  3. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    Are you sure you clicked "compile" and not just "run"? If so, try pressing "Compile & run". If it still doesn't work, please post the compiler log here
     
  4. Anfan

    Anfan Level IV

    Joined:
    Feb 12, 2009
    Messages:
    1,327
    Likes Received:
    105
    Location:
    USA
    Alright, well, I just did compile/run on Dev C++, and it ran fine.

    Do you have all the basic libraries/header files and such included? (They *should* be by default, but it doesn't make any sense if that can't compile source code.)
     
  5. assasin

    assasin Level IV

    Joined:
    Nov 24, 2007
    Messages:
    835
    Likes Received:
    0
    You have to save your program in .cpp format not in .c(Dev c++ doesnt take .c correctly).

    After saving then try again it should work!!
     
  6. Icegoten

    Icegoten Level III

    Joined:
    Aug 14, 2008
    Messages:
    460
    Likes Received:
    8
    Well this is probably the problem and I didn't see anything about this on their site when I downloaded it.

    I clicked compile alone. Clicked run alone. Clicked Compile & Run alone. They all didn't do it for me.

    Here is the log
    Code (Text):
    1. Compiler: Default compiler
    2. C:\CPPFiles\ILoveCPlusPlus.cpp
    3. Compiling
    4. Done.
    5.  
     
  7. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
    What operating system are you running?
     
  8. Icegoten

    Icegoten Level III

    Joined:
    Aug 14, 2008
    Messages:
    460
    Likes Received:
    8
    Windows 7 64-Bit
     
  9. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
  10. Icegoten

    Icegoten Level III

    Joined:
    Aug 14, 2008
    Messages:
    460
    Likes Received:
    8
    Thank you Zero! That fixed the problem. Now I can continue learning.
     
  11. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    Hmmm that might be a problem. I *think* the included mingw doesn't support 64-bit, so you might have to look into it. Try using the XP mode in windows 7? If it can handle a 32 bit XP operating system, everything should compile fine (on the virtual machine, of course).
     
  12. Icegoten

    Icegoten Level III

    Joined:
    Aug 14, 2008
    Messages:
    460
    Likes Received:
    8
    So if I wanted to continue just doing everything on 64-bit I should look for a new compiler? Or is 64-bit the actual problem?
     
  13. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    Actually, I have no experience on 64-bit windows OS'es, so I can't be sure. I think everything should still compile fine (afterall there's 32bit support for a reason) but it won't be optimized. You probably won't care as for the moment you're just doing basic standard input/output stuff, so w/e :p