Newbie

This is a discussion on Newbie within the C++ Programming forums, part of the General Programming Boards category; I'm new to C++ and i'm going through the tutorials on this site, however the first piece of code it ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    7

    Newbie

    I'm new to C++ and i'm going through the tutorials on this site, however the first piece of code it gives me to start learning doesn't work.

    #include <iostream.h>
    int main()
    {
    cout<<"HEY, you, I'm alive! Oh, and Hello World!";
    cin.get();
    return 0;
    }

    It keeps on returning Unable to run program. I'm using Dev-C++ 5

    can anyone tell me whats going on?

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Code:
    #include <iostream>
    int main() {
       std::cout << "Hello world!" << std::endl;
       return 0;
    }

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    7
    Again i get unable to run program

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    "Unable to run program"

    What are you doing when you get that error?

    I assume this happens when you try to compile & link???

    It sounds like the Dev-C++ compiler itself is the program that's "not running". If this is the case, then you're having a problem with your compiler, not your program. I assume that you never get a "Hello.EXE" file. (?)

    I probably won't be able to help you, because I don't use Dev-C++, but it is a very popular package, and someone here should be able to help.

    Don't give up! I've used several different compilers (mostly obscure ones), and none of them have ever worked as expected "out-of-the-box". Read-over the documentation carefully, and make sure that everything is set-up and configured correctly. Also, save your "Hello.CPP" file in whatever directory/folder is recommended by the Dev-C++ documentation.

    Oh, make sure that the compiler is configured to compile a "console" application, not a Win32 GUI application.

  5. #5
    Registered User
    Join Date
    Apr 2004
    Posts
    7
    That sounds likely, I was just wondering if it might have something to do with me not having Mingw/GCC with the compiler

  6. #6
    Registered User
    Join Date
    Apr 2004
    Posts
    19
    Isnt he forgeting to #include <string.h>?

    Well I am new as well but you would put that if you wanted the user to input something with spaces for example

    Code:
    #include <string.h>
    #include <iostream.h>
    
    int main()
    {
         char userName[25]="";
    
              cout<<"Hello, enter your name ";
              cin.getline(userName,25);
    
              cout<<"Hello, "<<userName<<endl;
         return 0;
    }
    errr sorry I think I have complicated it up a bit, and in doing so I forgot the question...enjoy.
    jotun

    n : (Norse mythology) one of a race of giants often in conflict with the Aesir [syn: Jotun, Jotunn]

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Isnt he forgeting to #include <string.h>?
    None of the code posted previously has used anything from <string.h> (which should be <cstring> to be correct C++).

    >if you wanted the user to input something with spaces for example
    Well, yes. That's correct. However, both your code and your post have no bearing on the question, which is most likely an incorrect installation of the compiler.
    My best code is written with the delete key.

  8. #8
    Registered User
    Join Date
    Apr 2004
    Posts
    7
    having #include <string.h> didn't help

  9. #9
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    You didn't download Dev-C++ with the MinGW compiler?

    That's probably your problem. Dev-C++ is just an IDE. You need the compiler to... compile it.

  10. #10
    Registered User
    Join Date
    Apr 2004
    Posts
    7
    I decided to dl Dev-C++ 4.0 with mingw, i installed it and tryed to run this program and i
    m still getting an error but now it is:

    parse error before `{'

    Does this give anyone any insight into the problem

  11. #11
    Board Conservative UnregdRegd's Avatar
    Join Date
    Jul 2003
    Posts
    154
    Quote Originally Posted by PsyK
    I decided to dl Dev-C++ 4.0 with mingw, i installed it and tryed to run this program and i
    m still getting an error but now it is:

    parse error before `{'

    Does this give anyone any insight into the problem
    Check what you typed and make sure it's exactly as follows (and also make sure you set the project as a Win32 console application):

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        cout << "Hello, world!" << endl;
        return 0;
    }
    If there was a typo or something, you might get an error like the one you got.
    I am a programmer. My first duty is to God, then to nation, then to employer, then to family, then to friends, then to computer, and finally to myself. I code with dignity, honor, and integrity.

  12. #12
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Did you compile this:
    Code:
    #include <iostream.h> 
    int main() 
    {
    cout<<"HEY, you, I'm alive! Oh, and Hello World!"; 
    cin.get();
    return 0; 
    }
    or this:

    Code:
    #include <iostream>
    
    int main() {
     std::cout << Hey, you, I'm alive! Oh, and Hello World!";
     cin.get();
     return 0;
    }
    ?
    Do not make direct eye contact with me.

  13. #13
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    y dont u try getting a more recent version of the compiler? u going backwards...

  14. #14
    Registered User
    Join Date
    Apr 2004
    Posts
    7
    I have the same problem with my version of DEV. I ran the code through G++ on my linux box and it ran just fine. It turns out that the latest version of DEV doesn't include the iostream library. At least mine doesn't. I have my own thread asking about that elsewhere.
    I'm not sure where to get that library nor how to make it.
    If you have access to a different compiler or can find/make/improvise a new iostream library, then your code should work fine.
    -=Wynter]=-

  15. #15
    Registered User
    Join Date
    Apr 2004
    Posts
    19
    It runs find in CodeWarrior
    jotun

    n : (Norse mythology) one of a race of giants often in conflict with the Aesir [syn: Jotun, Jotunn]

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 06:49 PM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 11:53 AM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  4. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 07:44 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM

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