Thread: how to create and compile c programs

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    116

    how to create and compile c programs

    Hi, I have one last question

    at my university we are using visual studio 2010 for creating and compiling code.

    I downloaded it to my laptop but it expires soon and is very expensive.

    One of my classmates said you can write c on notepad and run it using the command prompt.

    is this correct and how so I do it. If I work on it at home in this manner, will I still be able to put it into visual studio at uni to demonstrate my code to my teacher?

    Is there any disadvantages to using different methods of compiling?

    Any information that can be provided on this issue would be greatly appreciated

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    The express version of Visual Studio 2010 should be free. I'd recommend that since you'd then have a common point of reference as to how your code should behave both at home and at school. If not the express version, then most universities I believe have some sort of student discount associated with the purchasing of such tools. Would that be an option?

    Code is just text, whatever application you've already got that has an editor of some kind (MS Word/Wordpad/Notepad,etc...) can be used to write code. What you do need is a compiler to translate that code into an actual executable. You cannot just write C code and then run that without some other piece in between the code stage and the executable stage whether it is a compiler or some kind of interpreter.

    If you are going to be using different compilers to test your programs out you need to - at the very least - write standard code. Code that is written to the standard should run the same and produce the same output if compiled on any compiler. What you absolutely want to avoid is the use of non-standard code or compiler specific functionality that would work in your testing at home but then fail to compile or execute the same on the systems at school.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    thanks for explaining that, I think i understand a bit better.

    I will take your advice and download the express version for home use.

    In the long run though, do you think its worthwhile me learning other compiler prgograms?

    What different types are there and what are the advantages and disadvantages? What do most people use here?

    At what stage do you think I should consider downloading a different compiler? I m guessing its not till ive finished my studies and am confident with programming?

    I figured if i kinow where to look there are prob some really good free ones

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    I recommend that you install Linux/GCC/GDB/Vim as soon as you are able. Beats a Windows development environment, hands down.

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    88
    If you're comfortable with Visual Studio, there's no need to stop. It's a widely-used compiler. There are however many things that are Visual Studio specific, so make sure when you learn to distinguish between what is standard and what is not (as hk_mp5kpdw said). It will come in handy if you do programming that is not windows-specific and needs to be portable.

    There are free options:

    MinGW for windows is not too hard to download and install. It includes ports of gcc and g++ (free linux compilers) for c and c++ code. Once you install and setup MinGW for windows, you can just open a command prompt and compile programs from the appropriate folders. There are many tutorials online about using the gcc and g++ compilers.

    These compilers made available through MinGW can also be used through Code::Blocks which is an IDE (integrated development environment). An IDE is something that helps you organize and manage coding projects, and is not a compiler itself. Code::Blocks can be set up to run with many different compilers (free or otherwise). Think of code::blocks as a nice user interface to deal with editing files and compiling projects (with many options you can mess with).

    EDIT: Like the above poster who beat me to the punch, I do prefer coding in Linux. But if you don't want to learn a new operating system, MinGW is a good option. Different versions of Linux are maintained by coders so there are many great free tools on different Linux distributions.
    EDIT 2: Well, no s**t, they're maintained by coders, but you know what I mean. There are many free tools for programming maintained and widely available for Linux.
    Last edited by Ocifer; 02-02-2012 at 12:01 PM.
    W7, Ubuntu -- mingw, gcc, g++, code::blocks, emacs, notepad++

  6. #6
    Registered User
    Join Date
    Jan 2012
    Posts
    69
    GCC?

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by kevinstrijbos View Post
    GCC?
    GCC, the GNU Compiler Collection
    GCC, the GNU Compiler Collection - GNU Project - Free Software Foundation (FSF)
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    Jan 2012
    Posts
    69
    I know what it is, it was just an answer to the question how to write programs in notepad and compile it

  9. #9
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by siliconbz View Post
    I recommend that you install Linux/GCC/GDB/Vim as soon as you are able. Beats a Windows development environment, hands down.
    actually i just bought a linux magazine with free cd with ubuntu which im planning to use as a dual operating system as some of teh researchers at my uni prefer it so figured i should get used to it

  10. #10
    Registered User
    Join Date
    Jan 2012
    Posts
    69
    I recommend you first install Linux with wubi, just to check if you want to use Linux. Wubi instals Ubuntu as a "program" within Windows, so you don't have to worry about data loss while partitioning etc etc.

  11. #11
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    You don't need multiple compilers when you're just starting out. You have enough to deal with at that stage, without adding the complexity of learning more than one compiler and IDE at once. Just stick with VS2010 Express.

    It will be useful eventually though.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  12. #12
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by Ocifer View Post
    If you're comfortable with Visual Studio, there's no need to stop. It's a widely-used compiler. There are however many things that are Visual Studio specific, so make sure when you learn to distinguish between what is standard and what is not (as hk_mp5kpdw said). It will come in handy if you do programming that is not windows-specific and needs to be portable.

    There are free options:

    MinGW for windows is not too hard to download and install. It includes ports of gcc and g++ (free linux compilers) for c and c++ code. Once you install and setup MinGW for windows, you can just open a command prompt and compile programs from the appropriate folders. There are many tutorials online about using the gcc and g++ compilers.

    These compilers made available through MinGW can also be used through Code::Blocks which is an IDE (integrated development environment). An IDE is something that helps you organize and manage coding projects, and is not a compiler itself. Code::Blocks can be set up to run with many different compilers (free or otherwise). Think of code::blocks as a nice user interface to deal with editing files and compiling projects (with many options you can mess with).

    EDIT: Like the above poster who beat me to the punch, I do prefer coding in Linux. But if you don't want to learn a new operating system, MinGW is a good option. Different versions of Linux are maintained by coders so there are many great free tools on different Linux distributions.
    EDIT 2: Well, no s**t, they're maintained by coders, but you know what I mean. There are many free tools for programming maintained and widely available for Linux.
    thanks for taking the time to write this, it was very informative. I will add this thread to my favourites so I can use it in future for reference too as Ill prob need a plan of how to move forward and develop my coding skills

  13. #13
    Registered User
    Join Date
    Feb 2012
    Posts
    116
    Quote Originally Posted by iMalc View Post
    You don't need multiple compilers when you're just starting out. You have enough to deal with at that stage, without adding the complexity of learning more than one compiler and IDE at once. Just stick with VS2010 Express.

    It will be useful eventually though.

    agreed. at this stage its more just for background understanding but eventually i do wish to leave my comfort zone and look at other compilers. Will stick to vs2010 for now but was definitely useful to get a better understanding of what else is out there. I will carry on imporiving my c programming via vs2010 for now but when I am strong with it and have a better idea of what other languages/skills etc I will need I will definitely have to plan a lerarning pathway for myself and decide what needs to be learned and in what order to getting some background knowledge should enable me to time things right and have a proper plan of action

  14. #14
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    Just get started with GCC. Programming with MSVS is a headache. So many buttons and menus. You're learning code, not M$'s interfaces and quirky methods.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create batch file to compile and run programs
    By Springy in forum C Programming
    Replies: 3
    Last Post: 10-23-2009, 06:11 AM
  2. Can you create, edit and compile C code with a C++ IDE?
    By nerdpirate in forum C Programming
    Replies: 4
    Last Post: 05-31-2008, 01:54 AM
  3. Could I create my own library to include in programs?
    By EliasK in forum C++ Programming
    Replies: 1
    Last Post: 03-22-2003, 08:24 AM
  4. how to compile & run c programs in unix?
    By Unregistere in forum C Programming
    Replies: 2
    Last Post: 10-09-2002, 10:53 PM
  5. Has anybody gotten Dev-C++ to compile DirectX programs?
    By Harpoon in forum Game Programming
    Replies: 2
    Last Post: 12-14-2001, 01:54 PM