Backslash Combinations in Java

Make Data Matrix in Java Backslash Combinations

Backslash Combinations
ECC200 Drawer In Java
Using Barcode generation for Android Control to generate, create ECC200 image in Android applications.
www.OnBarcode.com
UCC.EAN - 128 Creation In Java
Using Barcode generation for Android Control to generate, create GS1-128 image in Android applications.
www.OnBarcode.com
The last program in this chapter, slasher, demonstrates several different backslash combinations. A backslash combination combines a backslash character (\) and a second character to produce a specific result when the combination is printed in the console window. One backslash combination you ve seen a lot of in this book is \n, which produces a new line in the console. C allows you to embed any number of backslash combinations in a text string. For example, this line of code:
Barcode Creator In Java
Using Barcode drawer for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
PDF417 Generation In Java
Using Barcode drawer for Android Control to generate, create PDF-417 2d barcode image in Android applications.
www.OnBarcode.com
printf( "Hello\n\nGoodbye" );
Barcode Generator In Java
Using Barcode generator for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
Printing ECC200 In Java
Using Barcode generator for Android Control to generate, create Data Matrix image in Android applications.
www.OnBarcode.com
produces the following output in the console window:
Code 128 Code Set A Creation In Java
Using Barcode printer for Android Control to generate, create Code 128 Code Set C image in Android applications.
www.OnBarcode.com
Creating Leitcode In Java
Using Barcode maker for Android Control to generate, create Leitcode image in Android applications.
www.OnBarcode.com
Hello Goodbye
Data Matrix 2d Barcode Recognizer In C#
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
DataMatrix Printer In Objective-C
Using Barcode creator for iPad Control to generate, create Data Matrix ECC200 image in iPad applications.
www.OnBarcode.com
The single blank line between Hello and Goodbye was caused by the two \n characters. The first \n would have caused the console to put Goodbye on the line immediately below Hello. The second \n moved the Goodbye down one more line. There are a number of backslash combinations. Let s discuss a few of the most interesting ones:
PDF417 Decoder In Visual Basic .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
PDF-417 2d Barcode Scanner In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
\r causes the cursor to move to the beginning of the same line. This allows you to
Encoding EAN / UCC - 14 In .NET
Using Barcode creator for Reporting Service Control to generate, create EAN / UCC - 13 image in Reporting Service applications.
www.OnBarcode.com
Print DataMatrix In Java
Using Barcode creation for Java Control to generate, create Data Matrix 2d barcode image in Java applications.
www.OnBarcode.com
draw some text and then overwrite the same text.
Code 39 Encoder In Java
Using Barcode drawer for Java Control to generate, create Code 39 image in Java applications.
www.OnBarcode.com
Barcode Recognizer In VB.NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
\b is a backspace character. Using it has the same effect as pressing the Delete key
ANSI/AIM Code 128 Recognizer In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Printing Barcode In Java
Using Barcode generation for Eclipse BIRT Control to generate, create Barcode image in Eclipse BIRT applications.
www.OnBarcode.com
while you are typing: it erases the last character typed.
Drawing Barcode In .NET Framework
Using Barcode generator for .NET framework Control to generate, create Barcode image in .NET applications.
www.OnBarcode.com
Barcode Printer In .NET Framework
Using Barcode generator for .NET framework Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
CHAPTER 5: C Basics: Variables and Operators
\\ allows you to place a backslash character in a string. Think about this for a moment.
If you simply embedded a backslash character in your string, the compiler would attempt to combine the backslash with the very next character, producing some unpredictable results. Unpredictable is bad.
\" allows you to place a quote character in a string. When the compiler first sees
a double-quote character in your code, it assumes you are starting a text string. It keeps reading, reading, reading, until it encounters a second, matching doublequote character. The second quote tells the compiler that it has reached the end of the string. So how do you place a quote character inside a string without ending the string Easy. Use the \" where you want the quote to appear.
\t allows you to place a tab in a string.
Support for Backslash Combinations
Backslash combinations stem from the olden days, where all programs ran on video displays with a fixed number of rows and columns. The backslash combinations helped programmers overcome the limitations of these displays, giving them a bit more control. As computers evolved, many of these backslash combinations became unnecessary. Over time, many development environments stopped supporting all but the most basic of these. To see this yourself, we ll run our next program, slasher, using the Terminal application that you used in 4. The Terminal application implements a classic console window that supports all the well-known backslash combinations, just like an old video display terminal. We ll use the built in Unix tools that you installed when you installed Xcode at the beginning of the book to compile the program as well.
NOTE
After you are done playing with the Unix version of slasher, take the Xcode version for a spin. You ll find it in the Learn C Projects folder, in the 05.03 - slasher subdirectory.
CHAPTER 5: C Basics: Variables and Operators
Running slasher
In the Finder, go to the Learn C Projects folder and into the 05.03 slasher subdirectory, and double-click the file named slasher. The Terminal application will launch, and a new window will appear, similar to the one shown in Figure 5-9.
Figure 5-9. Running slasher using the Terminal application. Don t worry if the first few lines look a bit different on your Terminal window.
You can ignore the first few lines of text in the Terminal window. The key lines of output to pay attention to are these five:
1111100000 0011 Here's a backslash...\...for you. Here's a double quote..."...for you. Here are a few tabs...
...for you.
As we step through the source code, you ll see a series of six printf()s, each of which corresponds to one of these lines of output. Once we finish going through the source code, we ll take a shot at compiling the source using the Unix compiler and the Terminal, instead of using Xcode.
CHAPTER 5: C Basics: Variables and Operators
Stepping Through the slasher Source Code
main.c consists of a series of printf()s, each of which demonstrates a different backslash combination. The first printf() prints a series of ten zeros, followed by the characters \r (also known as the backslash combination \r). The \r backslash combination generates a carriage return without a line feed, leaving the cursor at the beginning of the current line (unlike \n, which leaves the cursor at the beginning of the next line down).
#include <stdio.h> int main (int argc, const char * argv[]) { printf( "0000000000\r" );
The next printf() prints five ones over the first five zeros, as if someone had printed the text string "1111100000". The \n at the end of this printf() moves the cursor to the beginning of the next line in the console window.
printf( "11111\n" );
The next printf() demonstrates \b, the backspace backslash combination. \b tells printf() to back up one character so that the next character printed replaces the last character printed. This printf() sends out four zeros, backspaces over the last two, then prints two ones. The result is as if you had printed the string "0011".
printf( "0000\b\b11\n" );
The \ can also be used to cancel a character s special meaning within a quoted string. For example, the backslash combination \\ generates a single \ character. The difference is, this \ loses its special backslash powers. It doesn t affect the character immediately following it. The backslash combination \" generates a double-quote character ("), taking away the special meaning of the double quote. As I said earlier, without the \ before it, the " character would mark the end of the quoted string. The backslash allows you to include quotation marks inside a quoted string. The backslash combinations \\ and \" are demonstrated in the next two printf()s:
printf( "Here's a backslash...\\...for you.\n" ); printf( "Here's a double quote...\"...for you.\n" );
The \t combination generates a single tab character. The Terminal window has a tab stop every eight spaces. Here s a printf() example:
printf( "Here's a few tabs...\t\t\t\t...for you.\n" ); return 0; }
Copyright © OnBarcode.com . All rights reserved.