String assignments work exactly in the same way as any other variable type. It is possible to assign a string to another string or a character array to a string:
Examples:
- string name, address;
- address="Ocean St";
- name=address;
It is possible to compare two strings or to compare a string with a character array. Comparisons work the same way as they do with numeric variables.
Examples:
- string client,salesperson;
- client="Siek";
- salesperson="Jen";
- if(client==salesperson) ...
- if(client =="Siek") ...
Comparisons for < or > take into account the alphabetic order of the characters in the string.
Concatenation means that you want to add a string to the end of another string. For example:
- string firstname,lastname,fullname;
- firstname=ask("your first name?");
- lastname=ask("your last name?");
- fullname=firstname+" "+lastname;
As illustrated above, you may "add" strings and character arrays to another string.