Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you try out small/simple C or C++ source codes?

Tags:

c++

c

windows

ide

It is very easy on Linux to fire-up vi and write a 100-200 lines of code, compile and see the results: ie. Trying small simple examples of C/C++ code.

On windows however, I like Visual Studio but to use it you have create a new solution then a project which then creates a new folder, generates very large PDB and caching files and a small example of 100-200 LOC becomes a 20Mb large project(?!) after compilation.

So the question is how do you write this kind of small codes on Windows? Possibly Cygwin or Dev-C++ (which is not active since 2004?).

like image 698
PythontoBeLoved Avatar asked Dec 11 '09 09:12

PythontoBeLoved


People also ask

What is C source code?

A C file is a source code file for a C or C++ program. It may include an entire program's source code, or may be one of many source files referenced within a programming project. C files can be edited using a basic text editor, but will not show syntax highlighting like most software development programs do.

What is C language with example?

C language is a system programming language because it can be used to do low-level programming (for example driver and kernel). It is generally used to create hardware devices, OS, drivers, kernels, etc. For example, Linux kernel is written in C. It can't be used for internet programming like Java, .Net, PHP, etc.


3 Answers

You can compile from the command line using cl.exe. See the MSDN article How to: Compile a Native C++ Program from the Command Line for detailed instructions.

like image 99
Greg Hewgill Avatar answered Nov 09 '22 20:11

Greg Hewgill


When you installed Visual Studio it created an entry in your programs named something like "Visual Studio Command Prompt" (maybe in a group "Visual Studio Tools").

Execute that Command Prompt (it sets up some environment variables needed for the command line compiler) and use cl, the command line compiler.

> cl /?
Copyright (C) Microsoft Corporation.  All rights reserved.

                         C/C++ COMPILER OPTIONS


                              -OPTIMIZATION-

/O1 minimize space                      /O2 maximize speed
/Ob<n> inline expansion (default n=0)   /Od disable optimizations (default)
/Og enable global optimization          /Oi[-] enable intrinsic functions
...

Edit -- copy from another answer :)

Microsoft Documentation: VS2005, VS2008

like image 24
pmg Avatar answered Nov 09 '22 20:11

pmg


For the simplest examples codepad may be an option.

like image 30
Pascal Cuoq Avatar answered Nov 09 '22 20:11

Pascal Cuoq