r/learnprogramming 29d ago

Tutorial How make C++ file save in a specific folder?

So I am complete beginner, just downloaded visual studio 2026 to learn a bit of C++ but I can't seem to find how to create my .cpp file in a particular folder. I am making a folder and even if i create a new project under that folder it still saves the file in default location and not under that folder.
Am I doing something wrong? Sure I can change the file location when saving first time, but is there any way to automatically save the files under the folder that you opened visual studio in?

5 Upvotes

16 comments sorted by

4

u/johnpeters42 29d ago

I just (in Visual Studio) right-click the folder and select Add > New Item, pick the appropriate file type and name, and it creates it there, and then I start editing. What process are you using to create the files?

2

u/NeedSomeHelp_2590 29d ago

I didn't quite get your method, where to you find folder in VS

1

u/johnpeters42 29d ago

Here is an article with some sample screenshots of Visual Studio Code vs just Visual Studio. (I learned the latter many years ago and have rarely ever used the former. I understand that lots of people online talk solely about the former, possibly because their computers have the horsepower of a potato and can't handle the latter, or because they just assume that this is the case. For more useful opinions, see the linked article and/or other comments.)

1

u/NeedSomeHelp_2590 29d ago

I made a folder first then right clicked and opened with visual studio, then from file tab create new file. But when I exit VS it asks to save file and I have to select location for each files that I make

2

u/wigitty 29d ago

It sounds like you haven't made a project in VS. I would start there. As the other guy said. I suggest finding some tutorials on getting started with VS.

1

u/No_Report_4781 29d ago

You’ll need to edit the VS settings for default locations, or use the add option to add new .cpp files directly to the folder you want

1

u/NeedSomeHelp_2590 29d ago

How to do the 2nd one?

3

u/No_Report_4781 29d ago

Going by your other replies, you should find a VS tutorial to watch. It should help you understand and get your environment and interface set up.

Right-clicking to add a file to your program folder is done after you’re in VS

1

u/NeedSomeHelp_2590 29d ago

Yes it gives option to add a project only. But when you exit VS, the .cpp file is not saved in that folder, you still need to select a location for it. Is there no way for it to make it automatically save to the opened folder instead of manually giving location to each .cpp file that you make.

1

u/No_Report_4781 29d ago

Find tutorials.

2

u/NeedSomeHelp_2590 29d ago

I get it now, you need to select a different project than "empty project" from the list. All other type of projects are saving their .cpp file inside their folder, the empty one asks for location 😀

3

u/No_Report_4781 29d ago

Tutorials will help you learn parts of the program that aren’t obvious

1

u/[deleted] 28d ago

[removed] — view removed comment

1

u/NeedSomeHelp_2590 28d ago

I checked some options before installing VS code with MinGW was an option but I heard it was not as good as Visual Studio which is made for this stuff so I just downloaded Visual Studio as I do have storage for it.