OpenVMS Source-Code Demos

STRING_DEMO

//==============================================================================
// title  : string_demo.cpp (".cxx" is more common on OpenVMS)
// author : Neil Rieck (Waterloo, Ontario, Canada)
// created: 2013.05.29
// build  : openvms compile:    $ cxx     program.cpp
//          openvms link:       $ cxxlink program
//==============================================================================
#include <iostream>
#include <string>
using namespace std;

int main ()
{
    string user_first_name;
    string user_last_name;
    cout << "Please enter your first name: ";
    cin >> user_first_name;
    cout << "Please enter your last name: ";
    cin >> user_last_name;
    string user_full_name = user_first_name + " " + user_last_name;
    cout << "Your name is: " << user_full_name << "\n";
    //
    //  are there any limits to the size of these strings?
    //	for example, HP-BASIC for OpenVMS limits them to 32,767 bytes
    //
    int junk = 0;
    string huge = "";
    string yada = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
    while (junk<1999000){
        huge = huge + yada;
        junk = huge.length();
        cout << "length:" << junk << "\n";
    }
}