Hello, I would like to learn C++ but have No idea where to start. What is a good tutorial to watch? What should i download? All i have right now is Microsoft Visual C++ Express 2010. Also, When i take the code
1 2 3 4 5 6 7 8 9 10
// my first program in C++
#include <iostream>
usingnamespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
In notepad, save as .cpp, and open it, it just brings me to the MS visual thing,
again, i have no idea wjat i'm doing, all help would be appreciated
You need to create an executable before you can run your code, which involves compiling your code and linking it. You already have Visual C++ which handles all of this for you. To make a new project in Visual Studio go to File->New->Project and the New Project wizard should open. Then go to the General Tab and select "Empty Project." Give your project a name and choose wherever you want it to be saved. Once the project is open look in the solution explorer (if you can't view it go to View->Solution Explorer at the top of the screen). You should then see four folders, External Dependencies, Resource Files, Header Files and Source Files. Right click on the Source Files folder and select Add->New Item. Then click the Code tab and select "C++ Files (.cpp)." Name the file either main or the title of your project. Then type in all of your code. Once all the code is typed in press Ctrl-F5 to run the program! You can also press just F5 to run the program, but if you press Ctrl-F5 Visual Studio will add a "Press any key to continue. . ." message at the end of the program to keep the window from closing immediately.
Hope this helps! Don't worry about all the other folders, file types and options. When you're starting out in C++ what I've just explained should be more than enough to get by. Once you get to adding classes, making windows forms, using the MFC or making C++/CLI programs the rest of these options within the IDE will make sense and you'll see how powerful Visual Studio can be :-)
Ok that helped, thanks. But i did everything you said, and then when i hit F5, i got something that said this project is out of date would you like to build it? i hit yes, then hit F5 and all i got was a cmd pop-up that is too quick for me to read, is that what is supposed to happen?
1. Create new project
2. Select C++, Win32 console project
3. In the wizard, check "Empty Project"
4. make a .cpp file in the sollution explorer (docked at left)
5. open it and put your code in it.
6. Hit F5.
I would use a system"pause"); before you return 0, as it will stop the console from exiting. Be warned, it's not advisable to use system functions when you get past writing them for educational purposes and debuging.
@funcode, where did he explain? I don't see it.
@GiseleAune Could you explain what a system pause is and how to use it? This is my first day learning this, sorry
Ok, i've done ALL that. All that happened is the little cmd popup for half a second. What do i do when i get a popup saying the project is out of date? Do i say Yes or No to the option of building it? i've tried both to the same result. I'm sorry for taking up your time.
When i hit F5, the text will pop up in a cmd-like box. But it flashes so quickly, and only once. how do i make it stay? you said Ctrl+F5 but that is not working for me.