DJGPP Problems
Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: DJGPP Problems

  1. #1
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953

    Unhappy DJGPP Problems

    I'm really sorry I have to ask this...
    I'm having a hard time Converting from C to C++
    I can't seem to get Hello World working.

    1 #include <iostream.h>
    2
    3 int main()
    4 {
    7 cout << "\n\nHello World!\n";
    8 return 0;
    9 }
    yeah, I\'m gonna need that by friday...

  2. #2
    Antionline Herpetologist
    Join Date
    Aug 2001
    Posts
    1,165
    Your code should read:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    cout << "\n\nHello World!\n";
    return 0;
    }
    Cheers,
    cgkanchi
    Buy the Snakes of India book, support research and education (sorry the website has been discontinued)
    My blog: http://biology000.blogspot.com

  3. #3
    () \/V |\| 3 |) |3\/ |\|3G47|\/3
    Join Date
    Sep 2002
    Posts
    744
    I just compiled it - and it's just fine. Can you tell me what errors you are getting?

    Go Finland!
    Deviant Gallery

  4. #4
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953

    Here is a screen shot

    Thanx for the help, i get this error on multiple computers and multiple versions of Windows...

    Edit*
    More Madness: I have no trouble compiling C code. Only get errors with C++ source.
    yeah, I\'m gonna need that by friday...

  5. #5
    () \/V |\| 3 |) |3\/ |\|3G47|\/3
    Join Date
    Sep 2002
    Posts
    744
    Sorry, I don't think I'm familiar with your compiler. I'm using Microsoft Visual C++ 6.

    Just so you can see the the results of your code I've attached a screen shot.

    Go Finland!
    Deviant Gallery

  6. #6
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    -Thanx any way gals/guys...
    -I guess i'll just stick to C anyway!
    -Peace*
    yeah, I\'m gonna need that by friday...

  7. #7
    Junior Member
    Join Date
    Aug 2001
    Posts
    10
    tampabay420: If you use the code that cgkanchi posted, your program will work. You forgot the "using namespace std;" right after your includes. It's a commonly overlooked thing and is not required by all compilers.
    HaLCy0n

    \"Press any key to continue, or any other key to quit.\"

  8. #8
    Senior Member
    Join Date
    Jul 2002
    Posts
    744
    Try it like this:

    #include <iostream.h>
    void main(void)
    {
    cout << "Hello, World!";
    }

    I don't think you need the using. . . line with your compiler.
    Every now and then, one of you won't annoy me.

  9. #9
    Junior Member
    Join Date
    Aug 2001
    Posts
    10
    The program that bludgeon posted will work, but I believe that is following the older standards. Let me explain exactly what the using namespace command does.

    When you use the standard C++ functions, they are declared in the "std" scope. For example, if I did not put the "using namespace std;" I would have to say something like, "std::cout << "Hello World\n";" in order for it to work. That's just a little explanation.

    If you wanna read more indepth about how namespaces work exactly, here's a link for you: http://www.cplusplus.com/doc/tutorial/tut5-2.html

    Hope this helps.
    HaLCy0n

    \"Press any key to continue, or any other key to quit.\"

  10. #10
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    I used the using namespace std;
    -didn't work... but the link you sent was great. Thanx :-)

    edit*
    ________________________________
    #include <iostream>
    using namespace std;

    int main () {
    cout << "Hello world in ANSI-C++\n";
    return 0;
    }
    ________________________________
    #include <iostream>

    int main () {
    std::cout << "Hello world in ANSI-C++\n";
    return 0;
    }
    ________________________________

    Both didn't work, same error... Look at the screen shot...

    -Maybe it's my compiler...
    yeah, I\'m gonna need that by friday...

Posting Permissions

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