views:

88

answers:

4

I'm using Microsoft Visual Studio 2010. When I add files to my project, they have a .cpp extension. To work with C, I have to manually rename the files to .c.

Is there any way to directly add C files, without renaming anything?

+5  A: 

If I'm understanding correctly, you want to directly add a C file to the project. Unfortunately, I don't think VS provides any means to do so; you'll just have to rename newly added files.


You can rename a file from within the IDE. Right click the file and hit rename (or click on the file and push F2).

Click file, push F2.

GMan
no what i want is following for example we have getchar program it's extension is cpp how change it to c?
@davit: I'm not sure what you're asking. A file's extension is in it's name, you're going to change it's name at some point one way or another.
GMan
i need create c file not cpp
c++ programs file is like this hello.cpp i want hello.c
@davit: Right, you just have to rename the file from .cpp to .c. I don't think Visual Studio provides a way of adding C files directly.
GMan
@GMan thanks very much
@davit: No problem, I'm actually surprised there isn't at least an "Add C file" option.
GMan
yes you are right i think it should be
A: 

I've not tried this, but you can probably create a Template that causes the new file to be named with a .c extension by default:

Jason Williams
A: 

Just add a text file and specify the extension to be .C

bashmohandes
+1  A: 

When you "Add New Item", simply include the extension in the "Name:" field and it will override the default for the selected file type.

Clifford