Thread: .c in vc++

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    127

    .c in vc++

    How do you add a new .c source file in visual c++?

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Right-click the project & click Add -> New Item
    Give it a name with .c at the end...

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    127
    When you do that the icon to the left of it still says its a cpp source file so whats the difference? Does it even treat it as a .c source file.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    If it has a .c extension it should treat it as a C file. There's also a compile option that says "Compile as" and the choices are "C++ code" and "C code".

  5. #5
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    In my observation VC++ will handle .c files, but it doesn't want to tell you that it can handle .c files.

    Although I haven't done any extensive comparisons. I installed VC++ just long enough to determine that for a tutorial I didn't end up putting on my site. For C I use MinGW with Code::Blocks.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    930
    I gave .cpp extention to every .c file in the Petzold book in vc++2008 and they all worked.

    At least til the half of the book... im only there right now.
    Using Windows 10 with Code Blocks and MingW.

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    For the most part C code will compile just fine under C++ as long as you do explicit typecasting/conversion, which Im pretty sure Petzold does.

  8. #8
    Just a Human Anuradh_a's Avatar
    Join Date
    Jan 2008
    Posts
    50
    I'm also using the Vc++ for c programming.
    you should create a file with extension in c separately. then right click on the source folder
    choose the add existing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. .h file vs .c file
    By RocketMan in forum C Programming
    Replies: 5
    Last Post: 05-13-2008, 07:28 PM
  2. functions in .C file not recognized in .CPP file
    By tooKool4School6 in forum C++ Programming
    Replies: 1
    Last Post: 06-02-2006, 10:30 AM
  3. makefile exported by vc 6.0 doesn't work
    By wow in forum Windows Programming
    Replies: 7
    Last Post: 03-24-2006, 04:20 PM
  4. filename pattern matching
    By dwks in forum C Programming
    Replies: 11
    Last Post: 07-13-2005, 10:23 AM
  5. globals & multiple .c files
    By Unregistered in forum C Programming
    Replies: 8
    Last Post: 10-30-2002, 09:43 PM