Programming in C


Programming in C++

Let's analyze the program we wrote in Listing 2.2. We're going to ignore the first five lines of the listing. For now, we'll just jump down to line 6, which is the beginning of the main() function.

The main() Thing

The main() function includes everything from line 6 through line 21. main() is the program entry point. That's a fancy way of saying that the main() function is the place where your C++ programs start executing. The program starts at main() and executes one statement after another.

Actually, I should be more specific. When a C++ program executes, it starts with the first statement inside the main() function. The statements inside the main() function are all contained within the opening and closing braces, which are the symbols { and }.

Note

Notice that every statement in the main() function in Listing 2.2 ends with a semicolon. Almost all statements in C++ must end with semicolon. I'll point out the exceptions as we go along.


The left brace appears on line 7. Programmers often call it the opening brace of the function. The closing brace, which of course is the right brace, appears on line 21. All statements in the main() function must appear between the opening and closing braces. The first statement in main() is the declaration of a variable. The next section explains exactly what that means.

Compiling the Example Programs Yourself

As mentioned previously, you'll find a folder for every example program in this chapter on the CD in the \Source\Chapter02 folder. There's also a folder in \Source\Chapter02 called Bin. The Bin folder contains the compiled executables for every example program in chapter 2. However, if you would like to compile these programs yourself, use the following procedure:

1.

Create a folder on your hard disk for the program. You can put it wherever you like.

2.

Copy the .cpp file you want to compile into the folder you just created.

3.

Create a project for the program by starting Dev-C++ and selecting File from the main menu. Next, select New and then Project. All of the programs in this chapter are console programs, so choose Console Application. In the Name box, type the name of the project. In the dialog box that appears, navigate to the folder you created in step 1 and save the project there.

4.

From the File menu, select Close to close the edit window.

5.

In the pane on the left side of the Dev-C++ window (this is called the Project pane), you'll see a folder with a plus sign on its left and the name of the program on its right. Click the plus sign. When you do, you'll see the filename main.cpp. Right-click that filename and select Remove File from the menu that appears.

6.

Right-click the folder in the Project pane and select Add to Project from the menu that appears. This displays the Open File dialog box.

7.

In the Open File dialog box, navigate to the folder you created in step 1 and select the .cpp file you copied into it in step 2.

8.

From the Execute menu, select Compile & Run. The program compiles and then runs.


Variables

Line 8 of Listing 2.1 declares a variable. Think of a variable as simply a container, much like a mailbox. People put mail in mailboxes and take it out later. Each mailbox has an address. Variables work very much like that. Every byte in your computer's memory has an address, which is a number. Memory addresses can be specified either in binary or hexadecimal. Hexadecimal is yet another number systemit's base 16.

You and I are humans. We don't want to work with binary or hexadecimal address numbers if we can avoid it. It's far easier for us to give a memory location a name and use that instead of an address. We can let the compiler translate the variable name into an actual address in memory. Again, it's much like a mailbox. After a mail carrier has been on a mail route for a long time, she knows that the address 1234 South 5th Street is where the Wobbenflatz family lives. When she sees a letter for the Wobbenflatzes, she can put it in the right mailbox without having to look up the address. She uses the name Wobbenflatz for the mailbox rather than the address 1234 South 5th Street. You and I do the same with variables in programs. We use the variable names rather than the addresses because they're easier for us to deal with.

The variable on line 8 is called yourName. It's a spot in memory where the program stores your name. And once again, it works very much like a mailbox. The program can store your name in the variable and leave it there like people store mail in mailboxes. Later, when the program needs the data, it pulls the data out of yourName just as you'd retrieve your mail.

Notice that the variable name yourName describes the data that gets stored in the variable. All variable names should be like this. Variable names must conform to the following rules:

Variable names must start with a letter. The letter can be uppercase or lowercase.

Most compilers let variable names be as long as 128 characters; some allow them to be longer. However, virtually all compilers require that all variable names be unique in the first 32 characters. So if two variable names use exactly the same letters in the same order for the first 32 characters, the compiler sees them as the same name. It does not check any more than 32 characters in the name.

After the first character, variable names may contain any letter or number.

Variable names can also contain the underscore character (_).

Variable names are case sensitive. Therefore, yourName is not the same as YourName or YOURNAME. The compiler sees these as three different variables.

C++ commands, which are called keywords, cannot be used as variable names. We'll talk more about C++ keywords later.

Every variable must have a data type. More on this in a moment.

Spaces are not allowed.

If your variables do not follow these rules, your program won't compile.

As noted above, every variable must have a data type. The data type specifies exactly what kind of information the variable can hold. For instance, the variable yourName on line 8 of Listing 2.2 is of type string. A string is a collection of characters, such as the upper- and lowercase letters of the alphabet. As you read through this book, you'll see data types that contain integers, floating-point (real) numbers, logical values, and many other kinds of data. When you declare a variable to store each of these different kinds of data, you must specify the appropriate data type. Table 2.1 shows many of the variable types that are built into C++.

Table 2.1. The Most Common C++ Built-In Data Types

Type

Description

int

Integer. A number with no decimal point. The values 0, 1, -57, and 1000 are examples of integers. Integers usually contain 4 bytes of data.

short

Short integer. Same as an integer, but it usually contains 2 bytes of data.

long

Long integer. Same as an integer and usually contains 4 bytes of data, but with some compilers, it can contain 8 bytes of data.

unsigned

Unsigned integer. Can only contain values that are greater than or equal to 0. The unsigned integer usually contains 4 bytes of data.

float

Floating-point number. A number with a decimal point. The values 0.0, 1.2,0.00012345, and -10.5 are all examples of floating-point numbers. Floating-point numbers usually contain 4 bytes of data.

double

Double-sized floating-point number. Same as a floating-point number, but it usually contains 8 bytes of data.

char

Character. Contains characters. The char type contains 1 byte of data.

bool

Boolean value. Can be set to either true or false. The bool type usually contains 1 byte of data.


Notice that the type string is not in Table 2.1. The string type is added on by the C++ Standard Libraries. The C++ Standard Libraries contains a huge number of very useful types. We'll discuss some of the most common as we write our example programs. You'll find more information on the C++ Standard Libraries in the books listed in Appendix C.

You may be wondering if you have to use the style of variable name that I use in this book. The answer is no. C++ does not force you to use a particular style of variable name. As a result, you can create names such as yourName, your_name, YourName, and YOURNAME in your programs. This leads to confusion for new programmers.

Some common questions they ask are:

What letters should I capitalize and what should be lowercase?

Should I use underscores?

Do most people use the style in this book?

Should I use Microsoft's Hungarian notation?

The most common style in C++ programming is the style I used in Listing 2.2, which is called camel notation. In this style, the first word of the variable is lowercase. All subsequent words start with capital letters.

Note

There are other data types built into C++ that are not presented in Table 2.1. I'll discuss them later as needed. These are the data types that you'll use most often in your games.


I strongly encourage you to use camel notation. Programmers tend to use it because everyone recognizes that anything in that notation is a variable. It's often the case that many programmers are working together on games. Other programmers on the project can just look at a variable name in camel notation and tell it's a variable. That helps clarify what they're reading.

Other variable name styles do exist. The one you'll run into most often is Microsoft's Hungarian notation. They created it for the C programming language, which was the language that C++ is based on.

Hungarian notation puts an abbreviation at the beginning of the variable name that describes what type of data is in the variable. For example, a string variable would be sYourName. However, for reasons that have to do with the C++ language, it could also be strYourName, cpYourName arrYourName, or even bpYourName. This shows one of the big problems with Hungarian notationit's not standardized in the least.

Hungarian notation made sense in C, but it is not useful in C++ for a lot reasons that I won't go into now. I'm just going to say that in C++, Hungarian notation causes more problems than it solves. You'll do well to avoid it.

Output to the Screen

So far, we've seen that the program in Listing 2.2 contains a main() function. The first thing that this function does is declare a variable so it can store your name. Its next task, on line 10, is to output a string of characters to the screen. The string it outputs is

 "Please type your name and press Enter: " 


I typed the string directly into the program in quote marks. Strings that are typed directly into programs are called literal strings. Literal strings must always be in quote marks.

To get output to the screen, C++ uses a stream. Streams in C++ contain data that flow into and out of the program. When you want to send data from the program to the screen, you have to insert the data into an output stream. The data flows out from the program to the screen.

Streams can flow out to almost any device. The C++ Standard Libraries define a special stream called cout that flows to the screen. Any time you insert data into the cout stream, it automatically goes to the screen. You don't have to worry about how; all you need to do is insert the data. The C++ Standard Libraries take care of everything else.

Note

The stream cout is pronounced see-out.


To insert data into a stream, your program uses the insertion operator. The insertion operator is two less-than signs (<<). It's shown on line 10 between the cout stream and the literal string.

Sending information from the program to the screen is very much like standing by a stream of water that flows into a nearby lake and dropping in a toy boat. All you need to do is insert the boat into the stream and let the stream of water take it out to the lake. Similarly, we insert data from C++ programs into data streams. The streams carry the data to their destination. The destination of the cout stream is the screen.

If we were to translate line 10 of Listing 2.1 into English, we would read it something like this: "Insert the literal string specified in these quote marks into the cout stream so that it can go to the screen."

Lines 13 and 15 show more output to the screen. On line 13, the program sends a special value called an endline. This moves the cursor on the screen to the beginning of the next line. So line 13 essentially prints a blank line, and then the string "Hello," (the word Hello followed by a comma and a space). Next, it prints the string that the variable yourName contains, followed by an endline. Finally, it prints another blank line.

Input from the Keyboard

Streams aren't just for outputting information to the screen. C++ programs also use them to get input from the keyboard. Line 11 of Listing 2.2 demonstrates how this is done.

On line 11, the main() function uses a stream called cin, which is defined by the C++ Standard Libraries. This stream is connected to the keyboard. Data flows from the keyboard to the program through the cin stream. C++ programs must extract the data from the input stream using the extraction operator, which is two greater-than signs (>>).

The statement on line 11 extracts characters from the cin stream. The characters it extracts are the characters that the user types in.

Note

The stream cin is pronounced see-in.


It is important to note that the extraction operator does not get any input until after the user presses the Enter key. When the program uses the extraction operator, it just waits for input until the user presses Enter. This is fine for entering strings, but not so great for entering single characters. Line 15 prompts the user to press the C key and then press Enter. This causes the program to wait, giving the user time to read the message printed on line 13.

Normally, you do not want your programs to behave like this. If your program pauses, you usually want the user to just press one key to make it continue. We'll see how to do this later.

Although streams such as cin and cout are fine for simple input and output, we do not use them in games. We learned streams here because they are the simplest form of input and output. Also, all file input and output is based on streams. If you know how to use streams, writing saved games to files (and reading them back from files) is not all that much more complex than writing strings to the screen.

Tip

Use the insertion operator, which is <<, to make data flow out of a program. Use the extraction operator, the >> symbol, to get data into a program.


Streams and Include Statements

I mentioned earlier that the streams cin and cout are defined by the C++ Standard Libraries. To get access to these definitions, you must use include statements in your .cpp files. The include statement on line 2 of Listing 2.2 includes a file from the Standard Libraries called iostream. That is the file that contains the definitions of the cin and cout streams. To use cin and cout, you must put the statement

 #include <iostream> 


at the beginning of your .cpp files.

You might be wondering why we need include statements when the linker connects our programs to the Standard Libraries. The answer is that programs must have the definitions of cin and cout for the compiler so that the compiler knows that we're using those streams correctly. The linker links our programs to the actual library code that implements the streams. The definitions tell how they are used. The implementation actually performs the work. If our programs don't include the definitions, they won't compile. If our programs don't link to the implementations, they won't work.

Factoid

The LlamaWorks2D game engine, which is included on this book's CD, uses the OpenGL graphics library. That means that all of your programs that use LlamaWorks2D must link to OpenGL. Fortunately, you do not have to tell the linker that. When you followed the installation instructions in the Introduction, you configured the linker to automatically link to the OpenGL libraries whenever you compile an OpenGL program.


In general, this is how things work in C++. All code libraries provide definitions and implementations. The definitions are in files with an extension of .h or .hpp. There is a trend lately to put the definitions in a file with no extension on the filename. The new version of the C++ Standard Libraries uses this style. So the filename is iostream rather than iostream.h or iostream.hpp.

The implementations for code libraries are always in object files that have extensions such as .a or .lib. Your program must include the definition files and link to the implementation in the object files.

Functions

I've said repeatedly that main() is a function. However, I haven't really defined a function. A function is a chunk of code that your program can use over and over. Listing 2.3 illustrates what I mean.

Note

Just a quick reminder: Don't type in the line numbers you see in the listings. C++ does not allow line numbers in actual source code. They're just there in the listing to make it easy to talk about the individual statements in the program.


Listing 2.3. A function called by main()

 1    #include <iostream> 2    #include <stdlib.h> 3 4    using namespace std; 5 6 7 8    int Squared(int numberToSquare); 9 10 11 12   int main(int argc, char *argv[]) 13   { 14     // Prompt the user for an integer. 15     cout << "Please type an integer number and then press Enter: "; 16 17     // Delcare the integer variable. 18     int theNumber; 19 20     // Get the integer from the user. 21     cin >> theNumber; 22 23     // Declare another variable. 24     int theNumberSquared; 25 26     // Square the number. 27     theNumberSquared = Squared(theNumber); 28 29     // Print out the answer. 30     cout << theNumberSquared << endl; 31 32     // 33     // Now do it all again. 34     // 35 36    // Prompt the user for an integer. 37    cout << "Please type an integer number and then press Enter: "; 38 39    // Get the integer from the user. 40     cin >> theNumber; 41 42    // Square the number. 43    theNumberSquared = Squared(theNumber); 44 45    // Print out the answer. 46    cout << theNumberSquared << endl; 47 48    system("PAUSE"); 49 50    return (0); 51   } 52 53 54   int Squared(int numberToSquare) 55   { 56   int theNumberSquared = numberToSquare * numberToSquare; 57 58   return (theNumberSquared); 59   } 

Listing 2.3 shows a function called Squared(). It's defined on lines 5459. Normally, the program executes each statement in main() one after another. However, each time main() calls the Squared() function, the program jumps to the beginning of Squared() and executes the statements in Squared(). The main() function can call the Squared() function as many times as needed. As you can see, there are calls to Squared() on lines 27 and 43.

Tip

It's usually best to name your functions by capitalizing the first letter of each word in the name and using lowercase for all the other letters. Here's an example: ASampleFunctionName(). When other programmers see this, they recognize it as a function name from the style of capitalization used.


The next few topics use Listing 2.3 to discuss how to create a function, how to pass information to it, and how to get information out of it.

Creating Functions

Every function has a few required elements. First, functions must have names. The rules for naming functions are the same as the rules for naming variables. People use different styles for naming their functions than they use for naming variables. For example, some people use all lowercase, while others use all uppercase. In general, though, most programmers name their functions by capitalizing the first letter of each word in the name and using lowercase for all the other letters.

It's probably pretty obvious that the name of the function in Listing 2.3 is Squared(). Any time the name Squared() appears in another function, such as main(), we say that the program is calling or invoking the Squared() function. Program execution actually jumps to the beginning of Squared(). The program then executes all the statements in Squared(). When it hits the end of Squared(), which is marked by the closing brace (}), the program jumps back to the point where it called Squared(). It then resumes executing statements from that point.

Passing Values to Functions

In addition to a name, functions must have a parameter list. Programs use a function's parameter list to send information to the function. If you look on line 54 of Listing 2.3, you'll see the Squared() function's parameter list in parentheses. There is only one item in the parameter list: numberToSquare.

Function parameters are very much like variables. You use them in just the same way. The primary difference between a variable and a parameter is how they get their values. Your program usually uses the assignment operator (=) to assign a value to a variable. Parameters get their values when the function is called. Let's look at Listing 2.3 to see how this works.

On line 27, you can see that the main() function calls Squared(). The parentheses next to the name Squared() contain the variable theNumber. This means that main() is passing the value in theNumber as the parameter to the Squared() function. This causes the value in theNumber to be copied into the Squared() function's numberToSquare parameter. Program execution then jumps down to the Squared() function. The Squared() function executes and uses the parameter numberToSquare just as if it were a variable. When Squared() ends, program execution jumps back to line 27 of Listing 2.3.

The long and short of this is that passing a value as a parameter means that the value is copied into the parameter. The function being called can then use the parameter as if it were a variable.

The Body of a Function

The reason we write functions is to get them to do work for us. That means we need to have commands, or statements, inside the function. A function's statements are all contained in the function body. The function's body consists of all of the statements between the opening and closing braces (the { and } symbols).

When a function is called, program execution jumps down to the beginning of the function and executes all of the statements in the body. When the program reaches the end of the function's body, it jumps back to the point where the function was called.

The statements in the body of the Squared() function are on lines 5658. The statement on line 56 multiplies the number in numberToSquare by itself. That is how you calculate the square of a number. The statement stores the answer in a variable called theNumberSquared. Even though this variable has the same name as a variable in the main() function, they are two different variables. We'll talk more about this shortly.

The last statement in the body of the Squared() function sends the answer back to the main() function. Let's take a closer look at how that's done.

Note

It is possible to have more than one parameter in a function's parameter list. If there is more than one, you separate each parameter in the list with a comma. Each parameter must have its own name and type.


Returning Values from Functions

The purpose of the Squared() function in Listing 2.3 is to calculate the square of the number that is sent in through the parameter list. That means we want Squared() to give us back an answer. That answer is a piece of data. All data in programs must have a type.

When we send data from a function back to the point where the function was called, we say that we're returning a value from the function. When the Squared() function in Listing 2.3 is called on line 27, the program copies the value in the parameter list into the parameter numberToSquare. The program then executes the statements in the function's body. The last statement is a return statement. The return statement tells the program to return a value. The return statement is followed by the value to return. In this case, the value is the number in the variable theNumberSquared. So whatever's in theNumberSquared gets sent back to line 27, which is where Squared() was called from.

Notice that the return type of the Squared() function is int, which means integer. That is also the type of the parameter numberToSquare. Function return types do not have to be the same as any of types of the function's parameters. They don't have to match. In this case, they do match, but that's not a general requirement for all functions.

Note

It's not strictly true that all data in programs must have a type. It is possible to create data without a type, but it can cause complications. I strongly recommend that you don't create data without a type until you feel you're a strong C++ programmer.


Let's summarize what we've covered about functions so far. Every function must have a name, a parameter list, a return type, and a body. The name distinguishes the function from all other functions in the program. The parameter list is a way of getting information into the function. The return type specifies the type of the data the function returns. Returning data is how we get information out of functions.

Reminder

An integer has no decimal point. 0, -42, and 1000 are examples of integers.


The Squared() function has a name and a parameter list containing one parameter. When the function's name appears in main() on lines 27 and 43, the program copies the value in the parameter list into the numberToSquare parameter. The program then jumps to the beginning of the Squared() function's body on line 56. It performs the calculation on line 56 and then encounters the return statement on line 58. The return statement tells the program to send the value in theNumberSquared back to the place where there Squared() function was called from. If we look at lines 27 and 43, we see that they both use the assignment operator (the = sign) to assign the value that comes back from Squared() into a variable. This is what we often do with the return value of a function. You could also use the return value in a calculation, or print it to the screen with cout and the insertion operator (<<).

Factoid

Every function must have a name, type, parameter list, and body.


Scope in Functions

One thing that Listing 2.3 teaches is that variables in different functions can have the same name. The reason for this is that they have different scope.

So what is scope?

The scope of a variable is the portion of the code over which the variable can be seen and used.

Say what?

Let's go back to Listing 2.3 again to get a better handle on what scope is. The main() function declares a variable called theNumberSquared on line 24. The Squared() function declares a variable called theNumberSquared on line 56. These are two different variables because they each have a different scope. The variable declared on line 24 can only be accessed by statements in the main() function. Technically, we say that the scope of that variable is limited to the main() function.

On the other hand, the variable declared on line 56 can only be accessed by statements in the Squared() function. Therefore, its scope is limited to the Squared() function.

Any statements in the main() function that refer to a variable called theNumberSquared are referring to the one declared on line 24. Statements in the Squared() function that refer to a variable called theNumberSquared are referring to the one declared on line 56. The compiler never confuses the two.

As you can see from Listing 2.3, the scope of any variable is limited to the function in which it is declared. It cannot be seen outside that function. This enables us to use variables of the same name over and over in many different functions. You'll see the importance of this in later chapters.

Everything in a C++ program has scope. For example, the function Squared() has a specific scope. It can be accessed by any other function in the program. Most functions have this sort of scope. We can make functions that can only be seen by certain parts of the program. As we'll see in Part 2, there are definite reasons for doing so.

For now, though, we won't fuss much with scope. The variables we'll declare will only be visible in the functions in which they're declared. The functions we'll write will be visible throughout the entire program in which they appear. We'll continue in this fashion until Part 2.

Warning

It's not absolutely true that variables cannot be seen outside the functions where they are declared. However, making them visible outside their natural scope is an advanced programming topic that most C++ developers never need. I strongly recommend that you avoid changing the natural scope of variables.


Prototypes

Take a look at line 8 of Listing 2.3. Notice that it contains a statement that looks just like the first line of the Squared() function. This is a special type of statement called a function prototype. A prototype is like an introduction to a function. It gets the compiler and the function acquainted with each other. A fancier way of saying this is that the prototype is a template of how the function looks and acts. It describes the function's name, parameter list, and return type.

You're probably asking, "What are prototypes for?"

When a compiler compiles a program, it does so line by line. When it compiles main(), it examines each line and determines whether it is correct C++. If the statement is correct, the compiler translates it into object code. If the statement is not correct, the compiler spits out an error or warning message depending on how bad the problem is.

Suppose you're the compiler. You start at the beginning of main() and go through each statement. When you get to line 27 you see that the main() function calls a function named Squared(). Do the parentheses contain the correct number of parameters? Is the parameter the correct type? What about the return value? Can it be stored in an int variable, or is that an error?

The only way the compiler can answer such questions is to have a description of the Squared() function. That's what the prototype is for. It describes the parameter list and return type for the Squared() function. Because the prototype appears at the beginning of the file, we can use the Squared() function anywhere in the program. The compiler knows whether we're using it correctly. If we're not, it can let us know.

You'll need prototypes for all of the functions that you write. In later chapters, I'll show you how to organize the prototypes so they can be used easily and efficiently. There's a bit of a trick to it, but it's not hard to do if you just follow the few simple rules we'll discuss later.

A Few Final Words about Listing 2.3

There are a couple more items in Listing 2.3 worth discussing before we move on. First, notice that line 48 shows a call to the system() function. The system() function is provided by the C++ Standard Libraries. Its prototype is in the file stdlib.h.

The system() function takes one parameter. That parameter is a string that system() passes to the operating system. On line 48, the string that is passed is the PAUSE command. This is an old DOS command that was used a lot in batch files.

Factoid

The name stdlib stands for "standard library."


The PAUSE command causes DOS, or a DOS window under Windows, to pause and wait for the user to press a key. This is a different way to add a pause to a program than we saw in Listing 2.1. Either one works. You can use whichever you like better.

An item in Listing 2.3 that doesn't appear in Listing 2.2 is the comment. Programmers put comments in their programs to describe what they're doing. For example, line 14 contains a comment. It tells the reader that the program is about to prompt the user for an integer.

Comments in C++ programs begin with a pair of slash marks (//). Whenever the compiler sees a pair of slash marks on a line of code, it knows that the line contains a comment. The compiler always ignores comments; they are there strictly for people to read. Comments that begin with a // symbol end at the end of the line. They do not span more than one line of text.

Another interesting item in Listing 2.3 that is worth discussing is the fact that main() is a function. Therefore, it has all of the things that any other function has. Notice that main() has parameters. These parameters enable your program to receive strings as parameters when it starts up. For example, suppose you ran this program from the command line of a DOS window with the following command:

 prog_02_03_2 this that theOther 


What this does is run the program Prog_02_03.exe, which is shown in Listing 2.3. It also passes the strings "this", "that", and "theOther" into prog_02_03 as parameters in the parameter list.

Passing parameters from the operating system into main() used to be an important technique for all programmers. However, now that we're not using operating systems based around command lines any more, it is much less important. We won't discuss how it's done. However, if you want to know more, you'll find information on it in the C++ programming books I recommend in Appendix C.

The last item we should mention is the fact that main() returns a value like any other function. On line 50, it returns the value 0. Returning 0 tells the operating system that the program ended with no errors. All operating systems expect this, so you should put it at the end of all of your programs. If your program wants to return another value besides 0, it can. If it does, it usually means that an error occurred. Typically, the error values that main() returns are negative numbers.

Note

You can create comments that span multiple lines of text in C++ programs. To do so, start the comment with slash followed by an asterisk (/*). End the comment with an asterisk followed by a slash (*/).


The libraries that come with the Dev-C++ compiler define a special value called EXIT_SUCCESS. It is equal to 0. If you create a new project in Dev-C++, the main() function it generates for you returns the value EXIT_SUCCESS. So your programs can return EXIT_SUCCESS or 0. It's up to you which you want to use.



Creating Games in C++(c) A Step-by-Step Guide
Creating Games in C++: A Step-by-Step Guide
ISBN: 0735714347
EAN: 2147483647
Year: N/A
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net