I want to know how to get started to make a program in C++. I have read up on the material and I just don't know where to go from there. i would like the program to work on a windows platform.

14 Years
Discussion Span
Last Post by liliafan

well... maybe you haven't read enough... you should start with the simplest program in c++, the "Hello World!" program. you must first #include any header files you need for the specific program, usually <iostream> is used for inputing and outputing. then you must make your int main() function, this is the function where the program starts and ends and must always return 0;... if it returns anything else, the program will not work. then you must start the main function with the opening bracket, {. then you put your lines of code usually followed by a semicolon, ;. then you have to return something because the main function is of int type. so you must have the line return 0;. then you must end the main function with the closing bracket, }.

#include <iostream> 
using namespace std;
int main()
	 cout << "Hello World!";
	 return 0;

kind of a bad little tutorial but yea.
study the code, understand what each component does and then and only then, continue with c++... good luck


I want to know how to get started to make a program in C++. I have read up on the material and I just don't know where to go from there. i would like the program to work on a windows platform.

Which compiler are you using?



It sounds like you are just learning how to code. Welcome to a wonderful world of coding, debugging, and upkeep.

As long as you are just starting, you may want to remember a few things..... this will help you in the long run:

1) COMMENT. Write out in comments what you want that segment of code to do. Don't think it is silly or redundant... not even COBOL is super descriptive of what the code below should be doing. In your comments, put down what the variables represent, and what you want the code to do with them. Also, as you maintain the code, update your comments.

2) STYLE. Choose names of variables that mean something. For example, if your variable represents an amount of beans in a jar, call that variable beansinjar or something like that. Be careful of case sensitivity... depending on compilers, beans and BEANS could be different variables. Also, space your code out, and use the tab key to block out functions and loops. Your code should be easy to read.

3) FUNCTIONS DO SMALL THINGS. Do not overload what a function does, or you will remove flexibility as the code developes. Have each function only do one small part of the puzzle. A function might open a file, or output to the file. Don't try to have the function save the day.

4) ERROR-CHECK your input values. Don't assume good data will flow into your system. Check for data out-of-bounds, or for numbers that should be letters, etc. Wrong data will just blow up the program (best case) or will allow it to work with garbage results (worst case), as you will get results, but have no idea that the computations may be wrong.

As you continue to code, you will develop wisdom and templates on how your code will grow.

Good luck!



Thanks for the tips. I have read up on all the material and I just don't know how to apply it. I have been writing little programs for a PIC microprocessor but I want to get into deving applications for the computer. My compiler is the Bloodshed Dev-C++ because it is free and I didnt want to spend a lot of money.


dev-c++ is cool that is basically gnu gcc ported to windows, if you copy the example from bleek and paste it into your ide , you can then click the "play" button to execute it, it will then compile and run the program, if you want to properly compile you will find the compile command in one of the menus at the top, then just add to that program and play about.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.