Re: How to RUN C by Microsoft Visual Studio 選項

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Mike wrote:
I would like to use microsoft visual studio to compile a C program.
Does somebody know how to compile, link and run it?

Create an empty project and add the sourcefile to it. Keep in mind that the
compiler by default assumes C only for .c files and uses C++ for .cpp
files.

I create a project and add a program to it.
I press F5 to start debug (because I cannot find any command to run,
why?).

Control-F5, I think.

A console window just appears and close very quickly.

Well, your program is started, it creates a console window, does whatever it
should do and then terminates and closes the output window.

How can I pause the console window?

There are several ways:
- Create an endless loop at the end of the program (while(1);).
- Set a breakpoint near the end (F9 toggles breakpoints for a line).
- Wait for the user to press a key (getc comes to mind).
- Don't run the program from the IDE but from a commandline shell.

I typically use the second or third way, the third way typically dependant
on the result of IsDebuggerPresent().

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Michael Wöhrmann, Amtsgericht Hamburg HR B62 932
.



Relevant Pages

  • Re: I want to make a C# library of some classes
    ... compile the BaseParser with the generated library - seems too simple for me ... so the second thing that comes into my mind is to let them ... makes our class work to make their class work, ... would actually compile in C as well as C++. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: macro question
    ... be negative numbers and create an exponential moving average. ... is a snippet of what I had in mind. ... No I didn't try to compile it. ...
    (comp.lang.c)
  • Re: Handling Bugs
    ... Keep in mind that while you can compile your code before you distribute it ... Keep in mind that any un- handled error in the runtime is a much ... but in the runtime those un-handled errors does not ... So, the issue of making sure one's code having compile errors is important, ...
    (microsoft.public.access.formscoding)
  • RE: Writing a Fortran parser...
    ... However, further digging ... would everyone mind try to compile the following ... >end program foo ... >With this nasty little example in mind, what are the rules governing the ...
    (comp.lang.fortran)
  • Re: How to RUN C by Microsoft Visual Studio
    ... I would like to use microsoft visual studio to compile a C program. ... A console window just appears and close very quickly. ... Don't run the program from the MSVC console window. ...
    (comp.lang.c)