1.1. How to Write a C++ Program
We’ve been asked to write a simple program to write a message to the user’s terminal asking her to type in her name. Then we read the name she enters, store the name so that we can use it later, and, finally, greet the user by name.
OK, so where do we start? We start in the same place every C++ program starts — in a function called main(). main() is a user-implemented function of the following general form:
int main() { // our program code goes here }
int is a C++ language keyword. Keywords are predefined names given special meaning within the language. int represents a built-in integer data type. (I have much more to say about data types in the next section.)
A function is an independent code sequence that ...
Get Essential C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.