Thread: Executing C Program in Visual Studio 2008

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    14

    Executing C Program in Visual Studio 2008

    I am trying to teach myself C Programming. I need to know how to execute an application in Visual Studio 2008. I can't find a way to do this!!! It is only the first example aswell which is to simply print out hello

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Well in VS2005 you press F5 to run with debug, or CTRL + F5 to run without it.

  3. #3
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by mike_g View Post
    Well in VS2005 you press F5 to run with debug, or CTRL + F5 to run without it.
    what's the difference between the two?

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by BEN10 View Post
    what's the difference between the two?
    F5 starts the debugger. Obviously, the program runs slower in the debugger than without. Furthermore, in Debug mode, the console window disappears when the program does as opposed to non-debug mode (but you can use a breakpoint to avoid that).

    Also, you DON'T need an empty project. It will create a default project for you that will compile fine (although it creates a C++ file, but you can rename them). Remember that by default it also creates a precompiled header, which means you must add #include "stdafx.h" at the beginning of every source file.
    I'm not certain if it includes C++ headers in stdafx.h by default. I don't think so...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by Elysia View Post
    F5 starts the debugger. Obviously, the program runs slower in the debugger than without. Furthermore, in Debug mode, the console window disappears when the program does as opposed to non-debug mode (but you can use a breakpoint to avoid that).

    Also, you DON'T need an empty project. It will create a default project for you that will compile fine (although it creates a C++ file, but you can rename them). Remember that by default it also creates a precompiled header, which means you must add #include "stdafx.h" at the beginning of every source file.
    I'm not certain if it includes C++ headers in stdafx.h by default. I don't think so...
    i usually press F5 to debug.can i start CNTRL+F5(it'll save me from writing getch()).will it affect my execution of the program in any way?and what is the difference between debugging and non-debugging?

  6. #6
    Registered User Sharke's Avatar
    Join Date
    Jun 2008
    Location
    NYC
    Posts
    303
    I agree that you should just use Visual Studio C++ Express Edition.

    It's a complete program, not a trial - and as a beginner I am finding it to be an absolutely superb IDE for learning how to program in C and C++. I've used various other IDEs with other languages and VSC++ is by far and away the best I've ever used. Intellisense is fantastic as a learning tool when you're starting out with things such as passing pointers to structs around and the like. There's many a time it's made me realize exactly what I was doing wrong. I love it.

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by BEN10 View Post
    i usually press F5 to debug.can i start CNTRL+F5(it'll save me from writing getch()).will it affect my execution of the program in any way?and what is the difference between debugging and non-debugging?
    You do know what a debugger is, I hope?
    The only difference is that your program will crash or you will get a runtime error dialog if something goes wrong in non-debugging mode. In debugging mode, the debugger will break where the error occurred.
    And debugging mode gives you access to debugging features, naturally.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Same thing with 2008.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Feb 2008
    Posts
    14
    The option is greyed out in the menu. Don't know if it's down to the type of file i opened, i opened up a text file in the C++ development IDE and then saved it as a .c file.
    Last edited by rory-uk; 02-04-2008 at 01:51 PM.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You need to create a project first, then add files to the project and compile through F7, then run through F5 or Ctrl+F5.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User
    Join Date
    Feb 2008
    Posts
    14
    Getting build errors with attempting to do the above. In fact I'm not sure if this version of Visual Studio will allow me to create a C Program. Can anyone give me a link to an IDE for C Programming which I can download for free that works on 64 Bit Home Premium Vista?

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It does work. Post your compile errors.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Registered User
    Join Date
    Feb 2008
    Posts
    14
    1>------ Build started: Project: Test3, Configuration: Debug Win32 ------
    1>Compiling manifest to resources...
    1>Project : error PRJ0003 : Error spawning 'rc.exe'.
    1>Build log was saved at "file://c:\Users\Rory\Documents\Visual Studio 2008\Projects\Test3\Test3\Debug\BuildLog.htm"
    1>Test3 - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  14. #14
    Registered User
    Join Date
    Feb 2008
    Posts
    14
    The original file that gets created is a .cpp file, which is a C++ extension and the other file I created is a .c Isn't this not going to work

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Does Visual Studio Express come with a recourse compiler (rc.exe)?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OutputDebugString not working in Visual Studio 2008
    By jw232 in forum Windows Programming
    Replies: 3
    Last Post: 07-02-2009, 07:13 PM
  2. C & visual studio 2008
    By Red Maw in forum C Programming
    Replies: 2
    Last Post: 04-02-2009, 09:06 PM
  3. Visual Studio Express 2008 problems.
    By Normac in forum C++ Programming
    Replies: 2
    Last Post: 08-08-2007, 10:41 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM