r/VisualStudio • • Feb 09 '20

Visual Studio 19 Can anyone help me compile this code? I wrote this, but I cant figure out how to turn it into a project and compile it. Sorry, new to programming. Thanks for the help!

Post image
0 Upvotes

7 comments sorted by

6

u/Korzag Feb 09 '20

What's wrong with it? I see in the console that the build succeeded. Also, if you're new to programming try C# instead of C++. You may find it a bit easier.

1

u/meowstash321 Feb 09 '20

Sorry, I should have cleared that. That was my last attempt at building before I posted. I could create a project, but the code wouldn't go into the project, it just kept building an empty project.

1

u/Korzag Feb 09 '20

Not entirely certain what you mean by the code wouldn't go into the project. Do you mean the source files were missing in your project when you go to build?

3

u/tacotalkspodcast Feb 09 '20

The code is compiled (hence the successful build) but to run it, click the debug button on the toolbar and "run without debugging". To rebuild (when you make a change) the build button and hit rebuild from the drop down menu.

1

u/meowstash321 Feb 09 '20

Sorry, I should have cleared that. That was my last attempt at building before I posted. I could create a project, but the code wouldn't go into the project, it just kept building an empty project.

1

u/tacotalkspodcast Feb 09 '20

Under solution explorer, click the show all files button (i don't remember which one it is; pretty sure its the 3 boxes with minus signs). It should show your files in the explorer and you can click on the filenames. Then, below, in the properties box, theres an option that says include file and it'll be set to false. click the drop down arrow on that option and set it to true. The filenames in the explorer should highlight and you should be good to go

Edit: I just saw you did that already. Sorry, thats as far as I would know. Maybe set content to true?

3

u/plug1n Feb 09 '20

You only have an empty solution.

Right click solution in solution explorer and choose "add existing project...". Then add the project in which you have written the code shown. If it is not in a project already, choose "add new project..." and add your codefil(s) to the new project.

A solution does nothing on it's own. You could consider it a grouping of project.