Thread: Compile C in Visual Studio

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    5

    Compile C in Visual Studio

    Hi

    I am very new to the C language and am wondering is it possible to compile the code in Visual Studio?

    I do have a compiler that works well on my personal pc, but if I can compile it in Visual Studio I would be able to work on my stuff during my breaks at work (without having to drag my laptop back and forth).

    Many thanks!
    Carol

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Keylac
    I am very new to the C language and am wondering is it possible to compile the code in Visual Studio?
    Yes it is. You just need to name your source files with a .c extension (this may involve renaming .cpp files to .c). You can also change the configuration to compile as C.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by Keylac View Post
    Hi

    I am very new to the C language and am wondering is it possible to compile the code in Visual Studio?

    I do have a compiler that works well on my personal pc, but if I can compile it in Visual Studio I would be able to work on my stuff during my breaks at work (without having to drag my laptop back and forth).

    Many thanks!
    Carol
    Code:
    1 New Project
    2 Click Win32/64 console Applicaiton
    3 Enter project name
    4 Dis-able pre-defined header files
    5 Click Ok
    6 Click "Add to project"
    7 Click .cpp file
    8 Name it <file name here> .c <- VERY IMPORTANT
    9 Click OK
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    5
    Excellent, thanks very much!

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    26
    In your project properties, expand the C/C++ node and select Advanced. There is a setting that allows you to select whether you want to compile the project as C or as C++. I don't think you'll have to change the file extension of your source files.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You can do it that way, but I would not recommend it. C code is supposed to have a .c extension to let everyone know it is indeed C code.
    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.

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Keylac View Post
    I do have a compiler that works well on my personal pc, but if I can compile it in Visual Studio I would be able to work on my stuff during my breaks at work (without having to drag my laptop back and forth).
    That sounds like a good way for your employer to end up owning all your code.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  4. visual studio won't compile what i modify
    By Shadow12345 in forum C++ Programming
    Replies: 7
    Last Post: 11-28-2002, 09:27 PM
  5. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 04:07 PM