CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

Dealing with Strings

Your programs can now declare objects of type "string"

string name,address;

Objects of type string can be input using the askwords function:

name = askwords("What is your name?");

address=askwords("What is your address?");

You can also use assignments between objects of type string, or literal strings:

string customer_name, employer;

customer_name=name;

employer="UC Santa Cruz";

You can display objects of type string with boxes:

Box thename("Name:"),theaddress("Address:");

thename.say(name);

thename.say(address);

Unfortunately, you cannot use strings with atlhetes:

Sal.say(name) ... will not work.