An asterisk. Useful for masking password input, dereferencing pointers in C and C++, indicating *italics* in plain text, and a host of other tasks.

Odd little operator in c and c++. It does all the following:
  • Declaring a pointer:
    int *ptr or int* ptr
    (there is a jihad almost as bad as emacs vs. vi about which of those is right. I usually go with *ptr)

  • Dereferencing a pointer:
    foo = *ptr
    would put the value in the memory address which ptr pointed to into foo.

  • Multiplication:
    foo = bar * baz
    yawn...
In linguistics, an asterisk often appears before a form (a word, sentence, etc.), where it has one of two functions:
  1. introducing a form that is ungrammatical or otherwise unacceptable, for the purposes of discussion;
  2. introducing a form that is posited but not directly attested, such as a reconstructed form.

It will be seen that there is a certain contradiction between these two usages: one means approximately "wrong" and the other something like "should be". The contradiction can be avoided by remembering that the asterisk actually indicates only that a form is unattested.

Context: regular expressions, regexp, regex

In regular expressions (or regexp, or even regex)pattern matching syntax, the asterisk (*) represents a quantifier of 0 or more instances of the previous character or group. Thus a* matches 0 or more as, .* matches 0 or more characters and (foo|bar)* matches 0 or more instances of foo or bar.

An exception of this occurs in character classes, where an asterisk just represents an asterisk. To specify an asterisk in places outside of character classes, use the expression \*.

Log in or register to write something here or to contact authors.