osd@hou2d.UUCP (Orlando Sotomayor-Diaz) (05/15/86)
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c> mod.std.c Digest Thu, 15 May 86 Volume 16 : Issue 13 Today's Topics: MORE C standard differences Apr85-Feb86, part 3 of 9 ---------------------------------------------------------------------- Date: From: ihnp4!utzoo!lsuc!msb Subject: MORE C standard differences Apr85-Feb86, part 3 of 9 To: utzoo!ihnp4!hou2d!osd # D.9.4.4 The tmpnam function * If the argument is not {null --> a null pointer}, it is assumed * to point to an array of at least L_tmpnam {bytes --> characters} ... # D.9.5.2 The fflush function The fflush function causes any unwritten data for the output * stream pointed to by stream to be {--> delivered to the host en- vironment to be} written to the file. # D.9.5.3 The fopen function * "w": create text file for writing, or truncate {--> to zero length}. Remark: The same change for "wb", "w+", and "w+b". # D.9.5.3 The fopen function However, output may not be directly followed by input without an * intervening {--> fflush,} fseek, or rewind, and input may not be * directly followed by output without an intervening {--> fflush,} fseek, or rewind, unless the input operation encounters end-of- file. # D.9.5.3 The fopen function <--O After the write operation, the file pointer is repositioned at <--O the end of the output file and the buffer is flushed. # D.9.5.3 The fopen function N--> When opened, a stream is fully buffered if and only if it does N--> not refer to an interactive device. # D.9.5.4 The freopen function The primary use of freopen is ... with ... stderr, stdin, or * stdout ..., as those identifiers need not be {lvalue expressions --> modifiable lvalues} (that may be assigned to by the fopen function). # D.9.5.5 The setbuf function <--O The setbuf function is used after the stream pointed to be stream <--O has been associated with an open file but before it is read or <--O written. It causes the array pointed to by buf to be used in- <--O stead of an automatically allocated buffer. If buf is a null <--O pointer, input/output on that stream will be completely unbuf- <--O fered. The macro BUFSIZ specifies the size in bytes of the array <--O that is needed. <--O The standard stream stdout is normally buffered if and only if <--O the output does not refer to a terminal; this default may be <--O changed by setbuf. The standard stream stderr is by default un- <--O buffered unconditionally; setbuf will set the state to whatever <--O is desired. When an output stream is unbuffered, information ap- <--O pears on the destination file or terminal as soon as written; <--O when it is buffered, characters are saved up and written as a <--O block. <--O ... The buffer must have a lifetime at least as great as the <--O open stream, so a stream must be closed before a buffer that has <--O automatic storage duration is deallocated upon block exit. N--> Except that it returns no value, the setbuf function is N--> equivalent to the setvbuf function invoked with the values _IOFBF N--> for type and BUFSIZ for size, or (if buf is a null pointer), with N--> the value _IONBF for type. # D.9.5.6 The setvbuf function int setvbuf(FILE *stream, char *buf, int type, * {int --> size_t} size); # D.9.5.6 The setvbuf function * The setvbuf function {is --> may be} used after the stream point- ed to by stream has been associated with an open file but before it is read or written. # D.9.5.6 The setvbuf function * ... _IOFBF causes input/output to be fully buffered {, if possi- * ble -->}; _IOLBF causes input/output to be line buffered {, if possible -->} ...; _IONBF causes input/output to be completely * unbuffered {, if possible -->}. # D.9.5.6 The setvbuf function * If buf is not a null pointer, the array it points to {will --> may} be used instead of an automatically allocated buffer. ... * {--> The contents of the array at any time are indeterminate.} ... The buffer must have a lifetime at least as great as the * open stream, so the stream {must --> should} be closed before a buffer that has automatic storage duration is deallocated upon block exit. # D.9.5.6 The setvbuf function The setvbuf function returns non-zero if an invalid value is * given for type or size {-->, or if the request cannot be honored}. # D.9.6.1 The fprintf function * An optional decimal {digit string --> integer} specifying a minimum "field width". ... The padding is with spaces unless * the field width {digit string --> integer} starts with a zero, in which case the padding is with zeros. * An {--> optional} "precision" ... The precision takes the form * of a period (.) followed by an {--> optional} decimal {digit * string --> integer}; {a null digit string --> if the integer is omitted, it} is treated as zero. # D.9.6.1 The fprintf function An optional h specifying that a following ... conversion specif- ier applies to a short int or unsigned short int argument (the argument will have been promoted ... and its value shall be * {cast --> converted} to a short int or unsigned short int before printing) ... # D.9.6.1 The fprintf function * c The {least significant byte of the -->} int argument is * converted to a {character --> char}, and {--> the result- ing character is} printed. # D.9.6.1 The fprintf function <--O If the character after the % is not a valid conversion specifier, <--O the behavior is undefined. N--> If the conversion specifier is a lower-case letter that is not N--> described above, the behavior is undefined. If the conversion N--> specifier is any other character that is not described above, the N--> behavior is implementation-defined. # D.9.6.1 The fprintf function * {--> #include <stdio.h>} fprintf(stdout, "%s, %s %d, %.2d:%.2d\n", weekday, month, day, hour, min); ... #include <math.h> * {--> #include <stdio.h>} fprintf(stdout, "pi = %.5f\n", 4 * atan(1.0)); # D.9.6.2 The fscanf function * Conversion specifications, consisting {--> in sequence} of the character %, an optional assignment-suppressing character *, an * optional {numerical --> decimal integer that specifies the} max- imum field width, ... # D.9.6.2 The fscanf function ... The following conversion specifiers are valid: * d An {--> optionally signed} decimal integer is expected; ... # D.9.6.2 The fscanf function * ... the {subsequent --> corresponding} argument shall be a pointer to integer. Remark: This change is made throughout the section. # D.9.6.2 The fscanf function <--O i An integer is expected; the subsequent argument must be a <--O pointer to integer. The input is interpreted as an in- <--O teger constant, with an optional sign prefix and an op- <--O tional integer suffix. If the input field begins with <--O the characters 0x or 0X, the field is taken as a hexade- <--O cimal integer. Otherwise, if the input field begins with <--O the character 0, the field is taken as an octal integer. <--O Otherwise, the input field is taken as a decimal integer. N--> i An integer is expected; the corresponding argument shall N--> be a pointer to integer. The input format is as N--> described for the strtol function, with the value 0 for N--> the base argument. ------------------------------ End of mod.std.c Digest - Thu, 15 May 86 13:29:24 EDT ****************************** USENET -> posting only through cbosgd!std-c. ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C) In all cases, you may also reply to the author(s) above.