Post: How to create a C program in Visual Studio
07-18-2016, 04:57 PM #1
primetime43
Knowledge is power Tiphat
(adsbygoogle = window.adsbygoogle || []).push({});
Hey there NGU, so today I'm going to show you guys how to make a program in C, even though there isn't any C template option.

First off, open Visual Studio and then go to click on new project. (File > New > Project). Which will then bring you to this:
You must login or register to view this content.

At this page, click next and then select the options and make your screen like the picture below:
You must login or register to view this content.
Once at this page, go to Templates > Visual C++ > then once in there, select Win32 Console Application (as seen in the picture above. Also feel free to name it and custom it's save location etc.) Once done with that click OK and you will then be taken to this page here:
You must login or register to view this content.

Once at this page, click next and make your screen look like the picture below with the same options selected etc:
You must login or register to view this content.

Once you have done that, go ahead and select finish and your screen will look like this:
You must login or register to view this content.

Now to create the C file, (make sure you have the ConsoleApplication name highlighted blue when you go to do this) you want to go up to Project > Add New Item and this screen will appear:
You must login or register to view this content.

Have the C++ File option selected like above in the picture and where it says name, all you need to do is make sure you have it like this: FILENAME.c because if you make it have a .cpp extenstion, that means it's a C++ file. Then select done and your file will be created and then you can go ahead and begin coding in the C file. Here's some code you probably would want to use if you're following this:
    
int main(void) //for those who don't know, you put void in here because if you don't that means the method has unlimited arguments, whereas void means it accepts NONE
{

}
Last edited by Toxic ; 07-19-2016 at 11:35 AM.

The following user thanked primetime43 for this useful post:

01cedricv2
07-18-2016, 05:04 PM #2
01cedricv2
NGU Elite Lifetime Mermber
I rate it 10/10! Now the Newbs cant come over to anyway and ask "How can I create a C Program?" :salll:
07-20-2016, 02:02 AM #3
Jim Halpert
Bounty hunter
Originally posted by primetime43 View Post
Hey there NGU, so today I'm going to show you guys how to make a program in C, even though there isn't any C template option.

First off, open Visual Studio and then go to click on new project. (File > New > Project). Which will then bring you to this:
You must login or register to view this content.

At this page, click next and then select the options and make your screen like the picture below:
You must login or register to view this content.
Once at this page, go to Templates > Visual C++ > then once in there, select Win32 Console Application (as seen in the picture above. Also feel free to name it and custom it's save location etc.) Once done with that click OK and you will then be taken to this page here:
You must login or register to view this content.

Once at this page, click next and make your screen look like the picture below with the same options selected etc:
You must login or register to view this content.

Once you have done that, go ahead and select finish and your screen will look like this:
You must login or register to view this content.

Now to create the C file, (make sure you have the ConsoleApplication name highlighted blue when you go to do this) you want to go up to Project > Add New Item and this screen will appear:
You must login or register to view this content.

Have the C++ File option selected like above in the picture and where it says name, all you need to do is make sure you have it like this: FILENAME.c because if you make it have a .cpp extenstion, that means it's a C++ file. Then select done and your file will be created and then you can go ahead and begin coding in the C file. Here's some code you probably would want to use if you're following this:
    
int main(void) //for those who don't know, you put void in here because if you don't that means the method has unlimited arguments, whereas void means it accepts NONE
{

}


If I'm not mistaken, won't the C++ compiler still be used for such a program as you have selected a Visual C++ Console Application? I feel like even though you made it a C source file, you still need to change the compiler. I could be wrong.
07-20-2016, 02:20 AM #4
primetime43
Knowledge is power Tiphat
Originally posted by Jim
If I'm not mistaken, won't the C++ compiler still be used for such a program as you have selected a Visual C++ Console Application? I feel like even though you made it a C source file, you still need to change the compiler. I could be wrong.


Yes but it doesn't matter. The program still compiles and runs fine because the c++ compiler is able to compile C because c++ came from C obviously, so it's sort of like a backward compatible type thing.
07-20-2016, 02:25 AM #5
Originally posted by Jim
If I'm not mistaken, won't the C++ compiler still be used for such a program as you have selected a Visual C++ Console Application? I feel like even though you made it a C source file, you still need to change the compiler. I could be wrong.


I guess VS just knows, I'm sure they just check the extension.
You must login or register to view this content.

The following user thanked John for this useful post:

Jim Halpert
07-20-2016, 08:39 AM #6
Originally posted by John View Post
I guess VS just knows, I'm sure they just check the extension.
You must login or register to view this content.


Yes, Visual Studio can detect if it's C or C++.
You can also change the compiling settings in your 'Project Properties'.
07-20-2016, 05:27 PM #7
Jim Halpert
Bounty hunter
Originally posted by John View Post
I guess VS just knows, I'm sure they just check the extension.
You must login or register to view this content.


Nice going Jan.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo