O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data Types and Variables

I covered the basic concept of variables in the previous chapter when you looked at how they can be named and declared. Recall that we imagined them as named slots (imagine pigeonholes) in memory, with space reserved for each piece of data that you would like to store.

In addition, that chapter looked at how a variable is defined by specifying a name and a type:

int nMyNumber;         // A simple variable
char szMyString[255];  // A 255 slot array
char * szString;       // Pointer to char's

This is called the variable declaration. Once a variable has been declared, it can only contain data of the type that was included in the declaration. Operations upon the data in that variable will be limited to those that are supported by the data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required