|
 |
|
 |
01-01-2005, 02:33 PM
|
#1 (permalink)
|
|
Registered User
Join Date: Dec 2004
Posts: 43
|
What does this mean?
In simple words, can you retell me what this part of "sams teach it yourself C++ in 21days"
Special Printing Characters
The C++ compiler recognizes some special characters for formatting. Table 3.2 shows the most common ones. You put these into your code by typing the backslash (called the escape character), followed by the character. Thus, to put a tab character into your code, you would enter a single quotation mark, the slash, the letter t, and then a closing single quotation mark:
char tabCharacter = `\t';
This example declares a char variable (tabCharacter) and initializes it with the character value \t, which is recognized as a tab. The special printing characters are used when printing either to the screen or to a file or other output device.
New Term: An escape character changes the meaning of the character that follows it. For example, normally the character n means the letter n, but when it is preceded by the escape character (\) it means new line.
Table 3.2. The Escape Characters.
Character What it means
\n new line
\t tab
\b backspace
\" double quote
\' single quote
\? question mark
\\ backslash
If you can tell me what exactly it means, plz explain in easier terms, and examples. Thanx.
|
|
|
01-02-2005, 04:13 AM
|
#2 (permalink)
|
|
Regular Contributor
Join Date: Feb 2003
Location: indisclosed
Posts: 210
|
\n new line
\t tab
\b backspace
\" double quote
\' single quote
\? question mark
\\ backslash
This is easier than you think. I'm surprised they didn't offer any examples of any sort. You're going to want to use these in cout statements:
Code:
#include<iostream>
using std::cout;
int main()
{
cout << "This is some text\nWith a newline\ta tab a backspace\b some double quotes\" single\' question make\? a
nd a backslash\\ \n\n";
return 0;
}
Output:
Code:
This is some text
With a newline a tab a backspac some double quotes" single' question make? and a backslash\
The \n, newline goes to the next line before outputting anymore text. The \t places a tab before the next piece of text, the backspace goes back a charcter space (just like pressing backspace), and the quotes and backslash put that particular character in since you can't use them in output by themselves.
Hope that clears something up. If you don't understand one completely, just add a few to that code, and see what happens.
|
|
|
01-02-2005, 12:09 PM
|
#3 (permalink)
|
|
Registered User
Join Date: Dec 2004
Posts: 43
|
Hey thanx, that makes alot more sense. I thought it was harder then I thought, since the chapter was hard. (for me at least)
|
|
|
01-04-2005, 11:24 AM
|
#4 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 219
|
slashdot, is c++ your first coding language ever?
|
|
|
01-04-2005, 02:22 PM
|
#5 (permalink)
|
|
Registered User
Join Date: Dec 2004
Posts: 43
|
Ya it is. I have also tried python, java, and I think one other. But C++ is faster or so that I heard from my programming teachers, math teacher, a few people I know, and Steve Baker. I like it so far. I look into simple games that are open source, and see if what I have learned is incorporated somewhere, somehow into the game, so I can understand it more.
|
|
|
01-04-2005, 05:18 PM
|
#6 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 219
|
how about sharing the links where you got those games from?
|
|
|
01-04-2005, 05:52 PM
|
#7 (permalink)
|
|
Registered User
Join Date: Dec 2004
Posts: 43
|
Here's deadly cobra, its a nibbles/snake like game http://prdownloads.sourceforge.net/d...ar.gz?download, heres tux a quest for herring http://tuxaqfh.sourceforge.net/ the game is old as hell, (2000) but my game's engine is going to reflect that, just slightly hacked (mines is going to use plib, just like this game, so hopefully it'll make my life easier plib.sourceforge.net) once I understand the majority of the games code. Im sure I won't need it all. http://legacy.newdoom.com/downloads.php thats doom legacy, a enhanced port the original doom, it has jumping, looking with mouse, lan/internet mode, better then that IPX bs you have with the origianl. I barely looked into legacy, and I am not realy planning on making an FPS, thers too many out ther, and too little room for another. I've looked a little into its code. I believe its all in c, which I don't realy feel like dabling with, but maybe in the near future, I'll look into c, or just move onto a Open Source Game called cube. (I think cube.sourceforge.net, if not then google, not hard to find. If you want more OS games, then go to www.happypenguin.org.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 03:53 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|