-
C++ beginner
Hello
I just statred to learn C/C++ and I am using MS Visual compiler.
The problem i am haveing is that i do not fully understand how to save/ start my programs in a file.
i understand how to use
#include<stdio.h>
void main (void)
as my book tells me to start the program, but I dont know how /were i am saving the programs to.
Please help me to understand (directories) i think.
-
First off: Its 'int main(void)' not 'void main(void)'. Main should always return a value.
Anyhow, to create a new project go to File->New. A window will pop up with a few different options of what type of project you want to create. It sounds like you would most likely want 'Win32 Console Application' which is I believe third from the bottom. You will also have to enter a name for your project (in the text bar to the right) and the location on your Hard Drive you wish to save it to. I would create a directory specifically for my applications, such as 'C:\MyApps'. Once you're done click OKAY and it should ask you if you want your application to be empty, or some other crap. Select empty (what a stupid option).
Bingo. Project is made. Now you will either have to add a new file that you've made before or you can create a new one. Chances are you'll want a new file so select File->New again and select 'C++ Source File' or 'C++ Header File' from the list depending on what you want.
Ready to go. Use File->Save and File->Save Workspace to save your project and your file. Use File->Load Workspace to open it back up again later. Visual C will automatically open your most recent project when you run it the next time tho.
Hopefully that helped.
-
When you create the workspace, pay attention to where it is created. Then when you hit save, the .cpp file & .h files will be saved into that directory. For instance, if you go to File>New, then click to the second ( Projects ) tab, then choose Win32 Console Application, then choose a project name ( edit box top right corner ), then choose Location ( edit box below project name ), this will be the location that all files for this program will be saved. Each new program will require a new project workspace. Good luck.