How do I compile and run C code in Visual C++?

  • Thread starter Thread starter BigDaddyCool
  • Start date Start date
B

BigDaddyCool

I know that Visual C++ can compile C code. How do I do this? For example,
here is a hello world program in c:

#include <stdio.h>

int main(void)
{
printf("hello, world\n");
return 0;
}

How do I get this program to compile and run in Visual C++ 2005 Express
Edition? Please note that I am a bit of a newbie to programming, so please be
thorough with the instructions.
 
BigDaddyCool said:
I know that Visual C++ can compile C code. How do I do this? For example,
here is a hello world program in c:

#include <stdio.h>

int main(void)
{
printf("hello, world\n");
return 0;
}

How do I get this program to compile and run in Visual C++ 2005 Express
Edition? Please note that I am a bit of a newbie to programming, so please
be
thorough with the instructions.

And you, please, do your homework :)
Install VC++ express with the MSDN library. Run it. On the start page note
the "Getting started" box;
have look at the link "Create your first application".

Good luck.

--pa
 
I don't see a "Create Your First Application" under "Getting Started." All I
see are the following:

Visual C++ Express General Information
Download the PSDK
What's New in Visual C++
Creating and Managing the Visual C++ Pr...
How Do I...?
Connect With the Community

Am I looking in the wrong place?
 
BigDaddyCool said:
I don't see a "Create Your First Application" under "Getting Started."
All I
see are the following:

Visual C++ Express General Information
Download the PSDK
What's New in Visual C++
Creating and Managing the Visual C++ Pr...
How Do I...?
Connect With the Community

Am I looking in the wrong place?

My apologies. I was looking at VC++ 2008 SP1, not 2005.
Why not to get updated.

--PA
 
OK, so I updated to Visual C++ 2008 and clicked on "Create Your First
Application." However, I don't really see anything in the hel file that
explains how to do this. The only C-related thing I'm seeing is it says that
Visual C++ 2008 complies with "the ISO C 95" standard. I don't see anything
regarding how to compile and run C programs.
 
BigDaddyCool said:
OK, so I updated to Visual C++ 2008 and clicked on "Create Your First
Application." However, I don't really see anything in the hel file that
explains how to do this. The only C-related thing I'm seeing is it says that
Visual C++ 2008 complies with "the ISO C 95" standard. I don't see anything
regarding how to compile and run C programs.

There should be something about creating a project.
You click on File, New, Project, win32 console application.
This creates a template from which you start, something like
the "hello world" program.

If you really want to see the "hello world" presto,
without the project and things: open the VS command prompt,
then cd to your source dir, then type: cl yourfile.c
Lo and behold, it will compile to yourfile.exe.

Regards,
-- pa
 
To spell this out, by default, Visual Studio uses the C compiler for
compiling source files ending in *.c and the C++ compiler for
compiling source files ending in *.cpp.

Brian
 
Back
Top