Skip to main content

Posts

Showing posts from May, 2012

C - Ritchie & Kernighan - Part 3

Chapter 7-Input and Output   'prog <infile' causes prog to read characters from infile instead. 'otherprog | prog' runs the two programs otherprog and prog, and pipes the standard output of otherprog into the standard input for prog. 'prog >outfile' will write the standard output to outfile instead of stdout. These can be used when using getchar & putchar Each conversion specification begins with a % and ends with a conversion character. Between the % and the conversion character there may be, in order: A minus sign, which specifies left adjustment of the converted argument. A number that specifies the minimum field width. The converted argument will be printed in a field at least this wide. If necessary it will be padded on the left (or right, if left adjustment is called for) to make up the field width. A period, which separates the field width from the precision. A number, the precision, that specifies the maximu

C - Ritchie & Kernighan Part 2

Chapter 3-Control Flow the else part of an if-else is optional,there is an ambiguity when an else if omitted from a nested if sequence. This is resolved by associating the else with the closest previous else-less if The case labeled default is executed if none of the other cases are satisfied. A default is optional; if it isn't there and if none of the cases match, no action at all takes place. Cases and the default clause can occur in any order. Because cases serve just as labels, after the code for one case is done, execution falls through to the next unless you take explicit action to escape. The standard library provides a more elaborate function strtol for conversion of strings to long integers A pair of expressions separated by a comma is evaluated left to right, and the type and value of the result are the type and value of the right operand. A%B = A when A<B The continue statement applies only to loops, not to switch. A continue