#Meta-Wlp: #Macro: TITLE wlp: Learn C (III) p. 9 #Eval: $TITLE$ #Macro: PAGE bb3-9

s++ autoincrements s.

The ++ operator is unary, it takes only one argument. It is both prefix, coming before its argument, and postfix, coming after its argument. In prefix, first it increments the value, then it returns its value. In postfix, first it uses the value, then it increments it.

There is also a -- operator for autodecrement.

#include<stdio.h>

int main(){
  char * s, * t ;
  s = "I'm melting!" ;

  while ( *(t=s++) ) {
     while ( *t )
        printf("%c",*t++) ;
     printf("\n") ;
  }
}
This program prints sequence of shorter and shorter strings. In it we have used some very C-like notations. What best describes the action of *(t=s++)? #Shuffle: none $PAGE$-A $PAGE$-B $PAGE$-C $PAGE$-D Return to Learn C Table of Contents #: Assign s to t then increment them both. Dereference there common value, so it is a character, check this character for zero (the end of string marker). #: Assign s to t, then replace old s by s plus 1. This moves to the next character in the string. Dereference t, it is a character, check this character for zero (the end of string marker). #: Increment the character referenced by s, assign the reference s to t. Check if we are out of memory. If not, continue. #: This program hasn't a prayer of working. #: