String Test


Program Listing

StringTest.cpp

/************************************************************************
*                                                                       *
*   Program:    String Test                                             *
*                                                                       *
************************************************************************/

#include <iostream>
#include <string>

using namespace std;

int main() {

//  Print newlines

    cout << "Newline examples:" << endl << endl;
    cout << "Hello, World!" << endl;
    cout << "Hello, World!\n";
    cout << "Hello, \nWorld!" << endl;

//  Print tabs

    cout << endl << "Tab examples:" << endl << endl;
    cout << "Hello, World!" << endl;
    cout << "\tHello, World!" << endl;
    cout << "H\te\tl\tl\to, \tW\to\tr\tl\td!" << endl;

//  Print backspaces

    cout << endl << "Backspace examples:" << endl << endl;
    cout << "Hello, World!" << endl;
    cout << "Hello, \bWorld!" << endl;
    cout << "Hello, World!\b\b\b\b\b\bxxx" << endl;
    
    return 0;
}

Sample Run

Newline examples:

Hello, World!
Hello, World!
Hello, 
World!

Tab examples:

Hello, World!
    Hello, World!
H   e   l   l   o,  W   o   r   l   d!

Backspace examples:

Hello, World!
Hello,World!
Hello, xxx



Return to Lectures page


e-mail me at robbk@hsc.edu

This page was last modified on Tue Dec 7 16:04:23 1999 .

URL: http://people.hsc.edu/faculty-staff/robbk/Coms261/Examples/StringTest.html

Return to Coms 261 home page