Visual Studio C++ - running separate .cpp files? - c++

I just started using Visual Studio (Enterprise), more specifically C and C++ Programming. I was wondering, since I'm using mainly simple C programming and nothing OOP, is it possible to have multiple .cpp files in the same solution and/or project, and compile/run them separately.
I have a lot of C programs to write and I'm hoping I won't have to create a whole solution for each simple main function. I know this might be a dumb question but I'm still new to the structure of Visual Studio, any help would greatly appreciated.
Thanks.

You have to create a single solution with multiple project. Each project has its own main.
This is a weakness of visual studio, you can not create a project with several main.

Related

I want to learn how to create and compile multiple files in one c++ project using visual studio code

I'm a beginner learning to code in C++
I use Windows 10 to learn code
I want to learn how to create, link and run multiple files in Visual Studio Code.
I'm currently learning on Codecademy
I'm stuck on the Header section where they teach you how to link multiple files.
here is the link for that section:
https://www.codecademy.com/courses/learn-c-plus-plus/lessons/cpp-functions-scope-flexiblity/exercises/cpp-functions-header-files
Problem:
I want to practice using Visual Studio Code but I don't know how to link or make header files and I'm not finding any tutorials and I'm at a sticking point.
Progress:
I know how to create a Make file but I don't know how to create, open and link multiple new files and use them in a Visual Studio Code
Can anyone show me how to do this

Exporting/publishing a C++ program?

I have made a simple game in VS 2012 using C++, and I am just wondering if it is possible to "export" or "publish" the project so that is possible to use using a single .exe anywhere on a computer, rather than the whole debug folder that includes all the pictures I have used.
Many thanks!

Best way to save source functions

Newbie question: I've been trying to complete a couple of problems from the Project Euler site, using Visual studios 2010 as my IDE.
What is the best way for me to save and store the source so that I don't have to have 500 projects created?
Create a function for each problem, then just change which function you call from main.
The best way to "save" source code is in a version control system. My preference is Git.
I haven't used Visual Studio 2010 in anger, but I'm sure you can have multiple source files in a single project. You don't need to create one project per problem (although it may be a neat

Default project in Visual C++ 2008

In Visual C++ 2008 ( Professional Edition )it is impossible to create default project for a .cpp file. Sometimes it is inconvenient. Is there an edition of Visual C++ 2008 which allows it?
It's available, assuming you've already written the .cpp file. Use File + New + Project From Existing Code. You'll get a point-and-click wizard with a bunch of questions that need to be answered.
I reckon you'll use this a few times, then discover it is just simpler to start a new project from scratch with the Win32 Console Application template. Just add your .cpp to the project's Source Files folder.
Why you can't do this?
You can normally create Win32 C++ project and have with this .cpp file.
You mean you don't want to create a solution each time? There's no getting around this. It can be useful to create a Sandbox solution and just fill that up with .cpp files to throw your ideas around on.

Using Tortoise SVN with C++ in Visual Studio 2008

I have an online repository with some .h and .cpp files that make up part of a project. I'm trying to check these out and use them in a new project, but am getting errors (C4627 and C1010). All the files have been added to the project (with Add>Existing Item...), and the subdirectories that contain these files have been added to the "Additional include directories" of the project.
Would I be better off having the entire project tree in the repository? My reason for not doing so is that my colleague and I are working on different parts of the code and so want to use different main methods to test things as we go, and I didn't see any need to be passing around any compiled code etc. since I assumed that given the .h and .cpp files (with the correct settings), visual studio would be able to compile the project.
What's the best way to make Visual Studio 2008 and TortoiseSVN work well together (without spending any money)?
Would I be better off having the entire project tree in the repository?
Most certainly yes. You should be able to check out and build without much effort. Creating a new project every time you want to build the source and having to configure it is way too much work.
My reason for not doing so is that my colleague and I are working on different parts of the code and so want to use different main methods to test things as we go, and I didn't see any need to be passing around any compiled code etc.
Ok, just put more than one project in the solution. There's no reason you can't have separate executable projects for separate tests.
I assumed that given the .h and .cpp files (with the correct settings), visual studio would be able to compile the project.
If all of the settings are the same, then, yes, it should compile fine, but why bother with the hassle when you don't have to?
Also AnkhSVN which isn't too bad and it's free. Also, lots of the windows it displays look like TFS (if you're familiar with it)
What's the best way to make Visual Studio 2008 and TortoiseSVN work well together (without spending any money)?
There are a bunch of programs that integrate SVN into Visual Studio. VisualSVN is one of them.
Apologies for the VisualSVN recommendation. We used to use it in an old project and I'm positive it was free then. Maybe they changed their license?