Daniel Daniel - 3 months ago 14
C Question

Visual Studio Compile Separate Files

I am new to Visual Studio and wanted to ask: how can I compile 2 separate files independently? eg. Having Problem1.c(with its main and other functions) , Problem2.c(with its main and other functions) and I want to run them independently, but in VS they are both added to Solution Explorer and create a conflict.

Answer

I think you need to make a "project" for each.

That sounds like a lot of work for simple work. You can also make one project with one main and have that call a function in each of your problem files .c in which you implement the problem.

You can use the command line to tell which function (problem) to call, or you can adapt main each time you need to implement a new problem.

That saves you the overhead of creating a project for each problem and lets you quickly start working on implementing a new problem.