News flash: I'm going to Australia in February, so this Web site may be switched off at any time.


Finding the size of an Icon string

The unary ``*'' operator, applied to a string, returns the number of characters in the string. For example, the expression

    * "foo"
yields the integer 3, the number of characters in the string "foo".

Here's another example. This program prints the length of every line of its input:

    procedure main()
      while  line := read ( )  do
        write ( * line );
    end

Next: Selecting a substring in Icon
See also: Using the Icon programming language
Previous: How Icon positions are numbered

John W. Shipman, john@nmt.edu