Hello

This is a discussion on Hello within the C Programming forums, part of the General Programming Boards category; I am new to the site, and new to C programming, and I wanted to know how to get started. ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    6

    Hello

    I am new to the site, and new to C programming, and I wanted to know how to get started.

    The mian question I have is, what compiler should I use to compile my code?

    Thanks.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    When first getting started, it's better to test the waters with a free compiler than to spend money on a retail compiler. Two good ones for Windows are Bloodshed's Dev-C++ and Borland C++ 5.5. Dev-C++ is an IDE with the popular GCC compiler as the back-end, and Borland C++ 5.5 is a command line compiler. Both are free and high quality.

    For Linux, you should already have GCC installed, so it's just a man away. For Unix, if it doesn't have GCC then it will probably have cc, which is the classic Unix C compiler.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    6
    Yes, I tried Dev-C++, but for some reason it doesn't compile.

    I get this error:

    "Unable to run program file"

    and the compile log is this:

    "Compiler: Default compiler
    Building Makefile: "C:\Dev-Cpp\Examples\Hello\Makefile.win"
    Executing make...
    make.exe -f "C:\Dev-Cpp\Examples\Hello\Makefile.win" all
    Execution terminated"

    Any idea what could be wrong? It isn't the code, I tried a sample script they included with Dev-c++ and got the same error.

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Maybe the installation instructions should be re-read?
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    6
    There were not installation instructions. It just installed.

  6. #6
    Registered User
    Join Date
    Dec 2004
    Posts
    6
    OK, I got it working. But I tried a sample code I whipped up

    Code:
    #include <stdio.h>
    
    main()
    {
        printf("Hello");
        
    return 0;
        
    }
    And a DOS window comes up for like .5 seconds and then disapears.

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    It sounds like you just installed the Dev-C++ front-end. There are two options if I recall correctly. One is just the IDE if you already have a compiler installed, and the other is the IDE with the GCC package. Which one of those did you choose on installation?
    My best code is written with the delete key.

  8. #8
    Registered User
    Join Date
    Dec 2004
    Posts
    6
    I got it working, I just added dev-cpp/bin to the compiler options and it compiles fine, but now

    It comes up with a DOS window for like .5 seconds and then goes away with this code.

    Code:
    #include <stdio.h>
    
    main()
    {
        printf("Hello");
        
    return 0;
        
    }

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >main()
    This should be
    Code:
    int main(void)
    Let's start the good habits early.

    >printf("Hello");
    You need a \n at the end of the format string because further output may look funny otherwise, and a newline is required to flush the stream so that you can see the output. This isn't terribly important on a Windows machine, but it's a good idea if you want portable code.

    >It comes up with a DOS window for like .5 seconds and then goes away
    The program is done. Because Dev-C++ opens a new command line window just for your program, when the program terminates, the window is destroyed. You can avoid this by a request for input. This causes a blocking read and leaves the window open until you hit [Enter]:
    Code:
    #include <stdio.h>
    
    int main(void)
    {
      printf("Hello\n");
      getchar();
        
      return 0;
    }
    My best code is written with the delete key.

  10. #10
    Registered User
    Join Date
    Dec 2004
    Posts
    6
    Thanks for all of your help!

  11. #11
    * S T U D E N T *
    Join Date
    Oct 2003
    Posts
    30
    i use dev-cpp and i open up a seperate cmd (dos , or what used to be dos but now "windowsed") window, and then just compile it in dev-cpp but run it in the cmd window!

    also from an earlier post, UNIX does not always have gcc installed. but all you need to do is put disc1 of your distro in and add the relevant packages!

    hope that helps!

    --CHriS
    'rm -fr /bin/laden'
    'kill all'

  12. #12
    </life>
    Join Date
    Oct 2004
    Posts
    83
    I've yet to see a UNIX installation without the cc compiler.
    Microsoft is merely an illusion, albeit a very persistant one.

  13. #13
    * S T U D E N T *
    Join Date
    Oct 2003
    Posts
    30
    sure it comes with cc but one time it installed without the gcc compiler. ive never used cc and never been told to use it, thats all. isnt gcc the recommended compiler anyway? *hints at a debate amongst the C pr0s* hehe

    --CHriS
    'rm -fr /bin/laden'
    'kill all'

  14. #14
    ---
    Join Date
    May 2004
    Posts
    1,379
    i think gcc is the free implementation of cc. thats all.

  15. #15
    Jez
    Jez is offline
    The C-er
    Join Date
    Mar 2004
    Posts
    192
    I like LCC-win32. I comes as a complete development enviroment so it's easy to get started with. It's (almost) C99 compliant, and is well supported + actively developed.

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

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