Can I use Microsoft Visual Studio For coding C ?

In summary: And if you're not careful, it can damage your computer.Is it possible that it can harm my computer If I do smthing wrong in the downloading process ? How can I download and run it safely ?İt is possible that you could harm your computer if you do something wrong while downloading Vis. Studio, but there are a few ways to minimize that risk. First, be sure to read the instructions carefully. Second, make sure you have the latest antivirus software installed and up to date. Third, make sure that you have backed up your computer in case something goes wrong. And finally, be sure to take precautions such as not downloading anything from untrusted sources.In summary,
  • #1
Arman777
Insights Author
Gold Member
2,168
193
I will take Intro to C programming this semester and can I use MVS for coding C ?
 
Technology news on Phys.org
  • #2
Arman777 said:
I will take Intro to C programming this semester and can I use MVS for coding C ?
Yes. I use it for both C and C++ programs.

A C program should have a name with a file extension of .c. The extension for C++ programs is .cpp. There are also some switches in the property pages for your code to specify which language, but the easiest way is to use the file extensions I listed.
 
  • Like
Likes harborsparrow and Arman777
  • #3
Is it possible that it can harm my computer If I do smthing wrong in the downloading process ? How can I download and run it safely ?
 
  • #4
Arman777 said:
Is it possible that it can harm my computer If I do smthing wrong in the downloading process ? How can I download and run it safely ?
I haven't heard of anyone having something go wrong when they downloaded Vis. Studio.
 
  • Like
Likes Arman777
  • #5
Mark44 said:
I haven't heard of anyone having something go wrong when they downloaded Vis. Studio.
İnstructor shared a link for to run C in MinGW. But I couldn't download it from there cause its too complex .
http://mingw.org/wiki/Getting_Started
"After installation you will need to perform some additional tasks yourself to ensure your MinGW applications will run. Most importantly, you will need to make changes to your PATH environment variable. Be careful: there are two PATH variables which can be changed, and changing the wrong one can have significant consequences. Instructions for changing the correct PATH variable are provided below."

And many more warnings etc. I guess there's no such needs in MVS
 
  • #6
Simply download cygwin. It is a windows app. It acts like linux. Free. https://www.cygwin.com/

If you cannot do that and you are on Windows 10, then you can get an Ubuntu Linux app. Free. Install WSL from Microsoft.

In either case you need to understand that Windows text files have a line ending (carriage control) of ASCII 10, and ASCII 13. Two characters usually noted by "\n" and "\r". (\r shows in UNIX editors as "^M" which is a red flag.)

Ubuntu and cygwin use ONLY "\n". In Linux speak, this is called a UNIX file, the other one, "\n\r", is called a windows file. Most editors will change a text file to either one. If you use a windows editor, then compile it in Linux you will get a bunch of errors because of the wrong line ending. So fix the type of file first. Then, no errors.
 
  • #7
If you do use GCC, consider using the editor SciTE. If you turn on line numbering it'll make debugging very easy because GCC has very good error messages when you use -Wall -Wextra -pedantic. I suppose the one challenge with GCC is you need to learn how to write a Makefile but that is not hard to do and once you have the file, you can always reuse it. (A Makefile is like the solution in Visual Studio. It references all the files of your project and compiles it in the correct order to produce the executable.)
 
  • #8
I need some good explaining videos for these possible C IDE s.
 
  • #9
Arman777 said:
I will take Intro to C programming this semester and can I use MVS for coding C ?

I agree with @Mark44 that you can download and use it with no problems. It is a good super-IDE but just try to stay focused on your code and learn the extra IDE features with patience. Many years before I was using DevC++ and it was good enough for educational purposes as well as for building some open source software.- more recently I had installed a fork with C++11 support. There is a relatively new release at SourceForge.net .

Arman777 said:
İnstructor shared a link for to run C in MinGW. But I couldn't download it from there cause its too complex .
http://mingw.org/wiki/Getting_Started
"After installation you will need to perform some additional tasks yourself to ensure your MinGW applications will run. Most importantly, you will need to make changes to your PATH environment variable. Be careful: there are two PATH variables which can be changed, and changing the wrong one can have significant consequences. Instructions for changing the correct PATH variable are provided below."

And many more warnings etc. I guess there's no such needs in MVS

I always liked to tinker with tool chains particularly of GCC, as a way to learn and set up things exactly the way I like. The same holds for maintaining and modifying if necessary the PATHs of Windows, as for a lot of other Windows OS things. But these don't come as suggestions without warnings. If you really like to do it this way - even independently of Microsoft Visual Studio, you have to study through resources, references and tutorials and do things in a safe way without putting anything at stake. If you're aiming to be a good programmer or software developer, I would also recommend to learn to program on a Linux distro besides Windows.
 
  • #10
I did a bit research and find that Code Block is best for beginners. I downloaded it and I can manage to use it

I downloaded the MVS and tried to use it but some problems came up which I don't remember now. But maybe I download it later. But for now I think Code Block is nice and have much simpler user interface for me.
 
  • Like
Likes symbolipoint
  • #11
I installed VC++ because I wanted to see how easy it was to set up but I can't get it to work right either. For example, I tried to #include <stdio.h>; and it complains, but #include <cstdio>; doesn't.

@Mark44, can you elaborate on what settings need to change to enable C in the most compatible way possible? Thanks.
 
  • #12
verty said:
I installed VC++ because I wanted to see how easy it was to set up but I can't get it to work right either. For example, I tried to #include <stdio.h>; and it complains, but #include <cstdio>; doesn't.

Assuming that you have installed the Visual C++ redistributable for Visual Studio 2017, you can create "New Project" > "Visual C++" > "Win32 Console Application" >"Next" > "Console Application" and "Empty Project". Now, click "Finish" and add a new source file from the relevant menu and give your source file name the .c extension, ignoring the options displayed. Hope this helps.

As for <cstdio>, it includes <stdio.h> and adds the associated names to the std namespace. Here's the relevant Microsoft web page.
 
  • #13
QuantumQuest said:
Assuming that you have installed the Visual C++ redistributable for Visual Studio 2017, you can create "New Project" > "Visual C++" > "Win32 Console Application" >"Next" > "Console Application" and "Empty Project". Now, click "Finish" and add a new source file from the relevant menu and give your source file name the .c extension, ignoring the options displayed. Hope this helps.

As for <cstdio>, it includes <stdio.h> and adds the associated names to the std namespace. Here's the relevant Microsoft web page.

Thanks. It was my fault in the end, I deselected a bunch of stuff in the installer, too many in fact, but adding them back left the solution in a confused state. I had to delete it and create a new solution and it's now working properly. I think I prefer Code::Blocks (I tried that after Arman mentioned it) because it's closer to how it is on Linux. The one difference I see is it uses g++ to link the executable like so: g++ -o myapp.exe main.o. But otherwise it's just like it is on Linux which should be very compatible with his class although from what I can tell, adding main.c to an empty project in MSVC is working fine as well.

@Mark44, there's no need to reply because I've got it working. It was my own fault in the end for trying to make the install smaller.
 
  • #14
verty said:
@Mark44, can you elaborate on what settings need to change to enable C in the most compatible way possible? Thanks.
Once you have loaded your project in VS, open Solution Explorer, if you don't already have that as a pane that is showing. To open the Solution Explorer pane, under View, click Solution Explorer.

Select the source code file in your project (I'm assuming you have only one source code file). From the right-click menu for that file, choose Properties, the last selection in this list. This opens a dialog box labelled <File name> Property Pages.

In the left pane at the top level it says Configuration Properties. Under that there are two headings: General and C/C++. Expand the C/C++ heading. Two up from the bottom is Advanced. One option there is Compile As, which normally has Default as the option. Change this option to Compile as C Code, if that's how you want your code to be compiled. After that, click OK if you're done, or Apply if you want to change some other settings and aren't ready to close the Property Pages.

As I understand things, the usual setting of Default causes source files whose extension is .c to be compiled as C code, and files with a .cpp extension are compiled as C++ code. If you manually change the Compile As setting as described above, you can choose which back end does the compilation regardless of the file extension you have used -- I believe.
 
  • Like
Likes verty and jim mcnamara
  • #15
Arman777 said:
I will take Intro to C programming this semester and can I use MVS for coding C ?
Just FYI, C coding is what MVS started with and it has never been left out. As for installations, I've installed many versions on several different machines and have never had the least bit of problem. It's really wonderful that MS now gives away the full version to individuals. I've paid out quite a bit for versions over the years (I've been using it from the beginning) and I was delighted when I found that it's now free.
 
  • Like
Likes aaroman, QuantumQuest and jim mcnamara
  • #16
I use Visual Studio desktop express 2015, which is the last version before Microsoft switched to the community version. You can start here to download an "older" version:

https://visualstudio.microsoft.com/vs/older-downloads

Either way, you'll need to create a Microsoft account. If you're running Windows XP or XP X64, then the latest version of VS that will run on XP is Visual Studio C/C++ express 2010 (instead of desktop express). VS2010 is available as an ISO file. I don't think you need a Microsoft account to use VS2010.

Note that Microsoft's C compilers are essentially C89 compliant, not C99 or later. I'm not sure of the differences. Some C compilers allow variable length arrays (VLA), but even C++ standards don't support VLA, so I would avoid it. If you want a stack based array, you can use _alloca() with VS (it may be called alloca() for other compilers), but be aware if that if a stack based array is too large, you can get a stack overflow error.
 
  • #17
Thinking of C again reminds me of when I learned to program using Turbo C++. The help pages were very good and I've liked C languages ever since. I particularly like how everything is pretty easy to do if you know what function to call. Functions like memset, memcopy, etc, don't seem to exist in other languages. And I like how pointers work like arrays. And you can pass by reference by using the address-of operator (&). And of course it has the switch statement that has made it into almost every language but not Python for some reason. So I do like C and this was a nice reminder, seeing if MSVC could work in a compatible way. So thanks.
 
  • #18
Visual Studio is very good and stable. It installs easily. I would suggest you go with it if you are willing to learn to use it. You might need to get a book (used on Amazon, where you can see reviews of the books) to get familiar with its interface. I've used a bunch of those cygwin and other tools and much prefer Visual Studio.
 

1. Can I use Microsoft Visual Studio for coding C?

Yes, Microsoft Visual Studio is a popular and widely used integrated development environment (IDE) that supports the coding of C programs. It offers a variety of features and tools to make the coding process more efficient and effective.

2. Is Microsoft Visual Studio free for coding C?

Yes, Microsoft Visual Studio offers a free version called Visual Studio Community Edition, which includes all the necessary tools for coding C programs. However, there are also paid versions available with additional features and support.

3. What are the advantages of using Microsoft Visual Studio for coding C?

There are several advantages to using Microsoft Visual Studio for coding C, including its user-friendly interface, advanced debugging capabilities, code completion and suggestion, and support for various programming languages.

4. Can I use Microsoft Visual Studio for coding C on different operating systems?

Yes, Microsoft Visual Studio is available for both Windows and Mac operating systems. However, some features and tools may differ between the two versions.

5. Can I use Microsoft Visual Studio for coding C in a team environment?

Yes, Microsoft Visual Studio offers features and tools designed specifically for collaborative coding, such as version control and code review. It also supports integration with other team collaboration tools.

Similar threads

  • Programming and Computer Science
Replies
0
Views
250
  • Programming and Computer Science
Replies
3
Views
4K
  • Programming and Computer Science
Replies
2
Views
321
  • Programming and Computer Science
Replies
1
Views
274
  • Programming and Computer Science
Replies
3
Views
682
  • Programming and Computer Science
Replies
5
Views
389
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
11
Views
2K
  • Programming and Computer Science
Replies
25
Views
14K
Back
Top