-
/t and headers
djscsi (Visitor) Feb 23, 2002
I just started learning C++, and I'm trying to figure out what \t stands for in a statement.
Example of statement
cout << "I am:\t" << myAge << "\tyears old.\n";
Can someone also explain to me what headers are and what they do?
Thanks for the help
Kenny
-
\t is the tab character.
A header file is a file that usually contains function prototypes. For instance, including string.h, you get access to all of the various string functions, and when you include windows.h, you get access to all of the various windows API functions.
Z.
-
Since the compiler scans your code from top to bottom without ever looking ahead, you'll get an error when you call a function that is declared later:
Code:
int main()
{
func(4); // error: the compiler doesn't know the name "func"
return 0;
}
void func(int i)
{
// do something
}
This is where "function prototypes" come in. A function prototype looks like the normal function definition except that it has no code. It's purpose is just to tell the compiler that there indeed is such a function. The prototype for the "func" above would be:
void func(int i);
You don't need to specify a name for the parameter, so this would be legal too:
void func(int);
A header file is usually a collection of function prototypes and type definitions.