Results 1 to 11 of 11

Thread: C Compiler

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    7

    Question C Compiler

    Hi,

    Just wondering if Borland C++ Compiler version 5.5 works for C language also?

    If not, can u plz refer me with a similar free C compiler?


    Thanx

  2. #2
    SG Elite
    Join Date
    Jun 2001
    Posts
    26,794

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Posts
    7
    ok I downloaded Bloodsheed Dev C++

    I am trying to run this code

    Code:
    #include <stdio.h>
    
    int main()
    {
        printf("\n");
        printf("Hello World");
        printf("\n");
    }

    It compiles ok, and a DOS screen comes for a few milliseconds and disappears.

    Why is this hapenning? And How/Where do I see the output?

    Sorry, I am new to C.


    Thanx

  4. #4
    Forum Techie A_old's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta
    Posts
    10,663
    Probably because the program does its thing, returns and so the "DOS screen" (command prompt) closes. Try opening a command prompt and running your program that way instead of double clicking.

  5. #5
    Junior Member
    Join Date
    Jul 2008
    Posts
    7
    Solved.

    I had to include getch(); at the end of the program.

  6. #6
    Forum Techie A_old's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta
    Posts
    10,663
    I guess that works, but it keeps your program running until you hit a key, no? Why wouldn't you just let it close and run it from the command line? You didn't really solve anything b/c it wasn't a problem to start with.

  7. #7
    Certified SG Addict Brent's Avatar
    Join Date
    Oct 1999
    Posts
    42,161
    Create a shorcut to cmd.exe, right click on it, uncheck close on exit
    "Would you mind not standing on my chest, my hats on fire." - The Doctor

  8. #8
    Junior Member
    Join Date
    Jul 2008
    Posts
    7
    Quote Originally Posted by Amro View Post
    I guess that works, but it keeps your program running until you hit a key, no? Why wouldn't you just let it close and run it from the command line? You didn't really solve anything b/c it wasn't a problem to start with.
    Why would it then just close instead of displaying the message?

  9. #9
    Forum Techie A_old's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta
    Posts
    10,663
    Quote Originally Posted by cancer10 View Post
    Why would it then just close instead of displaying the message?
    Oh, I see why you were confused now. When you launch your program by double clicking it, it shows the message, then exits since the main function returns. By default, the window closes when the program exists. It all happens so quickly that you can't see it. Again, I suggest simply running it from the command line but your trick works for the "double click" case without any setting changes.

  10. #10
    Junior Member
    Join Date
    Jul 2008
    Posts
    7
    How do I run my helloworld.c program through the command line?

  11. #11
    Forum Techie A_old's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta
    Posts
    10,663
    Quote Originally Posted by cancer10 View Post
    How do I run my helloworld.c program through the command line?
    after you've compiled it into executable form, you simply open a command prompt (start-->run-->type cmd and hit enter) and then change directory to the location of the executable, then type its name and hit enter. you should look into general terminal and command prompt usage as you'll need to know a lot about it later on (if you plan to be a software developer), especially if you're working with linux/unix, etc.

Bookmarks

Posting Permissions

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