home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / help / dde4clib.in_ / DDE4CLIB.INF (.txt)
Encoding:
OS/2 Help File  |  1992-10-27  |  587.0 KB  |  22,633 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Include Files ΓòÉΓòÉΓòÉ
  3.  
  4. The include files provided with the run-time library contain macro and constant 
  5. definitions, type definitions, and function declarations.  Some functions 
  6. require definitions and declarations from include files to work properly. The 
  7. inclusion of files is optional, as long as the necessary statements from the 
  8. files are coded directly into the source. The description of each include file 
  9. in this section explains the contents of the following include files and lists 
  10. the functions that use them. 
  11.  
  12. o assert.h 
  13. o builtin.h 
  14. o conio.h 
  15. o ctype.h 
  16. o direct.h 
  17. o errno.h 
  18. o fcntl.h 
  19. o float.h 
  20. o io.h 
  21. o limits.h 
  22. o locale.h 
  23. o malloc.h 
  24. o math.h 
  25. o memory.h 
  26. o process.h 
  27. o search.h 
  28. o setjmp.h 
  29. o share.h 
  30. o signal.h 
  31. o stdarg.h 
  32. o stddef.h 
  33. o stdio.h 
  34. o stdlib.h 
  35. o string.h 
  36. o sys\stat.h 
  37. o sys\timeb.h 
  38. o sys\types.h 
  39. o sys\utime.h 
  40. o time.h 
  41. o wcstr.h 
  42.  
  43. Related Information 
  44.  
  45. o -- Reference fi not found -- 
  46.  
  47.  
  48. ΓòÉΓòÉΓòÉ 1.1. assert.h ΓòÉΓòÉΓòÉ
  49.  
  50. The assert.h include file defines the inf.assert macro.  You must include the 
  51. assert.h file when you use assert. 
  52.  
  53. The definition of assert is in an #ifndef preprocessor block.  If you have not 
  54. defined the identifier NDEBUG through a #define directive or on the compiler 
  55. command line, the assert macro tests a given expression (the assertion).  If 
  56. the assertion is false, the system prints a message to stderr and an abort 
  57. signal is raised for the program. 
  58.  
  59. If NDEBUG is defined, assert is defined to do nothing. as NULL. You can 
  60. suppress program assertions by defining NDEBUG. 
  61.  
  62. Related Information 
  63.  
  64. o -- Reference define not found -- 
  65. o -- Reference pifndef not found -- 
  66. o Include Files 
  67. o -- Reference fi not found -- 
  68.  
  69.  
  70. ΓòÉΓòÉΓòÉ 1.2. builtin.h ΓòÉΓòÉΓòÉ
  71.  
  72. The builtin.h include file contains function declarations for the following 
  73. built-in functions: 
  74.  
  75. inf._alloca         inf._disable 
  76. inf._enable         inf._facos 
  77. inf._fasin          inf._fcos 
  78. inf._fcossin        inf._fpatan 
  79. inf._fptan          inf._fsin 
  80. inf._fsincos        inf._fyl2x 
  81. inf._fyl2xp1        inf._f2xm1 
  82. inf._getTIB         inf._inp 
  83. inf._inpd           inf._inpw 
  84. inf._intrpt         inf._outp 
  85. inf._outpd          inf._outpw 
  86. inf._pdwords 
  87.  
  88. The builtin.h file also includes declaration for the following intrinsic 
  89. functions: 
  90.  
  91. inf._clear87        inf._control87 
  92. inf._status87 
  93.  
  94. The functions _clear87, _control87 and _status87 are also defined in float.h. 
  95.  
  96. The function _alloca is also defined in stdlib.h and malloc.h. 
  97.  
  98. The builtin.h file also includes a declaration for the type size_t, which is 
  99. also defined in stddef.h. 
  100.  
  101.  
  102. ΓòÉΓòÉΓòÉ 1.3. conio.h ΓòÉΓòÉΓòÉ
  103.  
  104. The conio.h include file contains definitions for the functions that involve 
  105. screen and console input/output: 
  106.  
  107. inf.cgets           inf.cprintf 
  108. inf.cputs           inf.cscanf 
  109. inf.getch           inf.getche 
  110. inf.kbhit           inf.putch 
  111. inf.ungetch 
  112.  
  113. Related Information 
  114.  
  115. o io.h 
  116. o stdio.h 
  117. o Include Files 
  118. o -- Reference fi not found -- 
  119.  
  120.  
  121. ΓòÉΓòÉΓòÉ 1.4. ctype.h ΓòÉΓòÉΓòÉ
  122.  
  123. The ctype.h include file defines functions used in character classification. 
  124. The functions defined in ctype.h are: 
  125.  
  126. inf.isalnum         inf.isalpha 
  127. inf.iscntrl         inf.isdigit 
  128. inf.isgraph         inf.islower 
  129. inf.isprint         inf.ispunct 
  130. inf.isspace         inf.isupper 
  131. inf.isxdigit        inf.tolower 
  132. inf.toupper 
  133.  
  134. The ctype.h file also includes definitions for the following Giverny 
  135. extensions: 
  136.  
  137. inf.isascii         inf.iscsym 
  138. inf.iscsymf         inf.toascii 
  139. inf._tolower        inf._toupper 
  140.  
  141. In the Giverny compiler, the ctype.h functions are all implemented as macros. 
  142.  
  143. Related Information 
  144.  
  145. o Include Files 
  146. o -- Reference fi not found -- 
  147.  
  148.  
  149. ΓòÉΓòÉΓòÉ 1.5. direct.h ΓòÉΓòÉΓòÉ
  150.  
  151. The direct.h include file contains definitions for functions that control 
  152. directories and drives. The functions defined in direct.h are: 
  153.  
  154. inf.chdir           inf._chdrive 
  155. inf.getcwd          inf._getdcwd 
  156. inf._getdrive       inf.mkdir 
  157. inf.rmdir 
  158.  
  159. Related Information 
  160.  
  161. o Include Files 
  162. o -- Reference fi not found -- 
  163.  
  164.  
  165. ΓòÉΓòÉΓòÉ 1.6. errno.h ΓòÉΓòÉΓòÉ
  166.  
  167. The errno.h include file defines the macros EDOM and ERANGE, and a modifiable 
  168. lvalue having type int called errno. It also defines the global variable 
  169. _doserrno, which reflects the OS/2 error code when an operating system error 
  170. occurs. 
  171.  
  172. See -- Reference runerrs not found -- for a list of the run-time error messages 
  173. and the errno values associated with each message. 
  174.  
  175. Note:  If you are going to test the value of errno after library function 
  176. calls, you should set it to 0 first since its value does not have to be reset 
  177. during the call. 
  178.  
  179. The definitions of errno and _doserrno are also provided in stdlib.h. 
  180.  
  181. Related Information 
  182.  
  183. o -- Reference runerrs not found -- 
  184. o stdlib.h 
  185. o Include Files 
  186. o -- Reference fi not found -- 
  187.  
  188.  
  189. ΓòÉΓòÉΓòÉ 1.7. fcntl.h ΓòÉΓòÉΓòÉ
  190.  
  191. The fcntl.h contains definitions for constants used by the inf._open and 
  192. inf._sopen functions. Definitions for these two functions are included in io.h. 
  193. Additional definitions for _sopen are provided in share.h. 
  194.  
  195. Related Information 
  196.  
  197. o io.h 
  198. o share.h 
  199. o Include Files 
  200. o -- Reference fi not found -- 
  201.  
  202.  
  203. ΓòÉΓòÉΓòÉ 1.8. float.h ΓòÉΓòÉΓòÉ
  204.  
  205. The float.h include file contains definitions of constants that specify the 
  206. ranges of floating-point data types, for example, the maximum number of digits 
  207. for objects of type double or the minimum exponent for objects of type float. 
  208. It also defines the macros that represent infinity and NaN (not-a-number) 
  209. values. 
  210.  
  211. In extended mode, float.h also contains the definitions for the following 
  212. functions that manipulate the floating-point control and status words, and for 
  213. the constants that they use: 
  214.  
  215. inf._clear87        inf._control87 
  216. inf._fpreset        inf._status87 
  217.  
  218. Related Information 
  219.  
  220. o Infinity and NaN Support 
  221. o -- Reference fltvar not found -- 
  222. o Include Files 
  223. o -- Reference fi not found -- 
  224.  
  225.  
  226. ΓòÉΓòÉΓòÉ 1.9. io.h ΓòÉΓòÉΓòÉ
  227.  
  228. The io.h include file contains definitions for the following file handle and 
  229. low-level input/output functions: 
  230.  
  231. inf.access          inf.chmod 
  232. inf.chsize          inf.close 
  233. inf.creat           inf.dup 
  234. inf.dup2            inf.eof 
  235. inf.filele2         inf.isatty 
  236. inf.lseek           inf.open 
  237. inf.read            inf.remove 
  238. inf.rename          inf.setmode 
  239. inf.sopen           inf.tell 
  240. inf.umask           inf.unlink 
  241. inf.write 
  242.  
  243. Two additional functions, inf._fstat and inf._stat, are defined in sys\stat.h. 
  244.  
  245. Constants required by the _open and _sopen functions are provided in fcntl.h. 
  246. Additional constants used by _sopen are defined in share.h. 
  247.  
  248. The _unlink function is also defined in stdio.h. 
  249.  
  250. Related Information 
  251.  
  252. o fcntl.h 
  253. o share.h 
  254. o sys\stat.h 
  255. o stdlib.h 
  256. o conio.h 
  257. o stdio.h 
  258. o Include Files 
  259. o -- Reference fi not found -- 
  260.  
  261.  
  262. ΓòÉΓòÉΓòÉ 1.10. limits.h ΓòÉΓòÉΓòÉ
  263.  
  264. The limits.h include file contains definitions of constants that specify the 
  265. ranges of integer and character data types;  for example, the maximum value for 
  266. an object of type char. 
  267.  
  268. Related Information 
  269.  
  270. o -- Reference ch not found -- 
  271. o -- Reference intvar not found -- 
  272. o Include Files 
  273. o -- Reference fi not found -- 
  274.  
  275.  
  276. ΓòÉΓòÉΓòÉ 1.11. locale.h ΓòÉΓòÉΓòÉ
  277.  
  278. The locale.h include file contains declarations for the inf.setlocale and 
  279. inf.localeconv library functions. These functions are useful for changing the C 
  280. locale when creating applications for international markets. 
  281.  
  282. locale.h also contains the declaration for the type struct lconv and the 
  283. following macro definitions: 
  284.  
  285. NULL                LC_ALL 
  286. LC_COLLATE          LC_CTYPE 
  287. LC_MONETARY         LC_NUMERIC 
  288. LC_TIME             LC_C_TOD 
  289. LC_C                LC_C_FRANCE 
  290. LC_C_GERMANY        LC_C_ITALY 
  291. LC_C_JAPAN          LC_C_SPAIN 
  292. LC_C_UK             LC_C_USA 
  293.  
  294. Related Information 
  295.  
  296. o Include Files 
  297. o -- Reference fi not found -- 
  298.  
  299.  
  300. ΓòÉΓòÉΓòÉ 1.12. malloc.h ΓòÉΓòÉΓòÉ
  301.  
  302. The malloc.h include file contains definitions for the following memory 
  303. allocation functions: 
  304.  
  305. inf._alloca         inf.calloc 
  306. inf._debug_calloc   inf._debug_free 
  307. inf._debug_malloc   inf._debug_heapmin 
  308. inf._debug_realloc  inf._dump_allocated 
  309. inf.free            inf._heap_check 
  310. inf.malloc          inf.realloc 
  311.  
  312. It also includes a definition for the type size_t. 
  313.  
  314. The SAA definitions of calloc, free, malloc, and realloc are provided in 
  315. stdlib.h, as are _alloca and _heapmin. 
  316.  
  317. The _debug_calloc, _debug_free, _debug_malloc, _debug_heapmin, _debug_realloc, 
  318. _dump_allocated, and _heap_check functions are also defined as standard 
  319. extensions in stdlib.h. Note that to use these functions, you must also define 
  320. the __DEBUG_ALLOC__ macro. See Memory Management Functions for more information 
  321. about these functions. 
  322.  
  323. The malloc.h include file also defines a number of far and near pointer macros 
  324. to the corresponding SAA or standard library function. These macros are: 
  325.  
  326. _fcalloc            _ffree 
  327. _fheapmin           _fmalloc 
  328. _frealloc           _ncalloc 
  329. _nfree              _nheapmin 
  330. _nmalloc            _nrealloc 
  331.  
  332. These macros are also defined in stdlib.h.. 
  333.  
  334. Related Information 
  335.  
  336. o stdlib.h 
  337. o Include Files 
  338. o -- Reference fi not found -- 
  339.  
  340.  
  341. ΓòÉΓòÉΓòÉ 1.13. math.h ΓòÉΓòÉΓòÉ
  342.  
  343. The math.h include file contains function declarations for all the 
  344. floating-point math functions: 
  345.  
  346. inf.acos            inf.asin 
  347. inf.atan            inf.atan2 
  348. inf.bessel          inf.ceil 
  349. inf.cos             inf.cosh 
  350. inf.erf             inf.erfc 
  351. inf.exp             inf.fabs 
  352. inf.floor           inf.fmod 
  353. inf.frexp           inf.gamma 
  354. inf.hypot           inf.ldexp 
  355. inf.log             inf.log10 
  356. inf.modf            inf.pow 
  357. inf.sin             inf.sinh 
  358. inf.sqrt            inf.tan 
  359. inf.tanh 
  360.  
  361. Note:  bessel does not correspond to a single function but to the functions 
  362.        named _j0, _j1, _jn, _y0, _y1, and _yn. 
  363.  
  364. The math.h file also includes definitions for the following Giverny extensions: 
  365.  
  366. inf._atold          -- Link Reference cabs not found --cabs 
  367. inf.matherr 
  368.  
  369. The _atold function is also defined in stdlib.h. 
  370.  
  371. The math.h include file defines the macros HUGE, _LHUGE, HUGE_VAL, and 
  372. _LHUGE_VAL, which expand to a positive double expression or to infinity. 
  373.  
  374. For all mathematical functions, a domain error occurs when an input argument is 
  375. outside the range of values allowed for that function.  In the event of a 
  376. domain error, errno is set to the value of EDOM. 
  377.  
  378. A range error occurs if the result of the function cannot be represented in a 
  379. double value.  If the magnitude of the result is too large (overflow), the 
  380. function returns the positive or negative value of the macro HUGE_VAL, and sets 
  381. errno to ERANGE.  If the result is too small (underflow), the function returns 
  382. zero. You can define a macro _FP_INLINE to inline the functions sin, cos, tan, 
  383. atan, acos and asin. 
  384.  
  385. Related Information 
  386.  
  387. o stdlib.h 
  388. o Include Files 
  389. o -- Reference fi not found -- 
  390.  
  391.  
  392. ΓòÉΓòÉΓòÉ 1.14. memory.h ΓòÉΓòÉΓòÉ
  393.  
  394. The memory.h include file contains definitions for the following buffer 
  395. manipulation functions: 
  396.  
  397. inf.memccpy         inf.memchr 
  398. inf.memcmp          inf.memcpy 
  399. inf.memicmp         inf.memset 
  400.  
  401. The SAA definitions of these functions are provided in string.h. 
  402.  
  403. The memory.h include file also defines a number of far and near pointer macros 
  404. to the corresponding SAA or standard library function.  These macros are: 
  405.  
  406. _fmemccpy           _fmemchr 
  407. _fmemcmp            _fmemcpy 
  408. _fmemicmp           _fmemset 
  409.  
  410. These macros are also defined in string.h. 
  411.  
  412. Related Information 
  413.  
  414. o string.h 
  415. o Include Files 
  416. o -- Reference fi not found -- 
  417.  
  418.  
  419. ΓòÉΓòÉΓòÉ 1.15. process.h ΓòÉΓòÉΓòÉ
  420.  
  421. The process.h include file contains definitions for the process control 
  422. functions. The functions defined in this file are: 
  423.  
  424. inf.abort           inf._beginthread 
  425. inf.cwait           inf._endthread 
  426. inf.execl           inf.execle 
  427. inf.execlp          inf.execlpe 
  428. inf.execv           inf.execve 
  429. inf.execvp          inf.execvpe 
  430. inf.exit            inf._exit 
  431. inf.getpid          inf.spawnl 
  432. inf.spawnle         inf.spawnlp 
  433. inf.spawnlpe        inf.spawnv 
  434. inf.spawnve         inf.spawnvp 
  435. inf.spawnvpe        inf.system 
  436. inf.wait 
  437.  
  438. The SAA definitions of abort, exit, and system are provided in stdlib.h, as are 
  439. those of _beginthread and _endthread. 
  440.  
  441. Related Information 
  442.  
  443. o stdlib.h 
  444. o Include Files 
  445. o -- Reference fi not found -- 
  446.  
  447.  
  448. ΓòÉΓòÉΓòÉ 1.16. search.h ΓòÉΓòÉΓòÉ
  449.  
  450. The search.h include file contains the definitions for the following search 
  451. functions: 
  452.  
  453. inf.bsearch         inf.lfind 
  454. inf.lsearch         inf.qsort 
  455.  
  456. It also defines the types size_t and _compare_t. 
  457.  
  458. The SAA definitions for bsearch and qsort are provided in stdlib.h. 
  459.  
  460. Related Information 
  461.  
  462. o stdlib.h 
  463. o Include Files 
  464. o -- Reference fi not found -- 
  465.  
  466.  
  467. ΓòÉΓòÉΓòÉ 1.17. setjmp.h ΓòÉΓòÉΓòÉ
  468.  
  469. The setjmp.h include file contains function declarations for the inf.setjmp and 
  470. inf.longjmp functions.  It also defines a buffer type, jmp_buf, that the setjmp 
  471. and longjmp functions use to save and restore the program state. 
  472.  
  473. Related Information 
  474.  
  475. o Include Files 
  476. o -- Reference fi not found -- 
  477.  
  478.  
  479. ΓòÉΓòÉΓòÉ 1.18. share.h ΓòÉΓòÉΓòÉ
  480.  
  481. The share.h include file defines constants used by the following functions: 
  482.  
  483. inf._creat          inf._fdopen 
  484. inf._open           inf._sopen 
  485.  
  486. The definitions for the above functions are included in io.h.  Additional 
  487. constants for _open and _sopen are provided in fcntl.h. 
  488.  
  489. Related Information 
  490.  
  491. o fcntl.h 
  492. o io.h 
  493. o Include Files 
  494. o -- Reference fi not found -- 
  495.  
  496.  
  497. ΓòÉΓòÉΓòÉ 1.19. signal.h ΓòÉΓòÉΓòÉ
  498.  
  499. The signal.h include file defines the values for signals.  The inf.signal and 
  500. inf.raise functions are also declared in signal.h. 
  501.  
  502. signal.h also defines the following macros: 
  503.  
  504. SIG_DFL             SIGILL 
  505. SIG_ERR             SIGINT 
  506. SIG_IGN             SIGSEGV 
  507. SIGABRT             SIGTERM 
  508. SIGFPE              SIGUSR1 
  509. SIGUSR2             SIGUSR3 
  510.  
  511. Related Information 
  512.  
  513. o Include Files 
  514. o -- Reference fi not found -- 
  515.  
  516.  
  517. ΓòÉΓòÉΓòÉ 1.20. stdarg.h ΓòÉΓòÉΓòÉ
  518.  
  519. The stdarg.h include file defines macros that allow you access to arguments in 
  520. functions with variable-length argument lists.  The macros are: inf.va_arg, 
  521. inf.va_start, and inf.va_end. stdarg.h also defines the type va_list. 
  522.  
  523.  
  524. ΓòÉΓòÉΓòÉ 1.21. stddef.h ΓòÉΓòÉΓòÉ
  525.  
  526. The stddef.h include file contains definitions of the commonly used pointers, 
  527. variables, and types, from -- Link Reference typdef not found --typedef 
  528. statements, listed below: 
  529.  
  530. ptrdiff_t        typedef for the type of the difference of two pointers 
  531.  
  532. size_t           typedef for the type of the value returned by sizeof 
  533.  
  534. wchar_t          typedef for a wide character constant. 
  535.  
  536. stddef.h also defines the macros NULL and offsetof. NULL is a pointer that is 
  537. guaranteed not to point to a data object. NULL is also defined in stdio.h and 
  538. stdlib.h. The offsetof macro expands to the number of bytes between a structure 
  539. member and the start of the structure.  The offsetof macro has the form: 
  540.  
  541. offsetof(structure_type, member)
  542.  
  543. stddef.h also contains definitions of the global variables errno and _threadid. 
  544.  
  545. The extended definition of errno is also included in stdlib.h, while the SAA 
  546. version is provided in errno.h. 
  547.  
  548. Related Information 
  549.  
  550. o errno.h 
  551. o stdlib.h 
  552. o stdio.h 
  553. o Include Files 
  554. o -- Reference fi not found -- 
  555.  
  556.  
  557. ΓòÉΓòÉΓòÉ 1.22. stdio.h ΓòÉΓòÉΓòÉ
  558.  
  559. The stdio.h include file contains definitions of constants, macros, and types, 
  560. along with function declarations for stream I/O functions.  The stream 
  561. input/output functions are: 
  562.  
  563. inf.clearerr        inf.fclose 
  564. inf.feof            inf.ferror 
  565. inf.fflush          inf.fgetc 
  566. inf.fgetpos         inf.fgets 
  567. inf.fopen           inf.fprintf 
  568. inf.fputc           inf.fputs 
  569. inf.fread           inf.freopen 
  570. inf.fscanf          inf.fseek 
  571. inf.fsetpos         inf.ftell 
  572. inf.fwrite          inf.getc 
  573. inf.getchar         inf.gets 
  574. inf.perror          inf.printf 
  575. inf.putc            inf.putchar 
  576. inf.puts            inf.remove 
  577. inf.rename          inf.rewind 
  578. inf.scanf           inf.setbuf 
  579. inf.setvbuf         inf.sprintf 
  580. inf.sscanf          inf.tmpfile 
  581. inf.tmpnam          inf.ungetc 
  582. inf.vfprintf        inf.vprintf 
  583. inf.vsprintf 
  584.  
  585. In extended mode, stdio.h also contains definitions for the following 
  586. extensions: 
  587.  
  588. inf._fcloseall      inf.fgetchar 
  589. inf.fileno          inf.flushall 
  590. inf.fputchar        inf.rmtmp 
  591. inf.tempnam         inf.unlink 
  592.  
  593. The _unlink function is also defined in io.h. 
  594.  
  595. The stdio.h file also defines the macros listed below.  You can use these 
  596. constants in your programs, but you should not alter their values. 
  597.  
  598. BUFSIZ 
  599.   BUFSIZ specifies the buffer size to be used by the setbuf library function 
  600.   when allocating buffers for stream I/O.  This value establishes the size of 
  601.   system-allocated buffers and is used with setbuf. 
  602.  
  603. EOF 
  604.   The EOF value is the value returned by an I/O function when the end of the 
  605.   file (or in some cases, an error) is found. 
  606.  
  607. FOPEN_MAX 
  608.   The FOPEN_MAX value is the number of files that can be opened simultaneously. 
  609.  
  610. FILENAME_MAX 
  611.   The FILENAME_MAX value is the longest filename supported.  If there is no 
  612.   reasonable limit, FILENAME_MAX will be the recommended size. 
  613.  
  614. L_tmpnam 
  615.   The L_tmpnam value is the size of the longest temporary name that can be 
  616.   generated by the tmpnam function. 
  617.  
  618. P_tmpdir 
  619.   This variable indicates the default directory to be used by the tempnam 
  620.   function. 
  621.  
  622. TMP_MAX 
  623.   The TMP_MAX value is the minimum number of unique file names that can be 
  624.   generated by the tmpnam function. 
  625.  
  626. NULL 
  627.   The NULL pointer value - a pointer guaranteed not to point to a data object. 
  628.   NULL is also defined in stddef.h and stdlib.h. 
  629.  
  630. The FILE structure type is defined in stdio.h.  Stream functions use a pointer 
  631. to the FILE type to get access to a given stream.  The system uses the 
  632. information in the FILE structure to maintain the stream.  The streams stdin, 
  633. stdout, and stderr are defined in stdio.h. 
  634.  
  635. The macros SEEK_CUR, SEEK_END, and SEEK_SET expand to integral constant 
  636. expressions and can be used as the third argument to fseek. 
  637.  
  638. The macros _IOFBF, _IOLBF, and _IONBF expand to integral constant expressions 
  639. with distinct values suitable for use as the third argument to the setvbuf 
  640. function. 
  641.  
  642. The type fpos_t is defined in stdio.h for use with fgetpos and fsetpos. 
  643.  
  644. Related Information 
  645.  
  646. o stddef.h 
  647. o stdlib.h 
  648. o conio.h 
  649. o io.h 
  650. o Include Files 
  651. o -- Reference fi not found -- 
  652.  
  653.  
  654. ΓòÉΓòÉΓòÉ 1.23. stdlib.h ΓòÉΓòÉΓòÉ
  655.  
  656. The stdlib.h include file contains function declarations for the following 
  657. functions: 
  658.  
  659. inf.abort           inf.abs 
  660. inf.atexit          inf.atof 
  661. inf.atoi            inf.atol 
  662. inf.bsearch         inf.calloc 
  663. inf.div             inf.exit 
  664. inf.free            inf.getenv 
  665. inf.labs            inf.ldiv 
  666. inf.malloc          inf.mblen 
  667. inf.mbstowcs        inf.mbtowc 
  668. inf.qsort           inf.rand 
  669. inf.realloc         inf.srand 
  670. inf.strtod          inf.strtol 
  671. inf.strtoul         inf.system 
  672. inf.wctomb          inf.wcstombs 
  673.  
  674. In extended mode, stdlib.h also contains definitions for the following standard 
  675. extensions: 
  676.  
  677. inf._alloca         inf._atold 
  678. inf._beginthread    inf._debug_calloc 
  679. inf._debug_free     inf._debug_heapmin 
  680. inf._debug_malloc   inf._debug_realloc 
  681. inf._dump_allocated inf.ecvt 
  682. inf._endthread      inf._exit 
  683. inf._fcvt           inf._freemod 
  684. inf._fullpath       inf._gcvt 
  685. inf._heapmin        inf._heap_check 
  686. inf._itoa           inf._loadmod 
  687. inf._lrotl          inf._lrotr 
  688. inf._ltoa           inf._makepath 
  689. inf.max             inf.min 
  690. inf.onexit          inf.__parmdwords 
  691. inf._putenv         inf._rotl 
  692. inf._rotr           inf._searchenv 
  693. inf._splitpath      inf.strtold 
  694. inf.swab            inf._ultoa 
  695.  
  696. Note that you must also define the __DEBUG_ALLOC__ macro to use the 
  697. _debug_calloc, _debug_free, _debug_malloc, _debug_realloc, _dump_allocated, 
  698. _debug_heapmin, and _heap_check functions. For more information about these 
  699. functions, see Memory Management Functions. 
  700.  
  701. The stdlib.h file also contains definitions for the following macros: 
  702.  
  703. split=yes. 
  704.  
  705. NULL The NULL pointer value. NULL is also defined in stddef.h and stdio.h. 
  706.  
  707. EXIT_SUCCESS Expands to 0; used by the atexit function. 
  708.  
  709. EXIT_FAILURE Expands to 8; used by the atexit function. 
  710.  
  711. RAND_MAX Expands to an integer representing the largest number that the RAND 
  712.   function can return. 
  713.  
  714. MB_CUR_MAX Expands to an integer representing the maximum number of bytes in a 
  715.   multibyte character for the current locale. 
  716.  
  717. For more information on the types size_t and wchar_t, see stddef.h. 
  718.  
  719. In extended mode, stdlib.h also defines the following global variables: 
  720.  
  721. _doserrno           _environ 
  722. errno               onexit_t 
  723. _osmajor            _osminor 
  724. _osmode 
  725.  
  726. The variable errno is also defined in stddef.h. The variable _doserrno and the 
  727. SAA definition of errno are provided in errno.h. 
  728.  
  729. In addition, stdlib.h defines the following far and near pointer macros to the 
  730. corresponding SAA or standard library function: 
  731.  
  732. _fcalloc            _ffree 
  733. _fmalloc            _fheapmin 
  734. _frealloc           _ncalloc 
  735. _nfree              _nmalloc 
  736. _nheapmin           _nrealloc 
  737.  
  738. These macros are also defined in malloc.h. 
  739.  
  740. Related Information 
  741.  
  742. o errno.h 
  743. o malloc.h 
  744. o stddef.h 
  745. o stdio.h 
  746. o Include Files 
  747. o -- Reference fi not found -- 
  748.  
  749.  
  750. ΓòÉΓòÉΓòÉ 1.24. string.h ΓòÉΓòÉΓòÉ
  751.  
  752. The string.h include file declares the string manipulation functions: 
  753.  
  754. inf.memchr          inf.memcmp 
  755. inf.memcpy          inf.memmove 
  756. inf.memset          inf.strcat 
  757. inf.strchr          inf.strcmp 
  758. inf.strcoll         inf.strcpy 
  759. inf.strcspn         inf.strerror 
  760. inf.strlen          inf.strncat 
  761. inf.strncmp         inf.strncpy 
  762. inf.strpbrk         inf.strrchr 
  763. inf.strspn          inf.strstr 
  764. inf.strtok          inf.strxfrm 
  765.  
  766. In extended mode, string.h also contains definitions for the following standard 
  767. extensions: 
  768.  
  769. inf.memccpy         inf.memicmp 
  770. inf.strcmpi         inf.strdup 
  771. inf._strerror       inf.stricmp 
  772. inf.strlwr          inf.strnicmp 
  773. inf.strnset         inf.strrev 
  774. inf.strset          inf.strupr 
  775.  
  776. The memxxxx functions are also included in memory.h. 
  777.  
  778. The string.h include file also defines the macro NULL and the type size_t. 
  779. These definitions are also provided in stddef.h. NULL is also defined in 
  780. stdlib.h and stdio.h. 
  781.  
  782. string.h also defines the following far  and near pointer macros to the 
  783. corresponding SAA or standard library function: 
  784.  
  785. _fmemccpy           _fmemchr 
  786. _fmemcmp            _fmemcpy 
  787. _fmemicmp           _fmemmove 
  788. _fmemset            _fstrcat 
  789. _fstrchr            _fstrcmp 
  790. _fstrcpy            _fstrcspn 
  791. _fstrdup            _fstricmp 
  792. _fstrlen            _fstrlwr 
  793. _fstrncat           _fstrncmp 
  794. _fstrncpy           _fstrnicmp 
  795. _fstrnset           _fstrpbrk 
  796. _fstrrchr           _fstrrev 
  797. _fstrset            _fstrspn 
  798. _fstrstr            _fstrtok 
  799. _fstrupr            _nstrdup 
  800.  
  801. These macros are also defined in memory.h. 
  802.  
  803. Related Information 
  804.  
  805. o stddef.h 
  806. o memory.h 
  807. o stdlib.h 
  808. o stdio.h 
  809. o Include Files 
  810. o -- Reference fi not found -- 
  811.  
  812.  
  813. ΓòÉΓòÉΓòÉ 1.25. sys\stat.h ΓòÉΓòÉΓòÉ
  814.  
  815. The sys\stat.h include file contains the definitions for the low-level 
  816. input/output functions inf._fstat and inf._stat. It also defines the structure 
  817. stat and the following types: 
  818.  
  819. dev_t               ino_t 
  820. off_t               time_t 
  821.  
  822. These types are also defined in sys\types.h. 
  823.  
  824. Other low-level I/O functions are defined in io.h. 
  825.  
  826. Related Information 
  827.  
  828. o io.h 
  829. o sys\types.h 
  830. o Include Files 
  831. o -- Reference fi not found -- 
  832.  
  833.  
  834. ΓòÉΓòÉΓòÉ 1.26. sys\timeb.h ΓòÉΓòÉΓòÉ
  835.  
  836. The sys\timeb.h include file contains the definition for the inf._ftime 
  837. function and also defines the type time_t and the structure timeb. 
  838.  
  839. Related Information 
  840.  
  841. o Include Files 
  842. o -- Reference fi not found -- 
  843.  
  844.  
  845. ΓòÉΓòÉΓòÉ 1.27. sys\types.h ΓòÉΓòÉΓòÉ
  846.  
  847. The sys\types.h include file contains the definitions for the following types: 
  848.  
  849. ino_t               time_t 
  850. dev_t               off_t 
  851.  
  852. These types are also defined in sys\stat.h. 
  853.  
  854. Related Information 
  855.  
  856. o sys\stat.h 
  857. o Include Files 
  858. o -- Reference fi not found -- 
  859.  
  860.  
  861. ΓòÉΓòÉΓòÉ 1.28. sys\utime.h ΓòÉΓòÉΓòÉ
  862.  
  863. The sys\utime.h include file contains the definitions for the inf._utime 
  864. function, the structure utimbuf, and the type time_t. 
  865.  
  866. Related Information 
  867.  
  868. o Include Files 
  869. o -- Reference fi not found -- 
  870.  
  871.  
  872. ΓòÉΓòÉΓòÉ 1.29. time.h ΓòÉΓòÉΓòÉ
  873.  
  874. The time.h include file declares the time and date functions: 
  875.  
  876. inf.asctime         inf.clock 
  877. inf.ctime           inf.difftime 
  878. inf.gmtime          inf.localtime 
  879. inf.mktime          inf.strftime 
  880. inf.time 
  881.  
  882. In extended mode, time.h also includes the definition for the standard 
  883. extensions inf._strdate, inf._strtime, and inf._tzset. 
  884.  
  885. The time.h include file also provides: 
  886.  
  887. o A structure tm containing the components of a calendar time.  See gmtime  - 
  888.   Convert Time for a list of the members of the tm structure. 
  889.  
  890. o A macro CLOCKS_PER_SEC equal to the number per second of the value returned 
  891.   by the clock function. 
  892.  
  893. o Types clock_t, time_t, and size_t. 
  894.  
  895. o The NULL pointer value. 
  896.  
  897. For more information on NULL and the type size_t, see stddef.h. 
  898.  
  899. time.h also defines the global variables _daylight, _timezone, and _tzname. 
  900.  
  901. Related Information 
  902.  
  903. o stddef.h 
  904. o Include Files 
  905. o -- Reference fi not found -- 
  906.  
  907.  
  908. ΓòÉΓòÉΓòÉ 1.30. wcstr.h ΓòÉΓòÉΓòÉ
  909.  
  910. The wcstr.h include file declares the multibyte functions: 
  911.  
  912. inf.wcscat          inf.wcschr 
  913. inf.wcscmp          inf.wcscpy 
  914. inf.wcscspn         inf.wcslen 
  915. inf.wcsncat         inf.wcsncmp 
  916. inf.wcsncpy         inf.wcspbrk 
  917. inf.wcsspn          inf.wcsrchr 
  918. inf.wcswcs 
  919.  
  920. Related Information 
  921.  
  922. o Include Files 
  923. o -- Reference fi not found -- 
  924.  
  925.  
  926. ΓòÉΓòÉΓòÉ 2. Library Functions ΓòÉΓòÉΓòÉ
  927.  
  928. This section describes the C library functions. 
  929.  
  930. Each library function listed in this section contains a format description 
  931. showing the include file that declares the function and shows the data type 
  932. returned by the function and the required data types of the arguments to the 
  933. function. The following example shows the format of the log function: 
  934.  
  935.    #include <math.h>
  936.  
  937.    double log(double x);
  938.           /* x is a dummy variable */
  939.  
  940. The example shows that you must include the file math.h in the program, that 
  941. log returns type double, and that log requires an argument x of type double. 
  942.  
  943. Examples throughout the section illustrate the function and are not necessarily 
  944. complete. 
  945.  
  946. If you are unsure of the function you want to use, see the summary of the 
  947. library functions in The C Library. 
  948.  
  949.  
  950. ΓòÉΓòÉΓòÉ 2.1. The C Library ΓòÉΓòÉΓòÉ
  951.  
  952. This section summarizes the available C library functions. Each library 
  953. function is listed according to the type of function it performs. 
  954.  
  955. Error Handling 
  956.  
  957. o assert  - Verify Condition 
  958. o atexit  - Record Program Termination Function 
  959. o _matherr - Process Math Library Errors 
  960. o perror  - Print Error Message 
  961. o raise  - Send Signal 
  962. o signal - Install Interrupt Handlers 
  963. o strerror  - Set Pointer to Runtime Error Message 
  964. o _strerror - Point to System Error String 
  965.  
  966. Process Control 
  967.  
  968. o _beginthread - Create New Thread 
  969. o _cwait - Wait for Child Process 
  970. o _disable - Disable Interrupts 
  971. o _enable - Enable Interrupts 
  972. o _endthread - Terminate Current Thread 
  973. o _exit - End Process 
  974. o _freemod - Free User DLL 
  975. o _getpid - Get Process Identifier 
  976. o _getTIBvalue - Get TIB Value 
  977. o _interrupt - Call Interrupt  Procedure 
  978. o _loadmod - Load User DLL 
  979. o _onexit - Record Termination Function 
  980. o _putenv - Modify Environment Variables 
  981. o _searchenv - Search for File 
  982.  
  983. File and Directory Management 
  984.  
  985. o _chdir - Change Current Working Directory 
  986. o _chdrive - Change Current Working Drive 
  987. o _fstat - Information about Open File 
  988. o _fullpath - Get Full Path Name of Partial Path 
  989. o _getcwd - Get Path Name of Current Directory 
  990. o _getdcwd - Get Full Path Name of Current Directory 
  991. o _getdrive - Get Current Working Drive 
  992. o _makepath - Create Path 
  993. o _mkdir - Create New Directory 
  994. o _rmdir - Remove Directory 
  995. o _splitpath - Decompose Path Name 
  996. o _stat - Get Information about File or Directory 
  997.  
  998. Searching and Sorting 
  999.  
  1000. o bsearch  - Search Arrays 
  1001. o _lfind - _lsearch - Find Key in Array 
  1002. o _lfind - _lsearch - Find Key in Array 
  1003. o qsort  - Sort Array 
  1004.  
  1005. Mathematical 
  1006.  
  1007. o abs  - Integer Absolute Value 
  1008. o acos  - Arc Cosine 
  1009. o asin  - Arc Sine 
  1010. o atan - atan2  - Arc Tangent 
  1011. o -- Reference cabs not found -- 
  1012. o ceil - Integer >= Argument 
  1013. o cos  - Cosine 
  1014. o cosh  - Hyperbolic Cosine 
  1015. o div  - Quotient and Remainder 
  1016. o erf - erfc  - Error Functions 
  1017. o exp  - Exponential Function 
  1018. o fabs  - Floating-Point Absolute Value 
  1019. o _facos - Calculate Arccosine 
  1020. o _fasin - Calculate Arcsine 
  1021. o _fcos - Calculate Cosine 
  1022. o _fcossin - Calculate Cosine and Sine 
  1023. o floor - Integer <= Argument 
  1024. o fmod  - Floating-Point Remainder 
  1025. o _fpatan - Calculate Arctangent 
  1026. o _fptan - Calculate Tangent 
  1027. o frexp  - Separate Floating-Point Value 
  1028. o _fsin - Calculate Sine 
  1029. o _fsincos - Calculate Sine and Cosine 
  1030. o _fsqrt -  Compute Square Root 
  1031. o _fyl2x - Compute 
  1032. o _fyl2xp1 -  Calculate 
  1033. o _f2xm1 -  Calculate 2** 
  1034. o gamma  - Gamma Function 
  1035. o hypot  - Calculate Hypotenuse 
  1036. o labs  - long Absolute Value 
  1037. o ldexp  - Multiply by a Power of Two 
  1038. o ldiv  - Long Division 
  1039. o log  - Calculate Natural Logarithm 
  1040. o log10  - Calculate Base 10 Logarithm 
  1041. o _lrotl - _lrotr - Rotate Bits 
  1042. o _lrotl - _lrotr - Rotate Bits 
  1043. o max - Return Larger of Two Values 
  1044. o min - Return Lesser of Two Values 
  1045. o modf  - Separate Floating-Point Value 
  1046. o pow  - Compute Power 
  1047. o _rotl - _rotr - Bit Rotation 
  1048. o _rotl - _rotr - Bit Rotation 
  1049. o sin  - Sine 
  1050. o sinh  - Hyperbolic Sine 
  1051. o sqrt  - Calculate Square Root 
  1052. o tan  - Tangent 
  1053. o tanh  - Hyperbolic Tangent 
  1054. o Bessel Functions 
  1055.  
  1056. Floating-Point Unit Control 
  1057.  
  1058. o _clear87 - Clear Floating-Point Statu         s Word 
  1059. o _control87 - Set Floating-Point Status         Word 
  1060. o _fpreset - Reset Floating-Point Unit 
  1061. o _status87 - Get Floating-Point Status Word 
  1062.  
  1063. Time Manipulation 
  1064.  
  1065. o asctime  - Convert Time 
  1066. o clock  - Determine Processor Time 
  1067. o ctime  - Convert Time 
  1068. o difftime  - Compute Time Difference 
  1069. o _ftime - Store Current Time 
  1070. o gmtime  - Convert Time 
  1071. o localtime  - Convert Time 
  1072. o mktime  - Convert Local Time 
  1073. o _strdate - Copy Current Date 
  1074. o strftime  - Formatted Time Conversion 
  1075. o _strtime - Copy Time 
  1076. o time  - Determine Current Time 
  1077. o _tzset - Assign Values to Locale Information 
  1078. o _utime - Set Modification Time 
  1079.  
  1080. Type Conversion 
  1081.  
  1082. o atof  - Convert Character Strings 
  1083. o atoi  - Convert Character Strings 
  1084. o atol  - Convert Character Strings 
  1085. o _atold - Convert ASCII String to Lo         ng Double 
  1086. o _ecvt - Convert Floating-Point to         Character 
  1087. o _fcvt - Convert Floating-Point to         String 
  1088. o _gcvt - Convert Floating-Point to String 
  1089. o _itoa - Convert Integer to String 
  1090. o _ltoa - Convert Long Integer to String 
  1091. o strtod  - Convert Character String to Numeric 
  1092. o strtol  - Convert Character String to Numeric 
  1093. o strtold - Convert String to Long Double 
  1094. o strtoul  - Convert String Segment to Unsigned Integer 
  1095. o _ultoa - Convert Unsigned Long Integer to Str         ing 
  1096.  
  1097. Stream Input/Output 
  1098.  
  1099. Formatted Input/Output 
  1100.  
  1101. o fprintf  - Formatted Write 
  1102. o fscanf  - Read Formatted Data 
  1103. o printf  - Formatted Print 
  1104. o scanf  - Read Data 
  1105. o sprintf  - Formatted Print to Buffer 
  1106. o sscanf  - Read Data 
  1107. o vfprintf  - Print Argument Data 
  1108. o vprintf  - Print Argument Data 
  1109. o vsprintf  - Print Argument Data 
  1110.  
  1111. Character and String Input/Output 
  1112.  
  1113. o fgetc  - Read a Character 
  1114. o _fgetchar - Read Single Character from stdin 
  1115. o fgets  - Read a String 
  1116. o fputc  - Write a Character 
  1117. o _fputchar - Write Character 
  1118. o fputs  - Print Strings 
  1119. o getc - getchar  - Read a Character 
  1120. o gets  - Read a Line 
  1121. o putc - putchar  - Write a Character 
  1122. o putc - putchar  - Write a Character 
  1123. o puts  - Write a String 
  1124. o ungetc  - Push Character onto Input Stream 
  1125.  
  1126. Direct Input/Output 
  1127.  
  1128. o clearerr  - Reset Error Indicators 
  1129. o feof  - Test End-of-File Indicator 
  1130. o ferror  - Test for Read/Write Errors 
  1131. o fread  - Read Items 
  1132. o fwrite  - Write Items 
  1133.  
  1134. File Positioning 
  1135.  
  1136. o fgetpos  - Get File Position 
  1137. o fseek  - Reposition File Position 
  1138. o fsetpos  - Set File Position 
  1139. o ftell  - Get Current Position 
  1140. o _lseek - Move File Pointer 
  1141. o rewind  - Adjust Current File Position 
  1142.  
  1143. File Access 
  1144.  
  1145. o fclose  - Close Stream 
  1146. o _fcloseall - Close All Open Streams 
  1147. o _fdopen - Associates Input Or Output With File 
  1148. o fflush  - Write Buffer to File 
  1149. o _flushall - Write Buffers to Files 
  1150. o fopen  - Open Files 
  1151. o freopen  - Redirect Open Files 
  1152. o setbuf  - Control Buffering 
  1153. o _setmode - Set File Translation Mode 
  1154. o setvbuf  - Control Buffering 
  1155.  
  1156. File Operations 
  1157.  
  1158. o _fileno - File Handle 
  1159. o remove  - Delete File 
  1160. o rename  - Rename File 
  1161. o _rmtmp - Remove Temporary Files 
  1162. o _tempnam - Produce Temporary File Name 
  1163. o tmpfile  - Create Temporary File 
  1164. o tmpnam  - Produce Temporary File Name 
  1165. o _unlink - Delete File 
  1166.  
  1167. Low-Level Input/Output 
  1168.  
  1169. o _inp - Read Byte from Input Port 
  1170. o _inpd - Read Double Word from Input Port 
  1171. o _inpw - Read Unsigned Short from Input Port 
  1172. o _outp - Write Byte to Output Port 
  1173. o _outpd - Write Double Word to Output Port 
  1174. o _outpw - Write Word to Output Port 
  1175. o _umask - Sets File Mask of Current Process 
  1176.  
  1177.   Character and String Input/Output 
  1178.  
  1179.    - _cgets - Read String of Characters from Keyboard 
  1180.    - _cprintf - Print Characters to Screen 
  1181.    - _cputs - Write String to Screen 
  1182.    - _cscanf - Read Data from Keyboard 
  1183.    - _getch - _getche - Read Character from Keyboard 
  1184.    - _kbhit - Test for Keystroke 
  1185.    - _putch - Write Character to Screen 
  1186.    - _ungetch - Push Character Back to Keyboard 
  1187.  
  1188.      File Positioning 
  1189.  
  1190.       o _eof - Determine End of File 
  1191.       o _tell - Get Pointer Position 
  1192.  
  1193.         File Access 
  1194.  
  1195.          - _access - Determine Access Mode 
  1196.          - _chmod - Change File Permission Setting 
  1197.          - _close - Closes File Associated with Handle 
  1198.          - _creat - Create New File 
  1199.          - _dup - Second Handle with Open File 
  1200.          - _dup2 - Second Handle with Open File 
  1201.          - _isatty - Test Handle for Character Device 
  1202.          - _open - Open File 
  1203.          - _read - Read Into Buffer 
  1204.          - _sopen - Open Shared File 
  1205.          - _read - Read Into Buffer 
  1206.  
  1207.         File Operations 
  1208.  
  1209.          - _chsize - Alter Length of File 
  1210.          - _filelength - Determine File Length 
  1211.  
  1212.         Handling Argument Lists 
  1213.  
  1214.          - va_arg - va_end - va_start  - Access Function Arguments 
  1215.  
  1216.         Pseudorandom Numbers 
  1217.  
  1218.          - rand  - Generate Random Number 
  1219.          - srand  - Set Seed for rand Function 
  1220.  
  1221.         Dynamic Memory Management 
  1222.  
  1223.          - _alloca - Temporarily Reserve Storag         e Block 
  1224.          - calloc  - Reserve and Initialize Storage 
  1225.          - free  - Release Storage Blocks 
  1226.          - _heapmin - Release Unused Memory in the Heap 
  1227.          - malloc  - Reserve Storage Block 
  1228.          - realloc  - Change Reserved Storage Block Size 
  1229.  
  1230.            Memory Objects 
  1231.  
  1232.             o memccpy - Copy Bytes 
  1233.             o memchr  - Search Buffer 
  1234.             o memcmp  - Compare Buffers 
  1235.             o memcpy  - Copy Bytes 
  1236.             o memicmp - Compare Bytes 
  1237.             o memmove  - Copy Bytes 
  1238.             o memset  - Set Bytes to Value 
  1239.             o _swab - Swap Adjacent Bytes 
  1240.  
  1241.            Environment Interaction 
  1242.  
  1243.             o abort  - Stop a Program 
  1244.             o exit  - End Program 
  1245.             o getenv  - Search for Environment Variables 
  1246.             o localeconv  - Query Locale Conventions 
  1247.             o longjmp  - Restore Stack Environment 
  1248.             o __parmdwords - Get Number of dwords in Parameter List 
  1249.             o setjmp  - Preserve Environment 
  1250.             o setlocale  - Sets Locale 
  1251.             o system - Invoke the Command Processor 
  1252.  
  1253.            String Operations 
  1254.  
  1255.             o strcat  - Concatenate Strings 
  1256.             o strchr  - Search for Character 
  1257.             o strcmp  - Compare Strings 
  1258.             o strcmpi - Compare Strings 
  1259.             o strcoll  - Compares Strings 
  1260.             o strcpy  - Copy Strings 
  1261.             o strcspn  - Compare Strings 
  1262.             o strdup - Duplicate String 
  1263.             o stricmp - Compare Strings 
  1264.             o strlen  - String Length 
  1265.             o strncat  - Concatenate Strings 
  1266.             o strncmp  - Compare Strings 
  1267.             o strncpy  - Copy Strings 
  1268.             o strnicmp - Compare Strings 
  1269.             o strnset - strset - Set Characters in String 
  1270.             o strpbrk  - Find Characters in String 
  1271.             o strrchr  - Find Last Occurrence of Character in String 
  1272.             o strrev - Reverse String 
  1273.             o strnset - strset - Set Characters in String 
  1274.             o strspn  - Search Strings 
  1275.             o strstr  - Locate Substring 
  1276.             o strtok  - Tokenize String 
  1277.             o strxfrm  - Transforms Strings 
  1278.  
  1279.            Character Testing 
  1280.  
  1281.             o isalnum to isxdigit  - Test Integer Value 
  1282.             o isascii - Test Integer Values 
  1283.             o _iscsym - _iscsymf - Test Integer 
  1284.             o -- Reference iscsymf not found -- 
  1285.  
  1286.            Character Case Mapping 
  1287.  
  1288.             o strlwr - Convert Uppercase to Lowercase 
  1289.             o strupr - Convert Lowercase to Uppercase 
  1290.             o tolower - toupper  - Convert Character Case 
  1291.             o tolower - toupper  - Convert Character Case 
  1292.             o tolower - toupper  - Convert Character Case 
  1293.             o tolower - toupper  - Convert Character Case 
  1294.  
  1295.            Multibyte Character Manipulation 
  1296.  
  1297.             o mblen  - Multibyte String Length 
  1298.             o mbstowcs  - Convert Multibyte Characters to wchar_t Characters 
  1299.             o mbtowc  - Convert Multibyte Character to wchar_t 
  1300.             o wctomb  - Converts wchar_t Character to Multibyte Character 
  1301.             o wcstombs  - Converts wchar_t String to Multibyte Character String 
  1302.             o wcscat  - Append wchar_t Strings 
  1303.             o wcschr  - Search wchar_t String for Given wchar_t 
  1304.             o wcscmp  - Compare wchar_t Strings 
  1305.             o wcscpy  - Copy wchar_t Strings 
  1306.             o wcscspn  - Find Offset of First wchar_t Match 
  1307.             o wcslen  - Calculates Length of wchar_t String 
  1308.             o wcsncat  - Concatenates wchar_t Strings 
  1309.             o wcsncmp  - Compares wchar_t Strings 
  1310.             o wcsncpy  - Copies wchar_t Strings 
  1311.             o wcspbrk  - Locates wchar_t Characters in String 
  1312.             o wcsspn  - Searches wchar_t Characters in String 
  1313.             o wcsrchr  - Locates wchar_t Character in String 
  1314.             o wcswcs  - Locates wchar_t Substring in wchar_t String 
  1315.  
  1316.            C Set/2 Extensions 
  1317.  
  1318.             o _access - Determine Access Mode 
  1319.             o _alloca - Temporarily Reserve Storag         e Block 
  1320.             o _atold - Convert ASCII String to Lo         ng Double 
  1321.             o _beginthread - Create New Thread 
  1322.             o -- Reference cabs not found -- 
  1323.             o _cgets - Read String of Characters from Keyboard 
  1324.             o _chdir - Change Current Working Directory 
  1325.             o _chdrive - Change Current Working Drive 
  1326.             o _chmod - Change File Permission Setting 
  1327.             o _chsize - Alter Length of File 
  1328.             o _clear87 - Clear Floating-Point Statu         s Word 
  1329.             o _close - Closes File Associated with Handle 
  1330.             o _control87 - Set Floating-Point Status         Word 
  1331.             o _cprintf - Print Characters to Screen 
  1332.             o _cputs - Write String to Screen 
  1333.             o _creat - Create New File 
  1334.             o _cscanf - Read Data from Keyboard 
  1335.             o _cwait - Wait for Child Process 
  1336.             o _dup - Second Handle with Open File 
  1337.             o _dup2 - Second Handle with Open File 
  1338.             o _ecvt - Convert Floating-Point to         Character 
  1339.             o _endthread - Terminate Current Thread 
  1340.             o _eof - Determine End of File 
  1341.             o _execl - _execvp - Load and Run Child Process 
  1342.             o _exit - End Process 
  1343.             o _fcloseall - Close All Open Streams 
  1344.             o _fcvt - Convert Floating-Point to         String 
  1345.             o _fdopen - Associates Input Or Output With File 
  1346.             o _fgetchar - Read Single Character from stdin 
  1347.             o _filelength - Determine File Length 
  1348.             o _fileno - File Handle 
  1349.             o _flushall - Write Buffers to Files 
  1350.             o _fpreset - Reset Floating-Point Unit 
  1351.             o _fputchar - Write Character 
  1352.             o _freemod - Free User DLL 
  1353.             o _fstat - Information about Open File 
  1354.             o _ftime - Store Current Time 
  1355.             o _fullpath - Get Full Path Name of Partial Path 
  1356.             o _gcvt - Convert Floating-Point to String 
  1357.             o _getch - _getche - Read Character from Keyboard 
  1358.             o _getcwd - Get Path Name of Current Directory 
  1359.             o _getdcwd - Get Full Path Name of Current Directory 
  1360.             o _getdrive - Get Current Working Drive 
  1361.             o _getpid - Get Process Identifier 
  1362.             o _heapmin - Release Unused Memory in the Heap 
  1363.             o isascii - Test Integer Values 
  1364.             o _isatty - Test Handle for Character Device 
  1365.             o _iscsym - _iscsymf - Test Integer 
  1366.             o _itoa - Convert Integer to String 
  1367.             o _kbhit - Test for Keystroke 
  1368.             o _lfind - _lsearch - Find Key in Array 
  1369.             o _loadmod - Load User DLL 
  1370.             o _lrotl - _lrotr - Rotate Bits 
  1371.             o _lseek - Move File Pointer 
  1372.             o _ltoa - Convert Long Integer to String 
  1373.             o _makepath - Create Path 
  1374.             o _matherr - Process Math Library Errors 
  1375.             o max - Return Larger of Two Values 
  1376.             o memccpy - Copy Bytes 
  1377.             o memicmp - Compare Bytes 
  1378.             o min - Return Lesser of Two Values 
  1379.             o _mkdir - Create New Directory 
  1380.             o _onexit - Record Termination Function 
  1381.             o _open - Open File 
  1382.             o __parmdwords - Get Number of dwords in Parameter List 
  1383.             o _putch - Write Character to Screen 
  1384.             o _putenv - Modify Environment Variables 
  1385.             o _read - Read Into Buffer 
  1386.             o _rmdir - Remove Directory 
  1387.             o _rmtmp - Remove Temporary Files 
  1388.             o _rotl - _rotr - Bit Rotation 
  1389.             o _searchenv - Search for File 
  1390.             o _setmode - Set File Translation Mode 
  1391.             o signal - Install Interrupt Handlers 
  1392.             o _sopen - Open Shared File 
  1393.             o _spawnl - _spawnvpe - Start and Run Child Processes 
  1394.             o _splitpath - Decompose Path Name 
  1395.             o _stat - Get Information about File or Directory 
  1396.             o _status87 - Get Floating-Point Status Word 
  1397.             o strcmpi - Compare Strings 
  1398.             o _strdate - Copy Current Date 
  1399.             o strdup - Duplicate String 
  1400.             o _strerror - Point to System Error String 
  1401.             o stricmp - Compare Strings 
  1402.             o strlwr - Convert Uppercase to Lowercase 
  1403.             o strnicmp - Compare Strings 
  1404.             o strnset - strset - Set Characters in String 
  1405.             o strrev - Reverse String 
  1406.             o _strtime - Copy Time 
  1407.             o strtold - Convert String to Long Double 
  1408.             o strupr - Convert Lowercase to Uppercase 
  1409.             o _swab - Swap Adjacent Bytes 
  1410.             o system - Invoke the Command Processor 
  1411.             o _tell - Get Pointer Position 
  1412.             o _tempnam - Produce Temporary File Name 
  1413.             o toascii - _tolower - _toupper - Convert Character 
  1414.             o _tzset - Assign Values to Locale Information 
  1415.             o _ultoa - Convert Unsigned Long Integer to Str         ing 
  1416.             o _umask - Sets File Mask of Current Process 
  1417.             o _ungetch - Push Character Back to Keyboard 
  1418.             o _unlink - Delete File 
  1419.             o _utime - Set Modification Time 
  1420.             o _wait - Wait for Child Process 
  1421.             o _write - Writes from Buffer to File 
  1422.  
  1423.  
  1424. ΓòÉΓòÉΓòÉ 2.2. Intrinsic Functions ΓòÉΓòÉΓòÉ
  1425.  
  1426. By default, the Giverny compiler generates code instead of a function call for 
  1427. the following C library functions: 
  1428.  
  1429. abs                 _clear87 
  1430. _control87          fabs 
  1431. labs                memchr 
  1432. memcmp              memcpy 
  1433. memmove             memset 
  1434. setjmp              _status87 
  1435. strcat              strchr 
  1436. strcmp              strcpy 
  1437. strlen              strncat 
  1438. strncmp             strncpy 
  1439. strrchr 
  1440.  
  1441. When you #include the appropriate header file in which the function prototype 
  1442. and the #define and #pragma statements for the function are found, the Giverny 
  1443. compiler generates code instead of a function call for these functions. 
  1444.  
  1445. You can override the header either by undefining the macro or by placing the 
  1446. name of the function in parentheses, thus disabling the processor substitution. 
  1447. The function then remains a function call, and is not replaced by the code. The 
  1448. size of your object module is reduced, but your application program executes 
  1449. more slowly. 
  1450.  
  1451. Note:  The following functions are built-in functions, meaning they do not have 
  1452.        any backing library functions, and are always inlined: 
  1453.  
  1454. _alloca             _disable 
  1455. _enable             _fcos 
  1456. _fcossin            _fpatan 
  1457. _fptan              _fsin 
  1458. _fsincos            _fyl2x 
  1459. _fyl2xp1            _f2xm1 
  1460. _getTIBvalue        _inp 
  1461. _inpd               _inpw 
  1462. _interrupt          _outp 
  1463. _outpd              _outpw 
  1464. __parmdwords 
  1465.  
  1466. The built-in functions are all defined in <builtin.h>, in addition to the 
  1467. standard header definitions. 
  1468.  
  1469. Related Information 
  1470.  
  1471. o Include Files 
  1472. o -- Reference define not found -- 
  1473. o -- Reference pragma not found -- 
  1474. o Library Functions 
  1475. ,* .when 'ipf' insert 
  1476.  
  1477.  
  1478. ΓòÉΓòÉΓòÉ 2.3. Memory Management Functions ΓòÉΓòÉΓòÉ
  1479.  
  1480. The Giverny compiler provides a set of seven functions to assist you in 
  1481. debugging memory management problems associated with memory allocated by the 
  1482. calloc, malloc, or realloc functions. The debug memory management functions are 
  1483. provided in both the standard and subsystem development libraries, and can help 
  1484. you find where memory is being allocated, written to, or freed incorrectly. 
  1485.  
  1486. This section describes the following debug memory management functions, and 
  1487. provides the format and an example for each: 
  1488.  
  1489. o _debug_calloc, _debug_free, _debug_heapmin _debug_malloc, _debug_realloc 
  1490.  
  1491.   These functions are variations of the calloc, free, _heapmin, malloc, and 
  1492.   realloc functions respectively. They build internal data structures to allow 
  1493.   checks to be made on the run-time heap. Each call to one of these functions 
  1494.   also automatically calls the _heap_check function. 
  1495.  
  1496. o _heap_check 
  1497.  
  1498.   This function checks all memory blocks allocated or freed by the functions 
  1499.   listed above to make sure that no overwriting has occurred outside the bounds 
  1500.   of allocated blocks or in a free memory block. 
  1501.  
  1502. o _dump_allocated 
  1503.  
  1504.   This function prints out information about each memory block currently 
  1505.   allocated by the functions listed above. 
  1506.  
  1507. All output from these functions is sent to the OS/2 file handle 2, which is 
  1508. usually associated with stderr. 
  1509.  
  1510. Note:  The information provided by these functions is Diagnosis, Modification, 
  1511.        and Tuning information only. It is not intended to be used as a 
  1512.        programming interface. 
  1513.  
  1514. Using the Debug Memory Management Functions 
  1515.  
  1516. Related Information 
  1517.  
  1518. o Library Functions 
  1519.  
  1520.  
  1521. ΓòÉΓòÉΓòÉ 2.3.1. Using the Debug Memory Management Functions ΓòÉΓòÉΓòÉ
  1522.  
  1523. To use the debug memory management functions: 
  1524.  
  1525.  1. Define the macro __DEBUG_ALLOC__ 
  1526.  
  1527.     This macro defines the malloc, calloc, realloc, free, and _heapmin 
  1528.     functions to the corresponding debug memory management function.  You can 
  1529.     define the macro in your source files, or on the command line (using the /D 
  1530.     option). 
  1531.  
  1532.  2. Include stdlib.h in each of your source files. 
  1533.  
  1534.     If you define __DEBUG_ALLOC__ in your source file, the definition must 
  1535.     appear before the #include directive. 
  1536.  
  1537.  3. Place a #pragma strings(readonly) directive at the top of each source file. 
  1538.  
  1539.     This directive is not essential, but it ensures that the file name passed 
  1540.     to the debug memory management functions cannot be overwritten, and that 
  1541.     only one copy of the file name string is included in the object module. 
  1542.  
  1543. Once you have followed the above steps, the _debug_malloc, _debug_calloc, 
  1544. _debug_realloc, _debug_free, and _debug_heapmin functions are automatically 
  1545. called in place of the regular memory management functions in your code. Do not 
  1546. parenthesize any calls to these functions, because parentheses will disable the 
  1547. definition of the function name to the debug function name. 
  1548.  
  1549. The _heap_check function is also called automatically by each of these 
  1550. functions, or you can call it explicitly. To use the _dump_allocated function, 
  1551. you must explicitly call it in your code. 
  1552.  
  1553. Note: 
  1554.  
  1555. o The debug memory management functions are not available if you are using 
  1556.   tiled memory (with the /Gt compiler option). 
  1557. o All memory blocks allocated by the _debug_malloc, _debug_calloc, and 
  1558.   _debug_realloc functions must be freed using _debug_free, not the free 
  1559.   function. If you do not use _debug_free, a message is generated and the 
  1560.   process terminates. To ensure that _debug_free is used, define the 
  1561.   __DEBUG_ALLOC__ macro in all your modules. 
  1562. o If you copy the examples from the online help and compile and run them, the 
  1563.   format of the output you will see will be the same as that shown in the 
  1564.   sample output, but the values may be different. 
  1565.  
  1566. Related Information 
  1567.  
  1568. o -- Reference define not found -- 
  1569. o -- Reference fi not found -- 
  1570. o malloc.h 
  1571. o stdlib.h 
  1572. o #pragma langlvl 
  1573. o #pragma strings 
  1574. o /D option 
  1575. o /Sm option 
  1576. o /Gt option 
  1577. o Memory Management Functions 
  1578.  
  1579.  
  1580. ΓòÉΓòÉΓòÉ 2.4. Infinity and NaN Support ΓòÉΓòÉΓòÉ
  1581.  
  1582. The Giverny compiler supports the use of infinity and NaN (not-a-number) 
  1583. values. Infinity is a value with an associated sign that is mathematically 
  1584. greater in magnitude than any binary floating-point number. A NaN is a value in 
  1585. floating-point computations that is not interpreted as a mathematical value, 
  1586. and that contains a mask state and a sequence of binary digits. 
  1587.  
  1588. The value of infinity can be computed from 1.0 / 0.0 . The value of a NaN can 
  1589. be computed from 0.0 / 0.0 . 
  1590.  
  1591. Depending on its bit pattern, a NaN can be either quiet (NaNQ) or signalling 
  1592. (NaNS), as defined in the ANSI/IEEE Standard for Binary Floating-Point 
  1593. Arithmetic (754-1982). A NaNQ is masked and never generates exceptions. A NaNS 
  1594. may be masked and may generate an exception, but does not necessarily do so. 
  1595. The Giverny compiler supports only quiet NaN values; all NaN values discussed 
  1596. below refer to quiet NaNs. 
  1597.  
  1598. NaN and infinity values are defined as macro constants in the inf.<float.h> 
  1599. header file.  The macros are: 
  1600.  
  1601. Macro                Description 
  1602. _INFINITYF           Infinity of type float 
  1603. _INFINITY            Infinity of type double 
  1604. _INFINITYL           Infinity of type long double 
  1605.  
  1606. _INFF                Same as _INFINITYF 
  1607. _INF                 Same as _INFINITY 
  1608. _INFL                Same as _INFINITYL 
  1609.  
  1610. _NANF                Quiet NaN of type float 
  1611. _NAN                 Quiet NaN of type double 
  1612. _NANL                Quiet NaN of type long double. 
  1613.  
  1614. The corresponding negative values can be obtained by using the unary minus 
  1615. operator (for example, -_INF). 
  1616.  
  1617. Because these macros are actually references to constant variables, you cannot 
  1618. use them to initialize static variables. For example, the following statements 
  1619. are not allowed: 
  1620.  
  1621.    static double infval = _INF;
  1622.    static float nanval = 1.0 + _NANF;
  1623.  
  1624. However, you can initialize static variables to the numeric values of infinity 
  1625. and Nan: 
  1626.  
  1627.    static double infval = 1.0 / 0.0;
  1628.    static float nanval =  0.0 / 0.0;
  1629.  
  1630. Note:  While positive and negative infinities are specific bit patterns, NaNs 
  1631.        are not.  A NaN value is not equal to itself or to any other value.  For 
  1632.        example, if you assign a NaN value to a variable x, you cannot check the 
  1633.        value of x with the statement if (_NAN == x).  Instead, use the 
  1634.        statement if (x != x). 
  1635.  
  1636. All relational and equality expressions involving NaN values always evaluate to 
  1637. FALSE or zero (0), with the exception of not equal (!=), which always evaluates 
  1638. to TRUE or one (1). 
  1639.  
  1640. Related Information 
  1641.  
  1642. o Infinity and NaN in Library Functions 
  1643. o Assignment Expressions 
  1644. o -- Reference eqle not found -- 
  1645. o -- Reference rele not found -- 
  1646. o float.h 
  1647.  
  1648.  
  1649. ΓòÉΓòÉΓòÉ 2.4.1. Infinity and NaN in Library Functions ΓòÉΓòÉΓòÉ
  1650.  
  1651. When the language level is set to extended (using the /Se option or the #pragma 
  1652. langlvl(extended) directive), which is the default, infinity and NaN values can 
  1653. be passed as arguments to the scanf and printf families of library functions, 
  1654. and to the string conversion and math functions. At other language levels, 
  1655. these functions work as described in this reference. 
  1656.  
  1657. The following sections describe how the library functions handle the infinity 
  1658. and NaN values: 
  1659.  
  1660. o scanf Family 
  1661. o printf Family 
  1662. o String Conversion Functions 
  1663. o Math Functions 
  1664.  
  1665. Related Information 
  1666.  
  1667. o Infinity and NaN Support 
  1668. o #pragma langlvl 
  1669. o /Se option 
  1670.  
  1671.  
  1672. ΓòÉΓòÉΓòÉ 2.4.1.1. scanf Family ΓòÉΓòÉΓòÉ
  1673.  
  1674. The scanf family of functions includes the SAA functions inf.scanf, inf.fscanf, 
  1675. and inf.sscanf. When reading in floating-point numbers, these functions convert 
  1676. the strings INFINITY, INF, and NAN (in upper-, lower-, or mixed case) to the 
  1677. corresponding floating-point value.  The sign of the value is determined by the 
  1678. format specification. 
  1679.  
  1680. Given a string that consists of NAN, INF, or INFINITY, followed by other 
  1681. characters, the scanf functions read in only the NaN or infinity value, and 
  1682. consider the rest of the string to be a second input field. For example, Nancy 
  1683. would be scanned as two fields, Nan and cy. 
  1684.  
  1685. Note:  In the case of a string that begins with INF, the functions check the 
  1686.        fourth letter. If that letter is not I (in upper- or lowercase), INF is 
  1687.        read and converted and the rest of the string is left for the next 
  1688.        format specification. If the fourth letter is I, the functions continue 
  1689.        to scan for the full INFINITY string.  If the string is other than 
  1690.        INFINITY, the entire string is discarded. 
  1691.  
  1692. Example of fscanf with NaN and Infinity Values 
  1693.  
  1694. Related Information 
  1695.  
  1696. o Infinity and NaN Support 
  1697. o fscanf  - Read Formatted Data 
  1698. o scanf  - Read Data 
  1699. o sscanf  - Read Data 
  1700.  
  1701.  
  1702. ΓòÉΓòÉΓòÉ 2.4.1.2. printf Family ΓòÉΓòÉΓòÉ
  1703.  
  1704. The printf family of functions includes the SAA functions inf.printf, 
  1705. inf.fprintf, inf.sprintf, inf.vfprintf, inf.vprintf, and inf.vsprintf. These 
  1706. functions convert floating-point values of infinity and NaN to the strings 
  1707. "INFINITY" or "infinity" and "NAN" or "nan". 
  1708.  
  1709. The case is determined by the format specification, as is the sign (positive or 
  1710. negative). When converting these values, the printf functions ignore the 
  1711. precision width given by the format specification. 
  1712.  
  1713. Example of printf with Nan and Infinity Values 
  1714.  
  1715. Related Information 
  1716.  
  1717. o Infinity and NaN Support 
  1718. o fprintf  - Formatted Write 
  1719. o printf  - Formatted Print 
  1720. o sprintf  - Formatted Print to Buffer 
  1721. o vfprintf  - Print Argument Data 
  1722. o vprintf  - Print Argument Data 
  1723. o vsprintf  - Print Argument Data 
  1724.  
  1725.  
  1726. ΓòÉΓòÉΓòÉ 2.4.1.3. String Conversion Functions ΓòÉΓòÉΓòÉ
  1727.  
  1728. The string conversion functions include the SAA functions inf.atof and 
  1729. inf.strtod, and the Giverny standard extensions inf._atold, inf._ecvt, 
  1730. inf._fcvt, inf._gcvt, and inf.strtold. 
  1731.  
  1732. The atof, _atold, strtod, and strtold functions accept the strings INFINITY, 
  1733. INF, and NAN (in upper-, lower-, or mixed case) as input, and convert these 
  1734. strings to the corresponding macro value defined in <float.h>. The _ecvt, 
  1735. _fcvt, and _gcvt functions convert infinity and NaN values to the strings 
  1736. INFINITY and NAN, respectively. 
  1737.  
  1738. Note:  If a signalling NaN string is passed to a string conversion function, a 
  1739.        quiet NaN value is returned, and no signal is raised. 
  1740.  
  1741. Example of atof with NaN and Infinity Values 
  1742.  
  1743. Related Information 
  1744.  
  1745. o Infinity and NaN Support 
  1746. o atof  - Convert Character Strings 
  1747. o _atold - Convert ASCII String to Lo         ng Double 
  1748. o _ecvt - Convert Floating-Point to         Character 
  1749. o _fcvt - Convert Floating-Point to         String 
  1750. o _gcvt - Convert Floating-Point to String 
  1751. o strtod  - Convert Character String to Numeric 
  1752. o strtold - Convert String to Long Double 
  1753.  
  1754.  
  1755. ΓòÉΓòÉΓòÉ 2.4.1.4. Math Functions ΓòÉΓòÉΓòÉ
  1756.  
  1757. Most math functions accept infinity, negative infinity, and NaN values as 
  1758. input. (For information on those functions that do not accept these values, see 
  1759. Math Functions Without Infinity and NaN Support.) In general, a NaN value as 
  1760. input will result in a NaN value as output, and infinity values as input 
  1761. usually result in infinity values. If the input value is outside the domain or 
  1762. range of the function, errno is set to EDOM or ERANGE, respectively. 
  1763.  
  1764. The following tables display the results of each math function when NaN or 
  1765. infinity values are input, and the associated errno value if one exists.  The 
  1766. first table lists the functions that take only one argument; the second lists 
  1767. those that take two arguments. 
  1768.  
  1769. Note:  In some cases, infinity is always a valid input value for the function 
  1770. regardless of the language level (for example, atan). These cases do not appear 
  1771. in the tables. 
  1772.  
  1773. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1774. Γöé          NaN and Infinity Values in Math Functions             Γöé
  1775. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1776. Γöé FUNCTION      Γöé INPUT          Γöé RESULT        Γöé "ERRNO" VALUE Γöé
  1777. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1778. Γöé "             Γöé NaN            Γöé NaN "         Γöé               Γöé
  1779. Γöé acos          Γöé infinity       Γöé 0             Γöé EDOM          Γöé
  1780. Γöé asin "        Γöé -infinity      Γöé 0 "           Γöé EDOM          Γöé
  1781. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1782. Γöé "atan"        Γöé NaN            Γöé NaN           Γöé               Γöé
  1783. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1784. Γöé "             Γöé NaN            Γöé NaN           Γöé               Γöé
  1785. Γöé ceil          Γöé infinity       Γöé infinity      Γöé               Γöé
  1786. Γöé floor "       Γöé -infinity      Γöé -infinity     Γöé               Γöé
  1787. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1788. Γöé "             Γöé NaN            Γöé NaN           Γöé EDOM          Γöé
  1789. Γöé cos           Γöé infinity       Γöé NaN           Γöé ERANGE        Γöé
  1790. Γöé tan "         Γöé -infinity      Γöé NaN           Γöé ERANGE        Γöé
  1791. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1792. Γöé "cosh"        Γöé NaN            Γöé NaN           Γöé               Γöé
  1793. Γöé               Γöé infinity       Γöé infinity      Γöé ERANGE        Γöé
  1794. Γöé               Γöé -infinity      Γöé infinity      Γöé ERANGE        Γöé
  1795. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1796. Γöé "erf"         Γöé NaN            Γöé NaN "         Γöé EDOM          Γöé
  1797. Γöé               Γöé infinity       Γöé 1             Γöé               Γöé
  1798. Γöé               Γöé -infinity      Γöé -1 "          Γöé               Γöé
  1799. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1800. Γöé "erfc"        Γöé NaN            Γöé NaN "         Γöé EDOM          Γöé
  1801. Γöé               Γöé infinity       Γöé 0             Γöé               Γöé
  1802. Γöé               Γöé -infinity      Γöé 2 "           Γöé               Γöé
  1803. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1804. Γöé "exp"         Γöé NaN            Γöé NaN           Γöé               Γöé
  1805. Γöé               Γöé infinity       Γöé infinity "    Γöé ERANGE        Γöé
  1806. Γöé               Γöé -infinity      Γöé 0 "           Γöé ERANGE        Γöé
  1807. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1808. Γöé "fabs"        Γöé NaN            Γöé NaN           Γöé               Γöé
  1809. Γöé               Γöé infinity       Γöé infinity      Γöé               Γöé
  1810. Γöé               Γöé -infinity      Γöé infinity      Γöé               Γöé
  1811. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1812. Γöé "frexp"       Γöé NaN            Γöé NaN, "0"      Γöé EDOM          Γöé
  1813. Γöé               Γöé infinity       Γöé NaN, "0"      Γöé EDOM          Γöé
  1814. Γöé               Γöé -infinity      Γöé NaN, "0"      Γöé EDOM          Γöé
  1815. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1816. Γöé "gamma"       Γöé NaN            Γöé NaN           Γöé EDOM          Γöé
  1817. Γöé               Γöé infinity       Γöé infinity      Γöé ERANGE        Γöé
  1818. Γöé               Γöé -infinity      Γöé NaN           Γöé EDOM          Γöé
  1819. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1820. Γöé "             Γöé NaN            Γöé NaN           Γöé               Γöé
  1821. Γöé log           Γöé infinity "     Γöé infinity      Γöé               Γöé
  1822. Γöé log10 "       Γöé 0              Γöé -infinity     Γöé ERANGE        Γöé
  1823. Γöé               Γöé <0 "           Γöé NaN           Γöé EDOM          Γöé
  1824. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1825. Γöé "modf"        Γöé NaN            Γöé NaN, NaN      Γöé EDOM          Γöé
  1826. Γöé               Γöé infinity       Γöé NaN, infinity Γöé EDOM          Γöé
  1827. Γöé               Γöé -infinity      Γöé NaN, -infinityΓöé EDOM          Γöé
  1828. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1829. Γöé "sin"         Γöé NaN            Γöé NaN           Γöé EDOM          Γöé
  1830. Γöé               Γöé infinity       Γöé NaN           Γöé ERANGE        Γöé
  1831. Γöé               Γöé -infinity      Γöé NaN           Γöé ERANGE        Γöé
  1832. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1833. Γöé "sinh"        Γöé NaN            Γöé NaN           Γöé EDOM          Γöé
  1834. Γöé               Γöé infinity       Γöé infinity      Γöé ERANGE        Γöé
  1835. Γöé               Γöé -infinity      Γöé -infinity     Γöé ERANGE        Γöé
  1836. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1837. Γöé "sqrt"        Γöé NaN            Γöé NaN           Γöé               Γöé
  1838. Γöé               Γöé infinity       Γöé infinity "    Γöé               Γöé
  1839. Γöé               Γöé -infinity      Γöé 0 "           Γöé EDOM          Γöé
  1840. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1841. Γöé "tanh"        Γöé NaN            Γöé NaN "         Γöé EDOM          Γöé
  1842. Γöé               Γöé infinity       Γöé 1             Γöé               Γöé
  1843. Γöé               Γöé -infinity      Γöé -1 "          Γöé               Γöé
  1844. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1845.  
  1846. The functions in the following table take two arguments.  The results from NaN 
  1847. and infinity values vary depending on which argument they are passed as. 
  1848.  
  1849. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1850. Γöé          Infinity and NaN Values in Math Functions             Γöé
  1851. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1852. Γöé FUNCTION   Γöé ARGUMENT 1 Γöé ARGUMENT 2 Γöé RESULT     Γöé "ERRNO"    Γöé
  1853. Γöé            Γöé            Γöé            Γöé            Γöé VALUE      Γöé
  1854. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1855. Γöé "atan2"    Γöé NaN        Γöé any number Γöé NaN        Γöé EDOM       Γöé
  1856. Γöé            Γöé any number Γöé NaN        Γöé NaN        Γöé            Γöé
  1857. Γöé            Γöé infinity   Γöé any number Γöé :font facenΓöémEDOMurier sΓöéze=15x12.0:font facename=default size=0x0.
  1858. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1859. Γöé "fmod"     Γöé NaN        Γöé any number Γöé NaN        Γöé EDOM       Γöé
  1860. Γöé            Γöé any number Γöé NaN        Γöé NaN        Γöé EDOM       Γöé
  1861. Γöé            Γöé ╤æinfinity  Γöé any number Γöé :font facenΓöémEDOMurier sΓöéze=15x12.0:font facename=default size=0x0.
  1862. Γöé            Γöé any number Γöé ╤æinfinity  Γöé :font facenΓöémEDOMurier sΓöéze=15x12.0:font facename=default size=0x0.
  1863. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1864. Γöé "ldexp"    Γöé infinity   Γöé any number Γöé infinity   Γöé ERANGE     Γöé
  1865. Γöé            Γöé -infinity  Γöé any number Γöé -infinity  Γöé ERANGE     Γöé
  1866. Γöé            Γöé NaN        Γöé any number Γöé NaN        Γöé EDOM       Γöé
  1867. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1868. Γöé "pow"      Γöé ╤æinfinity  Γöé "0"        Γöé NaN        Γöé EDOM       Γöé
  1869. Γöé            Γöé infinity   Γöé -infinity  Γöé NaN        Γöé EDOM       Γöé
  1870. Γöé            Γöé -infinity  Γöé ╤æinfinity  Γöé NaN        Γöé EDOM       Γöé
  1871. Γöé            Γöé -infinity  Γöé :font facenΓöémNaNourier sΓöézEDOMx12.<-1Γöéfont facename=default size=0x0.
  1872. Γöé            Γöé -infinity  Γöé :font facenΓöémNaNourier sΓöézEDOMx12.<1:Γöéont facename=default size=0x0., :font facename=Courier size=15x12.>-1:font facename=default size=0x0.
  1873. Γöé            Γöé -infinity  Γöé :font facenΓöémNaNourier sΓöézEDOMx12.>1:Γöéont facename=default size=0x0.
  1874. Γöé            Γöé NaN        Γöé any number Γöé NaN        Γöé EDOM       Γöé
  1875. Γöé            Γöé any number Γöé NaN        Γöé NaN        Γöé EDOM       Γöé
  1876. Γöé            Γöé :font facenΓöéminfinityr sΓöézNaN5x12.=<0ΓöéfEDOMfacenamΓöé=default size=0x0.
  1877. Γöé            Γöé :font facenΓöém╤æinfinity sΓöézNaN5x12.1:fΓöénEDOMcename=Γöéefault size=0x0.
  1878. Γöé            Γöé ╤æinfinity  Γöé ╤æ:font faceΓöéa:fontufacenΓöémERANGEier1sΓöéze=15x12.0:fontffacename=default size=0x0.
  1879. Γöé            Γöé :font facenΓöéminfinityr sΓöéz:font1facenΓöémERANGEiermsΓöéze=15x12.0:font0facename=defaultesize=0x0.size=15x12.<1:font facename=default size=0x0.
  1880. Γöé            Γöé :font facenΓöém-infinity sΓöézinfinity>0:ΓöéoERANGEenameΓöédefault size=0x0., :font facename=Courier size=15x12.<1:font facename=default size=0x0.
  1881. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1882.  
  1883. Note:  If a signalling NaN is passed to a math function, the behavior is 
  1884.        undefined. 
  1885.  
  1886.  
  1887. ΓòÉΓòÉΓòÉ 2.4.1.5. Math Functions Without Infinity and NaN Support ΓòÉΓòÉΓòÉ
  1888.  
  1889. The following floating-point unit functions are not supported for infinity or 
  1890. NaN. In general, a NaN or infinity value as input for these functions will 
  1891. result in an undefined value and/or an invalid operation exception. These 
  1892. functions do not set errno. 
  1893.  
  1894. Note:  If you expect the return value of a math function to be infinity or NaN, 
  1895. you should use the functions which are supported for these values. The 
  1896. advantage in using the floating-point unit math functions is a reduction in the 
  1897. processing time. :enote. 
  1898.  
  1899. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1900. Γöé :font         Γöé :font          Γöé :font         Γöé               Γöé
  1901. Γöé facename=CouriΓöérfacename=CourieΓöé facename=CouriΓöér              Γöé
  1902. Γöé size=15x12._faΓöéosize=15x12._fasΓöénsize=15x12._fcΓöés:font         Γöé
  1903. Γöé facename=defauΓöétfacename=defaulΓöé facename=defauΓöét              Γöé
  1904. Γöé size=0x0.     Γöé size=0x0.      Γöé size=0x0.     Γöé               Γöé
  1905. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1906. Γöé :font         Γöé :font          Γöé :font         Γöé               Γöé
  1907. Γöé facename=CouriΓöérfacename=CourieΓöé facename=CouriΓöér              Γöé
  1908. Γöé size=15x12._fcΓöéssize=15x12._fpaΓöéasize=15x12._fpΓöéan:font        Γöé
  1909. Γöé facename=defauΓöétfacename=defaulΓöé facename=defauΓöét              Γöé
  1910. Γöé size=0x0.     Γöé size=0x0.      Γöé size=0x0.     Γöé               Γöé
  1911. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1912. Γöé :font         Γöé :font          Γöé :font         Γöé               Γöé
  1913. Γöé facename=CouriΓöérfacename=CourieΓöé facename=CouriΓöér              Γöé
  1914. Γöé size=15x12._fsΓöénsize=15x12._fsiΓöécsize=15x12._fsΓöért:font        Γöé
  1915. Γöé facename=defauΓöétfacename=defaulΓöé facename=defauΓöét              Γöé
  1916. Γöé size=0x0.     Γöé size=0x0.      Γöé size=0x0.     Γöé               Γöé
  1917. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1918. Γöé :font         Γöé :font          Γöé :font         Γöé               Γöé
  1919. Γöé facename=CouriΓöérfacename=CourieΓöé facename=CouriΓöér              Γöé
  1920. Γöé size=15x12._fyΓöé2size=15x12._fylΓöéxsize=15x12._f2Γöém1:font        Γöé
  1921. Γöé facename=defauΓöétfacename=defaulΓöé facename=defauΓöét              Γöé
  1922. Γöé size=0x0.     Γöé size=0x0.      Γöé size=0x0.     Γöé               Γöé
  1923. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1924.  
  1925. Related Information 
  1926.  
  1927. o Infinity and NaN Support 
  1928. o math.h 
  1929. o acos  - Arc Cosine 
  1930. o asin  - Arc Sine 
  1931. o atan - atan2  - Arc Tangent 
  1932. o ceil - Integer >= Argument 
  1933. o cos  - Cosine 
  1934. o cosh  - Hyperbolic Cosine 
  1935. o erf - erfc  - Error Functions 
  1936. o exp  - Exponential Function 
  1937. o fabs  - Floating-Point Absolute Value 
  1938. o floor - Integer <= Argument 
  1939. o fmod  - Floating-Point Remainder 
  1940. o frexp  - Separate Floating-Point Value 
  1941. o gamma  - Gamma Function 
  1942. o ldexp  - Multiply by a Power of Two 
  1943. o log  - Calculate Natural Logarithm 
  1944. o log10  - Calculate Base 10 Logarithm 
  1945. o modf  - Separate Floating-Point Value 
  1946. o pow  - Compute Power 
  1947. o sin  - Sine 
  1948. o sinh  - Hyperbolic Sine 
  1949. o sqrt  - Calculate Square Root 
  1950. o tan  - Tangent 
  1951. o tanh  - Hyperbolic Tangent 
  1952.  
  1953.  
  1954. ΓòÉΓòÉΓòÉ 2.5. Low-Level I/O Notes ΓòÉΓòÉΓòÉ
  1955.  
  1956. o The primary difference between stream I/O and low-level I/O is that low-level 
  1957.   I/O leaves the responsibility of buffering and formatting up to the user. 
  1958.  
  1959. o A handle is a value created by the system and used by low-level I/O that 
  1960.   identifies a file. The conversion between C and DOS API handles is given by: 
  1961.  
  1962.     API_handle = C_handle
  1963.  
  1964. o Handles may be passed between library environments without restriction. 
  1965.  
  1966. o In general, do not mix input or output from low-level I/O with that from 
  1967.   stream I/O. The only way to communicate between stream I/O and low-level I/O 
  1968.   is by using fdopen or fileno. 
  1969.  
  1970. o The default open-sharing mode is SH_DENYWR. Use sopen to obtain other sharing 
  1971.   modes. 
  1972.  
  1973. o Text mode will delete `\r' characters on input and will change `\n' to `\r\n' 
  1974.   on output. 
  1975.  
  1976. o In a multithread environment, it is your responsibility to ensure that two 
  1977.   threads do not attempt to perform low level I/O operations on the same file 
  1978.   at the same time. You must make sure that one I/O process is completed before 
  1979.   another begins. 
  1980.  
  1981. o If a handle is acquired other than by using the IBM C/C++ for OS/2 library 
  1982.   functions _open, _creat, _sopen, or _fileno, the function _setmode must be 
  1983.   run for that handle before using it with the IBM C/C++ for OS/2 library 
  1984.   functions. 
  1985.  
  1986. o Low level I/O uses a named shared memory segment, with a name of the form 
  1987.   \SHAREMEM\DDE4xxxx.xxx, where x may be any character other than blank. Using 
  1988.   a named shared memory segment of this form may cause low level I/O to operate 
  1989.   incorrectly. 
  1990.  
  1991. o Low-level I/O functions will treat the character x1a specially if the file 
  1992.   mode is text: 
  1993.  
  1994.   The character x1a is treated as end of file on input if it is detected in a 
  1995.   nonseekable file. It is only treated as end of file if it is the last 
  1996.   character of a seekable file. 
  1997.  
  1998.   If a file is opened as text with either the O_APPEND or O_RDWR flags and x1a 
  1999.   is the last character of the file, the last character of the file is deleted. 
  2000.  
  2001. The low-level I/O functions include: 
  2002.  
  2003. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  2004. Γöé :font             Γöé :font             Γöé
  2005. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2006. Γöé size=15x12._accessΓöéfsize=15x12._fstat:Γöéont
  2007. Γöé facename=default  Γöé facename=default  Γöé
  2008. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2009. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2010. Γöé :font             Γöé :font             Γöé
  2011. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2012. Γöé size=15x12._chmod:Γöéosize=15x12._isattyΓöéfont
  2013. Γöé facename=default  Γöé facename=default  Γöé
  2014. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2015. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2016. Γöé :font             Γöé :font             Γöé
  2017. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2018. Γöé size=15x12._chsizeΓöéfsize=15x12._lseek:Γöéont
  2019. Γöé facename=default  Γöé facename=default  Γöé
  2020. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2021. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2022. Γöé :font             Γöé :font             Γöé
  2023. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2024. Γöé size=15x12._close:Γöéosize=15x12._open:fΓöént
  2025. Γöé facename=default  Γöé facename=default  Γöé
  2026. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2027. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2028. Γöé :font             Γöé :font             Γöé
  2029. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2030. Γöé size=15x12._creat:Γöéosize=15x12._read:fΓöént
  2031. Γöé facename=default  Γöé facename=default  Γöé
  2032. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2033. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2034. Γöé :font             Γöé :font             Γöé
  2035. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2036. Γöé size=15x12._dup:foΓöétsize=15x12._setmodΓöé:font
  2037. Γöé facename=default  Γöé facename=default  Γöé
  2038. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2039. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2040. Γöé :font             Γöé :font             Γöé
  2041. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2042. Γöé size=15x12._dup2:fΓöénsize=15x12._sopen:Γöéont
  2043. Γöé facename=default  Γöé facename=default  Γöé
  2044. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2045. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2046. Γöé :font             Γöé :font             Γöé
  2047. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2048. Γöé size=15x12._eof:foΓöétsize=15x12._stat:fΓöént
  2049. Γöé facename=default  Γöé facename=default  Γöé
  2050. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2051. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2052. Γöé :font             Γöé :font             Γöé
  2053. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2054. Γöé size=15x12._fdopenΓöéfsize=15x12._tell:fΓöént
  2055. Γöé facename=default  Γöé facename=default  Γöé
  2056. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2057. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2058. Γöé :font             Γöé :font             Γöé
  2059. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2060. Γöé size=15x12._fileleΓöégsize=15x12._umask:Γöéont
  2061. Γöé facename=default  Γöé facename=default  Γöé
  2062. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2063. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  2064. Γöé :font             Γöé :font             Γöé
  2065. Γöé facename=Courier  Γöé facename=Courier  Γöé
  2066. Γöé size=15x12._filenoΓöéfsize=15x12._write:Γöéont
  2067. Γöé facename=default  Γöé facename=default  Γöé
  2068. Γöé size=0x0.         Γöé size=0x0.         Γöé
  2069. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2070.  
  2071.  
  2072. ΓòÉΓòÉΓòÉ 2.6. abort   - Stop a Program ΓòÉΓòÉΓòÉ
  2073.  
  2074. #include <stdlib.h>
  2075.  
  2076. void abort(void);
  2077.  
  2078. Language Level: ANSI, SAA, Extension 
  2079.  
  2080. Description 
  2081.  
  2082. The abort function causes an abnormal program termination and returns control 
  2083. to the host environment.  The abort function is similar to exit, except that 
  2084. abort does not flush buffers and close open files before ending the program. 
  2085. Calls to abort raise the SIGABRT signal. 
  2086.  
  2087. The abort function will not result in program termination if SIGABRT is caught 
  2088. by a signal handler and the signal handler does not return. 
  2089.  
  2090. Example of abort 
  2091.  
  2092. Related Information 
  2093.  
  2094. o exit  - End Program 
  2095. o signal - Install Interrupt Handlers 
  2096. o stdlib.h 
  2097.  
  2098.  
  2099. ΓòÉΓòÉΓòÉ 2.7. abs  - Integer Absolute Value ΓòÉΓòÉΓòÉ
  2100.  
  2101. #include <stdlib.h>
  2102.  
  2103. int abs(int n);
  2104.  
  2105. Language Level: ANSI, SAA 
  2106.  
  2107. Description 
  2108.  
  2109. The abs function returns the absolute value of an integer argument n. 
  2110.  
  2111. There is no error return value.  The result is undefined when the absolute 
  2112. value of the argument cannot be represented as an integer.  The value of the 
  2113. minimum allowable integer is defined by INT_MIN in the <limits.h> include file. 
  2114.  
  2115. Example of abs 
  2116.  
  2117. Related Information 
  2118.  
  2119. o fabs  - Floating-Point Absolute Value 
  2120. o labs  - long Absolute Value 
  2121. o limits.h 
  2122. o stdlib.h 
  2123.  
  2124.  
  2125. ΓòÉΓòÉΓòÉ 2.8. _access - Determine Access Mode ΓòÉΓòÉΓòÉ
  2126.  
  2127. #include <io.h>
  2128.  
  2129. int _access(char *pathname, int mode);
  2130.  
  2131. Language Level: Extension 
  2132.  
  2133. Description 
  2134.  
  2135. The _access function determines whether the specified file exists and whether 
  2136. you can get access to it in the given mode.  The following list gives possible 
  2137. values for the mode and their meaning in the access call: 
  2138.  
  2139. Value    Meaning 
  2140.  06      Check for permission to read from and write to the file. 
  2141.  04      Check for permission to read from the file. 
  2142.  02      Check for permission to write to the file. 
  2143.  00      Check only for the existence of the file. 
  2144.  
  2145. The _access function returns the value 0 if you can get access to the file in 
  2146. the specified mode. A return value of -1 shows that the file does not exist or 
  2147. is inaccessible in the given mode, and the system sets errno to one of the 
  2148. following values: 
  2149.  
  2150. Value          Meaning 
  2151. EACCESS        Access is denied; the permission setting of the file does not 
  2152.                allow you to get access to the file in the specified mode. 
  2153. ENOENT         The system cannot find the file or the path that you specified, 
  2154.                or the file name was incorrect. 
  2155. EINVAL         The mode specified was not valid. 
  2156. EOS2ERR        The call to the operating system was not successful. 
  2157.  
  2158. Example of _access 
  2159.  
  2160. Related Information 
  2161.  
  2162. o _chmod - Change File Permission Setting 
  2163. o _sopen - Open Shared File 
  2164. o _umask - Sets File Mask of Current Process 
  2165. o io.h 
  2166.  
  2167.  
  2168. ΓòÉΓòÉΓòÉ 2.9. acos  - Arc Cosine ΓòÉΓòÉΓòÉ
  2169.  
  2170. #include <math.h>
  2171.  
  2172. double acos(double x);
  2173.  
  2174. Language Level: ANSI, SAA 
  2175.  
  2176. Description 
  2177.  
  2178. The acos function returns the arc cosine of x, expressed in radians, in the 
  2179. range 0 to ╤â. 
  2180.  
  2181. The value of x must be between -1 and 1 inclusive. If x is less than -1 or 
  2182. greater than 1, acos sets errno to EDOM and returns 0. 
  2183.  
  2184. Example of acos 
  2185.  
  2186. Related Information 
  2187.  
  2188. o asin  - Arc Sine 
  2189. o atan - atan2  - Arc Tangent 
  2190. o cos  - Cosine 
  2191. o cosh  - Hyperbolic Cosine 
  2192. o sin  - Sine 
  2193. o sinh  - Hyperbolic Sine 
  2194. o tan  - Tangent 
  2195. o tanh  - Hyperbolic Tangent 
  2196. o math.h 
  2197.  
  2198.  
  2199. ΓòÉΓòÉΓòÉ 2.10. _alloca - Temporarily Reserve Storag                e Block ΓòÉΓòÉΓòÉ
  2200.  
  2201. #include <stdlib.h>  /* also defined in <malloc.h> */
  2202.  
  2203. void *_alloca(size_t size);
  2204.  
  2205. Language Level: Extended 
  2206.  
  2207. Description 
  2208.  
  2209. The _alloca function is a built-in function that temporarily allocates size 
  2210. bytes of storage space from the program's stack. The memory space is 
  2211. automatically freed when the function that called _alloca returns. 
  2212.  
  2213. Warning: The _alloca function is faster than other allocation functions such as 
  2214. malloc, but it has several limitations: 
  2215.  
  2216. o Because it is a built-in function and has no backing code in the library: 
  2217.  
  2218.    - You cannot take the address of _alloca. 
  2219.    - You cannot parenthesize an _alloca function call because parentheses 
  2220.      specify a call to the backing code for the function in the library, and 
  2221.      _alloca has no backing code. 
  2222.  
  2223. o Because _alloca automatically frees storage after the function that calls it 
  2224.   returns, you cannot pass the pointer value returned by _alloca as an argument 
  2225.   to the free function. 
  2226. o You cannot pass memory allocated by _alloca to 16-bit programs, because it is 
  2227.   never tiled. 
  2228.  
  2229. Because _alloca uses automatic storage, programs calling _alloca must not be 
  2230. compiled using the /Gs+ switch.  This switch disables stack probes and does not 
  2231. guarantee that enough stack storage will be available. You should use the /Gs- 
  2232. switch, which is the default setting. 
  2233.  
  2234. The _alloca function returns a pointer to the reserved space. If _alloca cannot 
  2235. reserve the requested space, the program gets an out of stack exception. 
  2236.  
  2237. Example of _alloca 
  2238.  
  2239. Related Information 
  2240.  
  2241. o calloc  - Reserve and Initialize Storage 
  2242. o free  - Release Storage Blocks 
  2243. o malloc  - Reserve Storage Block 
  2244. o realloc  - Change Reserved Storage Block Size 
  2245. o /Gs option 
  2246. o malloc.h 
  2247. o stdlib.h 
  2248.  
  2249.  
  2250. ΓòÉΓòÉΓòÉ 2.11. asctime  - Convert Time ΓòÉΓòÉΓòÉ
  2251.  
  2252. #include <time.h>
  2253.  
  2254. char *asctime(const struct tm *time);
  2255.  
  2256. Language Level: ANSI, SAA 
  2257.  
  2258. Description 
  2259.  
  2260. The asctime function converts time stored as a structure pointed to by time to 
  2261. a character string.  The time value may be obtained from a call to gmtime or 
  2262. localtime;  either returns a pointer to a tm structure defined in <time.h>. See 
  2263. gmtime  - Convert Time for a description of the tm structure fields. 
  2264.  
  2265. The string result that asctime produces contains exactly 26 characters and has 
  2266. the format 
  2267.  
  2268.    "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"
  2269.  
  2270. See printf  - Formatted Print for a description of format specifications. The 
  2271. following are examples of the string returned: 
  2272.  
  2273.    Sat Jul 04 02:03:55 1991\n\0
  2274. or
  2275.    Sat Jul 04  2:03:55 1991\n\0
  2276.  
  2277. The asctime function uses a 24-hour-clock format.  The days are abbreviated to: 
  2278. Sun, Mon, Tue, Wed, Thu, Fri, and Sat.  The months are abbreviated to:  Jan, 
  2279. Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec.  All fields have 
  2280. constant width. Days with only one digit are preceded either with a zero or a 
  2281. blank space. The newline character (\n) and the null character (\0) occupy the 
  2282. last two positions of the string. 
  2283.  
  2284. The asctime function returns a pointer to the resulting character string. 
  2285. There is no error return value. 
  2286.  
  2287. Note:  The asctime, ctime, and other time functions may use a common, 
  2288.        statically allocated buffer to hold the return string.  Each call to one 
  2289.        of these functions may destroy the result of the previous call. 
  2290.  
  2291. Note:  The time and date functions begin at 00:00:00 Universal Time, January 1, 
  2292. 1970. :enote. 
  2293.  
  2294. Example of asctime 
  2295.  
  2296. Related Information 
  2297.  
  2298. o ctime  - Convert Time 
  2299. o gmtime  - Convert Time 
  2300. o localtime  - Convert Time 
  2301. o printf  - Formatted Print 
  2302. o time  - Determine Current Time 
  2303. o time.h 
  2304.  
  2305.  
  2306. ΓòÉΓòÉΓòÉ 2.12. asin  - Arc Sine ΓòÉΓòÉΓòÉ
  2307.  
  2308. #include <math.h>
  2309.  
  2310. double asin(double x);
  2311.  
  2312. Language Level: ANSI, SAA 
  2313.  
  2314. Description 
  2315.  
  2316. The asin function calculates the arc sine of x, in the range -╤â/2 to ╤â/2 
  2317. radians. 
  2318.  
  2319. The value of x must be between -1 and 1.  If x is less than -1 or greater than 
  2320. 1, asin sets errno to EDOM, and returns a value of 0. 
  2321.  
  2322. Example of asin 
  2323.  
  2324. Related Information 
  2325.  
  2326. o acos  - Arc Cosine 
  2327. o atan - atan2  - Arc Tangent 
  2328. o cos  - Cosine 
  2329. o cosh  - Hyperbolic Cosine 
  2330. o sin  - Sine 
  2331. o sinh  - Hyperbolic Sine 
  2332. o tan  - Tangent 
  2333. o tanh  - Hyperbolic Tangent 
  2334. o math.h 
  2335.  
  2336.  
  2337. ΓòÉΓòÉΓòÉ 2.13. assert  - Verify Condition ΓòÉΓòÉΓòÉ
  2338.  
  2339. #include <assert.h>
  2340.  
  2341. void assert(int expression);
  2342.  
  2343. Language Level: ANSI, SAA 
  2344.  
  2345. Description 
  2346.  
  2347. The assert function prints a diagnostic message to stderr and aborts the 
  2348. program if expression is false (zero). The diagnostic message has the format: 
  2349. Assertion failed: expression, file filename, line line-number. 
  2350.  
  2351. The assert function takes no action if the expression is true (nonzero). 
  2352.  
  2353. Use the assert function to identify program logic errors.  Choose an expression 
  2354. which holds true only if the program is operating as you intend.  After you 
  2355. have debugged the program, you can use the special no-debug identifier NDEBUG 
  2356. to remove the assert calls from the program.  If you define NDEBUG to any value 
  2357. with a #define directive, the C preprocessor expands all assert invocations to 
  2358. void expressions. If you use NDEBUG, it must be defined prior to including 
  2359. <assert.h> in the program. 
  2360.  
  2361. There is no return value. 
  2362.  
  2363. Note:  The assert function is a macro.  You should not use the #undef directive 
  2364. with the assert function. 
  2365.  
  2366. Example of assert 
  2367.  
  2368. Related Information 
  2369.  
  2370. o abort  - Stop a Program 
  2371. o assert.h 
  2372. o #define 
  2373. o #undef 
  2374.  
  2375.  
  2376. ΓòÉΓòÉΓòÉ 2.14. atan - atan2  - Arc Tangent ΓòÉΓòÉΓòÉ
  2377.  
  2378. #include <math.h>
  2379.  
  2380. double atan(double x);          /* Arc tangent of x */
  2381.  
  2382. double atan2(double y, double x);          /* Arc tangent of y/x */
  2383.  
  2384. Language Level: ANSI, SAA 
  2385.  
  2386. Description 
  2387.  
  2388. The atan and atan2 functions calculate the arc tangent of x and y/x, 
  2389. respectively. 
  2390.  
  2391. The atan function returns a value in the range -╤â/2 to ╤â/2 -pi/2 to pi/2 
  2392. radians.  The atan2 function returns a value in the range -╤â to ╤â radians.  If 
  2393. both arguments of atan2 are zero, the function sets errno to EDOM, and returns 
  2394. a value of zero (0). 
  2395.  
  2396. Example of atan - atan2 
  2397.  
  2398. Related Information 
  2399.  
  2400. o acos  - Arc Cosine 
  2401. o asin  - Arc Sine 
  2402. o cos  - Cosine 
  2403. o cosh  - Hyperbolic Cosine 
  2404. o sin  - Sine 
  2405. o sinh  - Hyperbolic Sine 
  2406. o tan  - Tangent 
  2407. o tanh  - Hyperbolic Tangent 
  2408. o math.h 
  2409.  
  2410.  
  2411. ΓòÉΓòÉΓòÉ 2.15. atexit  - Record Program Termination Function ΓòÉΓòÉΓòÉ
  2412.  
  2413. #include <stdlib.h>
  2414.  
  2415. int atexit(void (*func)(void));
  2416.  
  2417. Language Level: ANSI, SAA 
  2418.  
  2419. Description 
  2420.  
  2421. The atexit function records a function, pointed to by func, that the system 
  2422. calls at normal program termination.  For portability, you should use atexit to 
  2423. register up to 32 functions only. The functions are executed in a last in, 
  2424. first out order. 
  2425.  
  2426. The atexit function returns zero (0) if it is successful, and nonzero if it 
  2427. fails. 
  2428.  
  2429. Example of atexit 
  2430.  
  2431. Related Information 
  2432.  
  2433. o exit  - End Program 
  2434. o signal - Install Interrupt Handlers 
  2435. o stdlib.h 
  2436.  
  2437.  
  2438. ΓòÉΓòÉΓòÉ 2.16. atof  - Convert Character Strings ΓòÉΓòÉΓòÉ
  2439.  
  2440. #include <stdlib.h>
  2441.  
  2442. double atof(const char *string);     /* Convert string to double */
  2443.  
  2444. Language Level: ANSI, SAA, Extension 
  2445.  
  2446. Description 
  2447.  
  2448. This function converts a character string to a double-precision floating-point 
  2449. value. 
  2450.  
  2451. The input string is a sequence of characters that can be interpreted as a 
  2452. numerical value of the specified type.  The function stops reading the input 
  2453. string at the first character that it cannot recognize as part of a number; 
  2454. this character can be the null character that ends the string. 
  2455.  
  2456. The atof function expects a string in the following form: 
  2457.  
  2458.  ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ
  2459.     Γöé              Γöé  Γöé       Γöé  Γöé                                 Γöé
  2460.     ΓööΓöÇΓöÇwhitespaceΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ + ΓöÇΓöÇΓöñ  Γö£ΓöÇdigitsΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöñ
  2461.                       Γöé       Γöé  Γöé          Γöé      Γöé   Γöé        Γöé  Γöé
  2462.                       ΓööΓöÇΓöÇ - ΓöÇΓöÇΓöÿ  Γöé          ΓööΓöÇΓöÇ . ΓöÇΓöÿ   ΓööΓöÇdigitsΓöÇΓöÿ  Γöé
  2463.                                  Γöé                                 Γöé
  2464.                                  ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ . ΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2465.  
  2466.  ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ
  2467.    Γöé                           Γöé
  2468.    Γö£ΓöÇΓöÇeΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇdigitsΓöÇΓöÇΓöÿ
  2469.    Γöé     Γöé   Γöé     Γöé
  2470.    ΓööΓöÇΓöÇEΓöÇΓöÇΓöÿ   Γö£ΓöÇ + ΓöÇΓöñ
  2471.              Γöé     Γöé
  2472.              ΓööΓöÇ - ΓöÇΓöÿ
  2473.  
  2474. The whitespace consists of the same characters for which the isspace function 
  2475. is true, such as spaces and tabs.  The atof function ignores leading 
  2476. white-space characters. 
  2477.  
  2478. For the atof function, digits is one or more decimal digits;  if no digits 
  2479. appear before the decimal point, at least one digit must appear after the 
  2480. decimal point.  The decimal digits can precede an exponent, introduced by the 
  2481. letter e or E.  The exponent is a decimal integer, which may be signed. The 
  2482. string can also be "infinity", "inf", or "nan". These strings are case 
  2483. insensitive, and can be preceded by a unary minus (-). They are converted to 
  2484. infinity and NaN values. 
  2485.  
  2486. atof returns a double value produced by interpreting the input characters as a 
  2487. number.  The return value is 0 if the function cannot convert the input to a 
  2488. value of that type.  The return value is undefined in case of overflow. 
  2489.  
  2490. Example of atof 
  2491.  
  2492. Related Information 
  2493.  
  2494. o atoi  - Convert Character Strings 
  2495. o atol  - Convert Character Strings 
  2496. o _atold - Convert ASCII String to Lo         ng Double 
  2497. o stdlib.h 
  2498. o strtod  - Convert Character String to Numeric 
  2499. o strtol  - Convert Character String to Numeric 
  2500. o strtold - Convert String to Long Double 
  2501. o Infinity and NaN Support 
  2502.  
  2503.  
  2504. ΓòÉΓòÉΓòÉ 2.17. atoi  - Convert Character Strings ΓòÉΓòÉΓòÉ
  2505.  
  2506. #include <stdlib.h>
  2507.  
  2508. int atoi(const char *string);        /* Convert string to integer */
  2509.  
  2510. Language Level: ANSI, SAA 
  2511.  
  2512. Description 
  2513.  
  2514. This function converts a character string to an integer value. 
  2515.  
  2516. The input string is a sequence of characters that can be interpreted as a 
  2517. numerical value of the specified type.  The function stops reading the input 
  2518. string at the first character that it cannot recognize as part of a number; 
  2519. this character can be the null character which ends the string. 
  2520.  
  2521. The atoi function does not recognize decimal points nor exponents.  The string 
  2522. argument for this function has the form: 
  2523.  
  2524. ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÇ
  2525.     Γöé              Γöé  Γöé       Γöé
  2526.     ΓööΓöÇΓöÇwhitespaceΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ + ΓöÇΓöÇΓöñ
  2527.                       Γöé       Γöé
  2528.                       ΓööΓöÇΓöÇ - ΓöÇΓöÇΓöÿ
  2529.  
  2530. where whitespace consists of the same characters for which the isspace function 
  2531. is true, such as spaces and tabs.  The atoi function ignores leading 
  2532. white-space characters. digits is one or more decimal digits. 
  2533.  
  2534. atoi returns an int value produced by interpreting the input characters as a 
  2535. number.  The return value is 0 if the function cannot convert the input to a 
  2536. value of that type.  The return value is undefined in the case of an overflow. 
  2537.  
  2538. Example of atoi 
  2539.  
  2540. Related Information 
  2541.  
  2542. o atof  - Convert Character Strings 
  2543. o atol  - Convert Character Strings 
  2544. o _atold - Convert ASCII String to Lo         ng Double 
  2545. o stdlib.h 
  2546. o strtod  - Convert Character String to Numeric 
  2547. o strtol  - Convert Character String to Numeric 
  2548. o strtold - Convert String to Long Double 
  2549.  
  2550.  
  2551. ΓòÉΓòÉΓòÉ 2.18. atol  - Convert Character Strings ΓòÉΓòÉΓòÉ
  2552.  
  2553. #include <stdlib.h>
  2554.  
  2555. long int atol(const char *string);   /* Convert string to long */
  2556.  
  2557. Language Level: ANSI, SAA 
  2558.  
  2559. Description 
  2560.  
  2561. This function converts a character string to a long value. 
  2562.  
  2563. The input string is a sequence of characters that can be interpreted as a 
  2564. numerical value of the specified type.  The function stops reading the input 
  2565. string at the first character that it cannot recognize as part of a number; 
  2566. this character can be the null character that ends the string. 
  2567.  
  2568. The atol function does not recognize decimal points nor exponents.  The string 
  2569. argument for this function has the form: 
  2570.  
  2571. ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÇ
  2572.     Γöé              Γöé  Γöé       Γöé
  2573.     ΓööΓöÇΓöÇwhitespaceΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ + ΓöÇΓöÇΓöñ
  2574.                       Γöé       Γöé
  2575.                       ΓööΓöÇΓöÇ - ΓöÇΓöÇΓöÿ
  2576.  
  2577. where whitespace consists of the same characters for which the isspace function 
  2578. is true, such as spaces and tabs.  The atol function ignores leading 
  2579. white-space characters. digits is one or more decimal digits. 
  2580.  
  2581. atol returns a long value produced by interpreting the input characters as a 
  2582. number.  The return value is 0L if the function cannot convert the input to a 
  2583. value of that type.  The return value is undefined in case of overflow. 
  2584.  
  2585. Example of atol 
  2586.  
  2587. Related Information 
  2588.  
  2589. o atof  - Convert Character Strings 
  2590. o atoi  - Convert Character Strings 
  2591. o _atold - Convert ASCII String to Lo         ng Double 
  2592. o stdlib.h 
  2593. o strtod  - Convert Character String to Numeric 
  2594. o strtol  - Convert Character String to Numeric 
  2595. o strtold - Convert String to Long Double 
  2596.  
  2597.  
  2598. ΓòÉΓòÉΓòÉ 2.19. _atold - Convert ASCII String to Lo                ng Double ΓòÉΓòÉΓòÉ
  2599.  
  2600. #include <stdlib.h>    /* also defined in <math.h> */
  2601.  
  2602. long double _atold(const char *nptr);
  2603.  
  2604. Language Level: Extension 
  2605.  
  2606. Description 
  2607.  
  2608. The _atold function converts a character string pointed to by nptr to a long 
  2609. double value.  The function continues until it reads a character it does not 
  2610. recognize  as part of a number.  This character may be the ending null 
  2611. character. Except for its behavior on error, _atold is equivalent to 
  2612.  
  2613.    strtold(nptr, (char **)NULL)
  2614.  
  2615. The string pointed to by nptr must have the following format: 
  2616.  
  2617. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  2618. Γöé                                                                Γöé
  2619. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ>                                          Γöé
  2620. Γöé     ΓööΓöÇwhitespaceΓöÇΓöÿ                                             Γöé
  2621. Γöé                                                                Γöé
  2622. Γöé >ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ>               Γöé
  2623. Γöé    ΓööΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇdigitsΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÿ                  Γöé
  2624. Γöé      Γö£ΓöÇ + ΓöÇΓöñ  Γöé         ΓööΓöÇΓö¼ΓöÇΓöÿ  ΓööΓöÇdigitsΓöÇΓöÿ Γöé                    Γöé
  2625. Γöé      ΓööΓöÇ ΓöÇ ΓöÇΓöÿ  ΓööΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ                    Γöé
  2626. Γöé                                                                Γöé
  2627. Γöé >ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><                            Γöé
  2628. Γöé    ΓööΓöÇΓö¼ΓöÇ e ΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÿ                                Γöé
  2629. Γöé      ΓööΓöÇ E ΓöÇΓöÿ  Γö£ΓöÇ + ΓöÇΓöñ                                          Γöé
  2630. Γöé               ΓööΓöÇ ΓöÇ ΓöÇΓöÿ                                          Γöé
  2631. Γöé                                                                Γöé
  2632. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2633.  
  2634. The digits are one or more decimal digits.  If no digits appear before the 
  2635. decimal point, at least one digit must follow the decimal point. You can place 
  2636. an exponent expressed as a decimal integer after the digits. The exponent can 
  2637. be signed. 
  2638.  
  2639. The value of nptr can also be one of the strings infinity, inf, or nan.  These 
  2640. strings are case insensitive, and can be preceded by a unary minus (-). They 
  2641. are converted to infinity and NaN values. For more information on NaN and 
  2642. infinity values, see Infinity and NaN Support. 
  2643.  
  2644. The _atold function ignores any whitespace characters, as defined by the 
  2645. isspace function. 
  2646.  
  2647. The _atold function returns the converted long double value. In the case of an 
  2648. underflow, it returns 0. In the case of a positive overflow, _atold returns 
  2649. positive _LHUGE_VAL, and negative _LHUGE_VAL for a negative overflow. 
  2650.  
  2651. Example of _atold 
  2652.  
  2653. Related Information 
  2654.  
  2655. o atof  - Convert Character Strings 
  2656. o atoi  - Convert Character Strings 
  2657. o atol  - Convert Character Strings 
  2658. o strtod  - Convert Character String to Numeric 
  2659. o strtol  - Convert Character String to Numeric 
  2660. o strtold - Convert String to Long Double 
  2661. o stdlib.h 
  2662. o math.h 
  2663.  
  2664.  
  2665. ΓòÉΓòÉΓòÉ 2.20. _beginthread - Create New Thread ΓòÉΓòÉΓòÉ
  2666.  
  2667. #include <stdlib.h>     /* also defined in <process.h> */
  2668.  
  2669. int _beginthread(void (*start_address) (void *),
  2670.                      (void *)stack,
  2671.                      unsigned stack_size,
  2672.                      void *arglist);
  2673.  
  2674. Language Level: Extension 
  2675.  
  2676. Description 
  2677.  
  2678. The _beginthread function creates a new thread and takes the following 
  2679. arguments: 
  2680.  
  2681. start_address 
  2682.   The address of the function the newly created thread will execute. When the 
  2683.   thread returns from that function, it is terminated automatically.  The user 
  2684.   can also explicitly terminate the thread by calling _endthread. 
  2685.  
  2686. stack 
  2687.   This parameter is ignored, but is retained to ease migration of C/2 programs. 
  2688.   The C/2 compiler requires the second parameter to be the address of the 
  2689.   bottom of the stack that the new thread will use. Because the OS/2 operating 
  2690.   system automatically takes care of stack allocation, the parameter is not 
  2691.   needed. 
  2692.  
  2693. stack_size 
  2694.   The size of the stack, in bytes, which is to be allocated for the new thread. 
  2695.   The stack size should be a nonzero multiple of 4 Kbytes and a minimum of 8 
  2696.   Kbytes. Memory is used when needed, one page at a time. 
  2697.  
  2698. arglist 
  2699.   A parameter to be passed to the newly created thread. It is the size of a 
  2700.   pointer, and is usually the address of a data item to be passed to the new 
  2701.   thread, such as a char string. It provides _beginthread with a value to pass 
  2702.   to the child thread. NULL can be used as a placeholder. 
  2703.  
  2704. The function that the new thread will perform must be declared and compiled 
  2705. using optlink linkage. 
  2706.  
  2707. An alternative to this function is DosCreateThread. If you use DosCreateThread, 
  2708. you must also use a #pragma handler statement for the thread function to ensure 
  2709. proper C exception handling. The use of DosCreateThread requires the use of 
  2710. DosExit to terminate the thread. 
  2711.  
  2712. Note:  When using the _beginthread and _endthread functions, you must specify 
  2713. the /Gm+ compiler option to use the multithread libraries. 
  2714.  
  2715. If successful, _beginthread returns the thread ID number of the new thread. It 
  2716. returns -1 to indicate an error. 
  2717.  
  2718. Example of _beginthread 
  2719.  
  2720. Related Information 
  2721.  
  2722. o _endthread - Terminate Current Thread 
  2723. o /Gm+ option 
  2724. o stdlib.h 
  2725. o process.h 
  2726.  
  2727.  
  2728. ΓòÉΓòÉΓòÉ 2.21. Bessel Functions ΓòÉΓòÉΓòÉ
  2729.  
  2730. #include <math.h> /* SAA extensions to ANSI */
  2731.  
  2732. double j0(double x);
  2733.  
  2734. double j1(double x);
  2735.  
  2736. double jn(int n, double x);
  2737.  
  2738. double y0(double x);
  2739.  
  2740. double y1(double x);
  2741.  
  2742. double yn(int n, double x);
  2743.  
  2744. Language Level: SAA 
  2745.  
  2746. Description 
  2747.  
  2748. Bessel functions solve certain types of differential equations.  The _j0, _j1, 
  2749. and _jn functions are Bessel functions of the first kind for orders 0, 1, and 
  2750. n, respectively. 
  2751.  
  2752. The _y0, _y1, and _yn functions are Bessel functions of the second kind for 
  2753. orders 0, 1, and n, respectively.  The argument x must be positive.  The 
  2754. argument n should be greater than or equal to zero. If n is less than zero, it 
  2755. will be a negative exponent. 
  2756.  
  2757. For _j0, _j1, _y0, or _y1, if the absolute value of x is too large, the 
  2758. function sets errno to ERANGE, and returns 0.  For _y0, _y1, or _yn, if x is 
  2759. negative, the function sets errno to EDOM and returns the value -HUGE_VAL.  For 
  2760. _y0, _y1, or _yn, if x causes overflow, the function sets errno to ERANGE and 
  2761. returns the value -HUGE_VAL. 
  2762.  
  2763. Example of bessel 
  2764.  
  2765. Related Information 
  2766.  
  2767. o erf - erfc  - Error Functions 
  2768. o gamma  - Gamma Function 
  2769. o math.h 
  2770.  
  2771.  
  2772. ΓòÉΓòÉΓòÉ 2.22. bsearch  - Search Arrays ΓòÉΓòÉΓòÉ
  2773.  
  2774. #include <stdlib.h>
  2775.  
  2776. void *bsearch(const void *key, const void *base, size_t num,
  2777.               size_t size, int (*compare) (const void *element1,
  2778.               const void *element2));
  2779.  
  2780. Language Level: ANSI, SAA, Extension 
  2781.  
  2782. Description 
  2783.  
  2784. The bsearch function performs a binary search of an array of num elements, each 
  2785. of size bytes in size.  The array must be sorted in ascending order by the 
  2786. function pointed to by compare.  The base is a pointer to the base of the array 
  2787. to search, and key is the value being sought. 
  2788.  
  2789. The compare variable is a pointer to a function you must supply, that compares 
  2790. two array elements and returns a value specifying their relationship.  The 
  2791. bsearch function calls this function one or more times during the search, 
  2792. passing the key and the pointer to one array element on each call.  The 
  2793. function must compare the elements and then return one of the following values. 
  2794.  
  2795. Value             Meaning 
  2796. Less than 0       element1 less than element2 
  2797. 0                 element1 identical to element2 
  2798. Greater than 0    element1 greater than element2 
  2799.  
  2800. The bsearch function returns a pointer to key in the array to which base 
  2801. points.  If two keys are equal, it is unspecified to which element key will 
  2802. point.  If bsearch cannot find the key, it returns NULL. 
  2803.  
  2804. Example of bsearch 
  2805.  
  2806. Related Information 
  2807.  
  2808. o qsort  - Sort Array 
  2809. o stdlib.h 
  2810.  
  2811.  
  2812. ΓòÉΓòÉΓòÉ 2.23. calloc  - Reserve and Initialize Storage ΓòÉΓòÉΓòÉ
  2813.  
  2814. #include <stdlib.h>
  2815.  
  2816. void *calloc(size_t num, size_t size);
  2817.  
  2818. Language Level: ANSI, SAA, Extension 
  2819.  
  2820. Description 
  2821.  
  2822. The calloc function reserves storage space for an array of num elements, each 
  2823. of length size bytes.  The calloc function then gives all the bits of each 
  2824. element an initial value of zero (0). 
  2825.  
  2826. The calloc function returns a pointer to the reserved space.  The storage space 
  2827. to which the return value points is guaranteed to be suitably aligned for 
  2828. storage of any type of object.  To get a pointer to a type, use a type cast on 
  2829. the return value.  The return value is NULL if there is not enough storage, or 
  2830. if num or size is zero (0). 
  2831.  
  2832. Example of calloc 
  2833.  
  2834. Related Information 
  2835.  
  2836. o _alloca - Temporarily Reserve Storag         e Block 
  2837. o _debug_calloc - Reserve and Initialize Storage 
  2838. o free  - Release Storage Blocks 
  2839. o malloc  - Reserve Storage Block 
  2840. o realloc  - Change Reserved Storage Block Size 
  2841. o malloc.h 
  2842. o stdlib.h 
  2843.  
  2844.  
  2845. ΓòÉΓòÉΓòÉ 2.24. ceil - Integer >= Argument ΓòÉΓòÉΓòÉ
  2846.  
  2847. #include <math.h>
  2848.  
  2849. double ceil(double x);
  2850.  
  2851. Language Level: ANSI, SAA 
  2852.  
  2853. Description 
  2854.  
  2855. The ceil function returns a double value representing the smallest integer that 
  2856. is greater than or equal to x. 
  2857.  
  2858. Example of ceil 
  2859.  
  2860. Related Information 
  2861.  
  2862. o floor - Integer <= Argument 
  2863. o fmod  - Floating-Point Remainder 
  2864. o math.h 
  2865.  
  2866.  
  2867. ΓòÉΓòÉΓòÉ 2.25. _cgets - Read String of Characters from Keyboard ΓòÉΓòÉΓòÉ
  2868.  
  2869. #include <conio.h>
  2870.  
  2871. char *_cgets(char *str);
  2872.  
  2873. Language Level: Extension 
  2874.  
  2875. Description 
  2876.  
  2877. The _cgets function reads a string of characters directly from the keyboard and 
  2878. stores the string and its length in the location pointed to by str. 
  2879.  
  2880. The _cgets function continues to read characters until it meets a 
  2881. carriage-return followed by a line-feed (CR-LF) or reads the specified number 
  2882. of characters. It stores the string starting at str[2]. If _cgets reads a CR-LF 
  2883. combination, it replaces this combination with a null character ('\0') before 
  2884. storing the string. The _cgets function then stores the actual length of the 
  2885. string in the second array element, str[1]. 
  2886.  
  2887. The str variable must be a pointer to a character array. The first element of 
  2888. the array, str[0], must contain the maximum length, in characters, of the 
  2889. string to be read.  The array must have enough elements to hold the string, a 
  2890. final null character, and 2 additional bytes. 
  2891.  
  2892. If successful, the _cgets function returns a pointer to the actual start of the 
  2893. string, str[2]. Otherwise, _cgets returns NULL. 
  2894.  
  2895. Example of _cgets 
  2896.  
  2897. Related Information 
  2898.  
  2899. o conio.h 
  2900. o _cputs - Write String to Screen 
  2901. o hdref refid=fgets. 
  2902. o hdref refid=gets. 
  2903. o _getch - _getche - Read Character from Keyboard 
  2904.  
  2905.  
  2906. ΓòÉΓòÉΓòÉ 2.26. _chdir - Change Current Working Directory ΓòÉΓòÉΓòÉ
  2907.  
  2908. #include <direct.h>
  2909.  
  2910. int _chdir(char *pathname);
  2911.  
  2912. Language Level: Extension 
  2913.  
  2914. Description 
  2915.  
  2916. The _chdir function causes the current working directory to change to the 
  2917. directory specified by pathname.  The pathname must refer to an existing 
  2918. directory. 
  2919.  
  2920. Note:  This function can change the current working directory on any drive.  It 
  2921. cannot change the default drive.  For example, if A:\BIN is the current working 
  2922. directory and A: is the default drive, the following changes only the current 
  2923. working directory on drive C:. 
  2924.  
  2925.    _chdir ("c:\\emp");
  2926.  
  2927. A: is still the default drive. 
  2928.  
  2929. An alternative to this function is the DosSetCurrentDir API call. 
  2930.  
  2931. The _chdir function returns a value of 0 if the working directory was 
  2932. successfully changed. A return value of -1 indicates an error;  in this case, 
  2933. _chdir sets errno to ENOENT, showing that _chdir cannot find the specified path 
  2934. name.  No error occurs if pathname specifies the current working directory. 
  2935.  
  2936. Example of _chdir 
  2937.  
  2938. Related Information 
  2939.  
  2940. o _chdrive - Change Current Working Drive 
  2941. o _getcwd - Get Path Name of Current Directory 
  2942. o _getdcwd - Get Full Path Name of Current Directory 
  2943. o _getdrive - Get Current Working Drive 
  2944. o system - Invoke the Command Processor 
  2945. o _mkdir - Create New Directory 
  2946. o _rmdir - Remove Directory 
  2947. o system - Invoke the Command Processor 
  2948. o direct.h 
  2949.  
  2950.  
  2951. ΓòÉΓòÉΓòÉ 2.27. _chdrive - Change Current Working Drive ΓòÉΓòÉΓòÉ
  2952.  
  2953. #include <direct.h>
  2954.  
  2955. int _chdrive(int drive);
  2956.  
  2957. Language Level: Extension 
  2958.  
  2959. Description 
  2960.  
  2961. The _chdrive function changes the current working drive to the drive specified. 
  2962. The drive variable is an integer value representing the number of the new 
  2963. working drive (A: is 1, B: is 2, and so on). 
  2964.  
  2965. To change the default drive, include <os2.h>, define INCL_DOSFILEMGR, and use 
  2966. DosSetDefaultDisk to pass the appropriate command to the operating system. You 
  2967. can also use DosQueryCurrentDisk to query the disk. For more information, refer 
  2968. to the OS/2 2.0 Toolkit documentation. 
  2969.  
  2970. If _chdrive is successful in changing the working drive, it returns 0.  A 
  2971. return value of -1 indicates an error; in this case, _chdrive sets errno to 
  2972. EOS2ERR. 
  2973.  
  2974. Example of _chdrive 
  2975.  
  2976. Related Information 
  2977.  
  2978. o _chdir - Change Current Working Directory 
  2979. o _getcwd - Get Path Name of Current Directory 
  2980. o _getdcwd - Get Full Path Name of Current Directory 
  2981. o _getdrive - Get Current Working Drive 
  2982. o _mkdir - Create New Directory 
  2983. o _rmdir - Remove Directory 
  2984. o direct.h 
  2985.  
  2986.  
  2987. ΓòÉΓòÉΓòÉ 2.28. _chmod - Change File Permission Setting ΓòÉΓòÉΓòÉ
  2988.  
  2989. #include <io.h>
  2990. #include <sys\stat.h>
  2991.  
  2992. int _chmod(char *pathname, int pmode);
  2993.  
  2994. Language Level: Extension 
  2995.  
  2996. Description 
  2997.  
  2998. The _chmod function changes the permission setting of the file specified by 
  2999. pathname. The permission setting controls access to the file for reading or 
  3000. writing. The pmode expression contains one or both of the constants S_IWRITE 
  3001. and S_IREAD, defined in <sys\stat.h>. You can use the _chmod function only if 
  3002. the file is closed. The following list gives the meaning for the values of the 
  3003. pmode argument. 
  3004.  
  3005. Value                   Meaning 
  3006. S_IREAD                 Reading permitted 
  3007. S_IWRITE                Writing permitted 
  3008. S_IREAD | S_IWRITE      Reading and writing permitted. 
  3009.  
  3010. If you do not give permission to write to the file, the _chmod function makes 
  3011. the file read-only. With the OS/2 operating system, all files are readable; you 
  3012. cannot give write-only permission. Thus, the modes S_IWRITE and S_IREAD | 
  3013. S_IWRITE set the same permission. 
  3014.  
  3015. Specifying a pmode of S_IREAD is similar to making a file read-only with the 
  3016. ATTRIB system command. 
  3017.  
  3018. The _chmod function returns the value 0 if it successfully changes the 
  3019. permission setting.  A return value of -1 shows an error; in this case, the 
  3020. _chmod function set errno to one of the following values: 
  3021.  
  3022. Value          Meaning 
  3023. ENOENT         The system cannot find the file or the path that you specified, 
  3024.                or the file name was incorrect. 
  3025. EOS2ERR        The call to the operating system was not successful. 
  3026. EINVAL         The mode specified was not valid. 
  3027.  
  3028. Example of _chmod 
  3029.  
  3030. Related Information 
  3031.  
  3032. o _access - Determine Access Mode 
  3033. o _umask - Sets File Mask of Current Process 
  3034. o sys\stat.h 
  3035. o io.h 
  3036.  
  3037.  
  3038. ΓòÉΓòÉΓòÉ 2.29. _chsize - Alter Length of File ΓòÉΓòÉΓòÉ
  3039.  
  3040. #include <io.h>
  3041.  
  3042. int _chsize(int handle, long size);
  3043.  
  3044. Language Level: Extension 
  3045.  
  3046. Description 
  3047.  
  3048. The _chsize function lengthens or cuts off the file associated with handle to 
  3049. the length specified by size. You must open the file in a mode that permits 
  3050. writing. The _chsize function adds null characters (\0) when it lengthens the 
  3051. file. When _chsize cuts off the file, it erases all data from the end of the 
  3052. shortened file to the end of the original file. 
  3053.  
  3054. The _chsize function returns the value 0 if it successfully changes the file 
  3055. size.  A return value of -1 shows an error, and _chsize sets errno to one of 
  3056. the following values: 
  3057.  
  3058. Value          Meaning 
  3059. EACCESS        The specified file is locked against access. 
  3060. EBADF          The file handle is not valid, or the file is not open for 
  3061.                writing. 
  3062. ENOSPC         There is no space left on the device. 
  3063. EOS2ERR        The call to the operating system was not successful. 
  3064.  
  3065. Example of _chsize 
  3066.  
  3067. Related Information 
  3068.  
  3069. o _filelength - Determine File Length 
  3070. o _lseek - Move File Pointer 
  3071. o io.h 
  3072.  
  3073.  
  3074. ΓòÉΓòÉΓòÉ 2.30. clearerr  - Reset Error Indicators ΓòÉΓòÉΓòÉ
  3075.  
  3076. #include <stdio.h>
  3077.  
  3078. void clearerr (FILE *stream);
  3079.  
  3080. Language Level: ANSI, SAA 
  3081.  
  3082. Description 
  3083.  
  3084. The clearerr function resets the error indicator and end-of-file indicator for 
  3085. the specified stream.  Once set, the indicators for a specified stream remain 
  3086. set until your program calls clearerr or rewind.  The fseek function also 
  3087. clears the end-of-file indicator. 
  3088.  
  3089. Example of clearerr 
  3090.  
  3091. Related Information 
  3092.  
  3093. o feof  - Test End-of-File Indicator 
  3094. o ferror  - Test for Read/Write Errors 
  3095. o perror  - Print Error Message 
  3096. o rewind  - Adjust Current File Position 
  3097. o stdio.h 
  3098.  
  3099.  
  3100. ΓòÉΓòÉΓòÉ 2.31. _clear87 - Clear Floating-Point Statu                s Word ΓòÉΓòÉΓòÉ
  3101.  
  3102. #include <float.h>
  3103.  
  3104. unsigned int _clear87(void);
  3105.  
  3106. Language Level: Extension 
  3107.  
  3108. Description 
  3109.  
  3110. The _clear87 function gets the floating-point status word and then clears it. 
  3111. The floating-point status word is a combination of the numeric coprocessor 
  3112. status word and other conditions that the numeric exception handler detects, 
  3113. such as floating-point stack overflow and underflow. 
  3114.  
  3115. The _clear87 function will only affect the current thread. It does not affect 
  3116. any other threads that may be processing. 
  3117.  
  3118. The bits in the value returned reflect the floating-point status before the 
  3119. call to _clear87 was made. 
  3120.  
  3121. Example of _clear87 
  3122.  
  3123. Related Information 
  3124.  
  3125. o _control87 - Set Floating-Point Status         Word 
  3126. o _status87 - Get Floating-Point Status Word 
  3127. o _fpreset - Reset Floating-Point Unit 
  3128. o float.h 
  3129.  
  3130.  
  3131. ΓòÉΓòÉΓòÉ 2.32. clock  - Determine Processor Time ΓòÉΓòÉΓòÉ
  3132.  
  3133. #include <time.h>
  3134.  
  3135. clock_t clock(void);
  3136.  
  3137. Language Level: ANSI, SAA 
  3138.  
  3139. Description 
  3140.  
  3141. The clock function returns an approximation of the processor time used by the 
  3142. program since the beginning of an implementation-defined era that is related to 
  3143. the program invocation. To obtain the time in seconds, divide the value 
  3144. returned by clock by the value of the macro CLOCKS_PER_SEC. 
  3145.  
  3146. If the value of the processor time is not available or cannot be represented, 
  3147. clock returns the value (clock_t)-1. 
  3148.  
  3149. To measure the time spent in a program, call the clock function at the start of 
  3150. the program, and subtract its return value from the value returned by 
  3151. subsequent calls to clock. 
  3152.  
  3153. Example of clock 
  3154.  
  3155. Related Information 
  3156.  
  3157. o difftime  - Compute Time Difference 
  3158. o time  - Determine Current Time 
  3159. o time.h 
  3160.  
  3161.  
  3162. ΓòÉΓòÉΓòÉ 2.33. _control87 - Set Floating-Point Status                Word ΓòÉΓòÉΓòÉ
  3163.  
  3164. #include <float.h>
  3165.  
  3166. unsigned int _control87(unsigned int new, unsigned int mask);
  3167.  
  3168. Language Level: Extension 
  3169.  
  3170. Description 
  3171.  
  3172. The _control87 function gets the current floating-point control word and then 
  3173. sets it. The floating-point control word specifies the precision, rounding, and 
  3174. infinity modes of the floating-point chip. 
  3175.  
  3176. You can mask or unmask current floating-point exceptions using the _control87 
  3177. function. If the value for the mask is equal to 0, _control87 gets the 
  3178. floating-point control word. If the mask is nonzero, _control87 sets a new 
  3179. value for the control word in the manner described below, and returns the 
  3180. previous value of the control word. For any bit in the mask equal to 1, the 
  3181. corresponding bit in new updates the control word. This is equivalent to the 
  3182. expression: 
  3183.  
  3184.    fpcntrl = ((fpcntrl & ~ mask) Γöé (new & mask))
  3185.  
  3186. where fpcntrl is the floating-point control word. 
  3187.  
  3188. The _control87 function is used for the current thread only. It does not affect 
  3189. any other threads that may be processing. 
  3190.  
  3191. Warning: If you change the content of the floating-point control word: 
  3192.  
  3193. o The behavior of the math functions with regard to domain and range errors may 
  3194.   be undefined. 
  3195. o Math functions may not handle infinity and NaN values correctly. 
  3196. o Some floating-point exceptions may not occur, while other new ones may occur. 
  3197. o Resetting the EM_INEXACT bit may cause SIG_FPE exceptions, which decrease 
  3198.   performance. 
  3199. o If the precision or rounding bits are modified, you can reduce the precision 
  3200.   available for float and double variables. 
  3201.  
  3202. The bits in the returned value reflect the floating-point control word before 
  3203. the call. 
  3204.  
  3205. Example of _control87 
  3206.  
  3207. Related Information 
  3208.  
  3209. o _clear87 - Clear Floating-Point Statu         s Word 
  3210. o _status87 - Get Floating-Point Status Word 
  3211. o _fpreset - Reset Floating-Point Unit 
  3212. o Floating-Point Variables 
  3213. o signal - Install Interrupt Handlers 
  3214. o float.h 
  3215.  
  3216.  
  3217. ΓòÉΓòÉΓòÉ 2.34. _close - Closes File Associated with Handle ΓòÉΓòÉΓòÉ
  3218.  
  3219. #include <io.h>
  3220.  
  3221. int _close(int handle);
  3222.  
  3223. Language Level: Extension 
  3224.  
  3225. Description 
  3226.  
  3227. The _close function closes the file associated with the handle. Do not close 
  3228. handle associated with a stream; use fclose on the stream instead. 
  3229.  
  3230. The _close function returns 0 if it successfully closes the file. A return 
  3231. value of -1 shows an error, and _close sets errno to EBADF, showing an 
  3232. incorrect file handle argument. 
  3233.  
  3234. Example of _close 
  3235.  
  3236. Related Information 
  3237.  
  3238. o fclose  - Close Stream 
  3239. o _creat - Create New File 
  3240. o _open - Open File 
  3241. o _sopen - Open Shared File 
  3242. o io.h 
  3243.  
  3244.  
  3245. ΓòÉΓòÉΓòÉ 2.35. cos  - Cosine ΓòÉΓòÉΓòÉ
  3246.  
  3247. #include <math.h>
  3248.  
  3249. double cos(double x);  /* Calculate the cosine of x */
  3250.  
  3251. Language Level: ANSI, SAA 
  3252.  
  3253. Description 
  3254.  
  3255. The cos function returns the cosine of x.  The value x is expressed in radians. 
  3256. If x is large, a partial loss of significance in the result may occur. 
  3257.  
  3258. Example of cos 
  3259.  
  3260. Related Information 
  3261.  
  3262. o acos  - Arc Cosine 
  3263. o asin  - Arc Sine 
  3264. o atan - atan2  - Arc Tangent 
  3265. o cosh  - Hyperbolic Cosine 
  3266. o sin  - Sine 
  3267. o sinh  - Hyperbolic Sine 
  3268. o tan  - Tangent 
  3269. o tanh  - Hyperbolic Tangent 
  3270. o math.h 
  3271.  
  3272.  
  3273. ΓòÉΓòÉΓòÉ 2.36. cosh  - Hyperbolic Cosine ΓòÉΓòÉΓòÉ
  3274.  
  3275. #include <math.h>
  3276.  
  3277. double cosh(double x);  /* Calculate the hyperbolic cosine of x */
  3278.  
  3279. Language Level: ANSI, SAA 
  3280.  
  3281. Description 
  3282.  
  3283. The cosh function returns the hyperbolic cosine of x. The value x is expressed 
  3284. in radians. If the result is too large, cosh returns the value HUGE_VAL and 
  3285. sets errno to ERANGE. 
  3286.  
  3287. Example of cosh 
  3288.  
  3289. Related Information 
  3290.  
  3291. o acos  - Arc Cosine 
  3292. o asin  - Arc Sine 
  3293. o atan - atan2  - Arc Tangent 
  3294. o cos  - Cosine 
  3295. o sin  - Sine 
  3296. o sinh  - Hyperbolic Sine 
  3297. o tan  - Tangent 
  3298. o tanh  - Hyperbolic Tangent 
  3299. o math.h 
  3300.  
  3301.  
  3302. ΓòÉΓòÉΓòÉ 2.37. _cprintf - Print Characters to Screen ΓòÉΓòÉΓòÉ
  3303.  
  3304. #include <conio.h>
  3305.  
  3306. int _cprintf(char *format-string, argument-list);
  3307.  
  3308. Language Level: Extension 
  3309.  
  3310. Description 
  3311.  
  3312. The _cprintf function formats and sends a series of characters and values 
  3313. directly to the screen, using the _putch function to send each character. 
  3314.  
  3315. The format-string has the same form and function as the format-string parameter 
  3316. for printf. Format specifications in the format-string determine the output 
  3317. format for any argument-list that follows. See printf for a description of the 
  3318. format-string. 
  3319.  
  3320. Note:  Unlike the fprintf, printf, and sprintf functions, _cprintf does not 
  3321. translate line feed characters into output of a carriage-return followed by a 
  3322. line-feed. 
  3323.  
  3324. The _cprintf function returns the number of characters printed. 
  3325.  
  3326. Example of _cprintf 
  3327.  
  3328. Related Information 
  3329.  
  3330. o _cscanf - Read Data from Keyboard 
  3331. o fprintf  - Formatted Write 
  3332. o printf  - Formatted Print 
  3333. o _putch - Write Character to Screen 
  3334. o sprintf  - Formatted Print to Buffer 
  3335. o conio.h 
  3336.  
  3337.  
  3338. ΓòÉΓòÉΓòÉ 2.38. _cputs - Write String to Screen ΓòÉΓòÉΓòÉ
  3339.  
  3340. #include <conio.h>
  3341.  
  3342. int _cputs(char *str);
  3343.  
  3344. Language Level: Extension 
  3345.  
  3346. Description 
  3347.  
  3348. The _cputs function writes directly to the screen the string to which str 
  3349. points. The string str must end with a null character (\0). The _cputs function 
  3350. does not automatically add a carriage-return followed by a line-feed to the 
  3351. string after writing. 
  3352.  
  3353. If successful, _cputs returns 0. Otherwise, it returns a nonzero value. 
  3354.  
  3355. Example of _cputs 
  3356.  
  3357. Related Information 
  3358.  
  3359. o _cgets - Read String of Characters from Keyboard 
  3360. o fputs  - Print Strings 
  3361. o _putch - Write Character to Screen 
  3362. o puts  - Write a String 
  3363. o conio.h 
  3364.  
  3365.  
  3366. ΓòÉΓòÉΓòÉ 2.39. _creat - Create New File ΓòÉΓòÉΓòÉ
  3367.  
  3368. #include <io.h>
  3369. #include <sys\stat.h>
  3370.  
  3371. int _creat(char *pathname, int pmode);
  3372.  
  3373. Language Level: Extension 
  3374.  
  3375. Description 
  3376.  
  3377. The _creat function either creates a new file or opens and truncates an 
  3378. existing file. If the file specified by pathname does not exist, _creat creates 
  3379. a new file with the given permission setting and opens for writing in text 
  3380. mode. If the file already exists, and the read-only attribute and sharing 
  3381. permissions allow writing, _creat truncates the file to length 0. This destroys 
  3382. the previous contents of the file and opens it for writing in text mode. The 
  3383. _creat function always opens a file in text mode for reading and writing. 
  3384.  
  3385. The permission setting pmode applies to newly created files only. The new file 
  3386. receives the specified permission setting after you close it for the first 
  3387. time. The pmode integer expression contains one or both of the constants 
  3388. S_IWRITE and S_IREAD, defined in <sys\stat.h>. The following gives the values 
  3389. of the pmode argument and their meaning: 
  3390.  
  3391. Value                   Meaning 
  3392. S_IREAD                 Reading permitted 
  3393. S_IWRITE                Writing permitted 
  3394. S_IREAD | S_IWRITE      Reading and writing permitted. 
  3395.  
  3396. If you do not give permission to write to the file, the file is a read-only 
  3397. file. On the OS/2 operating system, you cannot give write-only permission. 
  3398. Thus, the modes S_IWRITE and S_IREAD | S_IWRITE have the same results. The 
  3399. _creat function applies the current file permission mask to pmode before 
  3400. setting the permissions. (See _umask - Sets File Mask of Current Process for 
  3401. more information about file permission masks.) 
  3402.  
  3403. When writing new code, it is preferable to use _open rather than _creat. 
  3404.  
  3405. Specifying a pmode of S_IREAD is similar to making a file read-only with the 
  3406. ATTRIB system command. 
  3407.  
  3408. The _creat function returns a handle for the created file if the call is 
  3409. successful. A return value of -1 shows an error, and _creat sets errno to one 
  3410. of the following values: 
  3411.  
  3412. Value          Meaning 
  3413. EACCESS        File sharing violated. 
  3414. EINVAL         The mode specified was not valid. 
  3415. EMFILE         No more file handles are available. 
  3416. ENOENT         The pathname was not found, or the file name was incorrect. 
  3417. EOS2ERR        The call to the operating system was not successful. 
  3418.  
  3419. Example of _creat 
  3420.  
  3421. Related Information 
  3422.  
  3423. o _close - Closes File Associated with Handle 
  3424. o _open - Open File 
  3425. o _fdopen - Associates Input Or Output With File 
  3426. o _sopen - Open Shared File 
  3427. o _umask - Sets File Mask of Current Process 
  3428. o sys\stat.h 
  3429. o io.h 
  3430.  
  3431.  
  3432. ΓòÉΓòÉΓòÉ 2.40. _cscanf - Read Data from Keyboard ΓòÉΓòÉΓòÉ
  3433.  
  3434. #include <conio.h>
  3435.  
  3436. int _cscanf(char *format-string, argument-list);
  3437.  
  3438. Language Level: Extension 
  3439.  
  3440. Description 
  3441.  
  3442. The _cscanf function reads data directly from the keyboard to the locations 
  3443. given by argument-list, if any are specified. The _cscanf function uses the 
  3444. _getche function to read characters. Each argument must be a pointer to a 
  3445. variable with a type that corresponds to a type specifier in the format-string. 
  3446.  
  3447. The format-string controls the interpretation of the input fields and has the 
  3448. same form and function as the format-string argument for the scanf function. 
  3449. See scanf for a description of the format-string. 
  3450.  
  3451. Note:  Although _cscanf normally echoes the input character, it does not do so 
  3452. if the last action was a call to _ungetch. 
  3453.  
  3454. The _cscanf function returns the number of fields that were successfully 
  3455. converted and assigned. The return value does not include fields that were read 
  3456. but not assigned. 
  3457.  
  3458. The return value is EOF for an attempt to read at the end of the file. A return 
  3459. value of 0 means that no fields were assigned. 
  3460.  
  3461. Example of _cscanf 
  3462.  
  3463. Related Information 
  3464.  
  3465. o fscanf  - Read Formatted Data 
  3466. o _getch - _getche - Read Character from Keyboard 
  3467. o scanf  - Read Data 
  3468. o sscanf  - Read Data 
  3469. o _ungetch - Push Character Back to Keyboard 
  3470. o conio.h 
  3471.  
  3472.  
  3473. ΓòÉΓòÉΓòÉ 2.41. ctime  - Convert Time ΓòÉΓòÉΓòÉ
  3474.  
  3475. #include <time.h>
  3476.  
  3477. char *ctime(const time_t *time);
  3478.  
  3479. Language Level: ANSI, SAA 
  3480.  
  3481. Description 
  3482.  
  3483. The ctime function converts the time value pointed to by time to local time in 
  3484. the form of a character string.  A time value is usually obtained by a call to 
  3485. the time function. 
  3486.  
  3487. The string result produced by ctime contains exactly 26 characters and has the 
  3488. format 
  3489.  
  3490.    "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"
  3491. for example: 
  3492.  
  3493.    Mon Jul 16 02:03:55 1987\n\0
  3494.  
  3495. The ctime function uses a 24-hour clock format.  The days are abbreviated to: 
  3496. Sun, Mon, Tue, Wed, Thu, Fri, and Sat.  The months are abbreviated to:  Jan, 
  3497. Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec.  All fields have a 
  3498. constant width. Dates with only one digit are preceded either with a zero or a 
  3499. blank space, depending on the compiler. The newline character (\n) and the null 
  3500. character (\0) occupy the last two positions of the string. 
  3501.  
  3502. The ctime function returns a pointer to the character string result.  There is 
  3503. no error return value.  The ctime function is equivalent to: 
  3504.  
  3505.    asctime(localtime(&anytime))
  3506.  
  3507. Note:  The asctime, ctime, and other time functions may use a common, 
  3508.        statically allocated buffer for holding the return string.  Each call to 
  3509.        one of these functions may destroy the result of the previous call. 
  3510.  
  3511. Note:  The time and date functions begin at 00:00:00 Universal Time, January 1, 
  3512. 1970. :enote. 
  3513.  
  3514. Example of ctime 
  3515.  
  3516. Related Information 
  3517.  
  3518. o asctime  - Convert Time 
  3519. o gmtime  - Convert Time 
  3520. o localtime  - Convert Time 
  3521. o time  - Determine Current Time 
  3522. o time.h 
  3523.  
  3524.  
  3525. ΓòÉΓòÉΓòÉ 2.42. _cwait - Wait for Child Process ΓòÉΓòÉΓòÉ
  3526.  
  3527. #include <process.h>
  3528.  
  3529. int _cwait(int *stat_loc, int process_id, int action_code);
  3530.  
  3531. Language Level: Extension 
  3532.  
  3533. Description 
  3534.  
  3535. The _cwait function delays the completion of a parent process until the child 
  3536. process specified by process_id ends. 
  3537.  
  3538. The process_id is the value returned by the _spawn function that started the 
  3539. child process. If the specified child process ends before _cwait is called, 
  3540. _cwait returns to the calling process immediately with a value of -1. If the 
  3541. value of process_id is 0, the parent process waits until all of its child 
  3542. processes end. 
  3543.  
  3544. If the variable pointed to by stat_loc is NULL, the _cwait function does not 
  3545. use it.  If it is not NULL, _cwait places information about the return status 
  3546. and the return code of the child process in the location to which stat_loc 
  3547. points. 
  3548.  
  3549. If the child process ended normally with a call to the OS/2 DosExit function, 
  3550. the lowest-order byte of the variable pointed to by stat_loc is 0.  The next 
  3551. highest-order byte contains the lowest-order byte of the argument passed to 
  3552. DosExit by the child process. The value of this byte depends on how the child 
  3553. process caused the system to call DosExit.  If the child called exit, _exit, 
  3554. &return. from main, or used a DosExit coded into the program, the byte contains 
  3555. the lowest-order byte of the argument the child passed to exit, _exit, or 
  3556. &return.. The value of the byte is undefined if the child caused a DosExit call 
  3557. simply by reaching the end of main. 
  3558.  
  3559. If the child process ended abnormally (without a call to DosExit), the 
  3560. lowest-order byte of the variable pointed to by stat_loc contains the return 
  3561. code from the OS/2 DosWaitChild function, and the next higher-order byte is 0. 
  3562. See the OS/2 online reference for details about the DosWaitChild return codes. 
  3563.  
  3564. The action_code specifies when the parent process is to start running again. 
  3565. Values for action_code include: 
  3566.  
  3567. Action Code Meaning 
  3568. WAIT_CHILD 
  3569.           The parent process waits until the specified child process ends. 
  3570. WAIT_GRANDCHILD 
  3571.           The parent process waits until the child process and all of the child 
  3572.           processes of that process end. 
  3573.  
  3574. The action code values are defined in <process.h>. 
  3575.  
  3576. Note:  Because the size of an int is only 2 bytes in the C/2 compiler, some 
  3577. parts of your programs may have to be rewritten if they use this function. 
  3578.  
  3579. An alternative to this function is the DosWaitChild API call. 
  3580.  
  3581. At the normal end of the child process, _cwait returns the process identifier 
  3582. of the child to the parent process. If a child process ends abnormally, _cwait 
  3583. returns -1 to the parent process and sets errno to EINTR. In the case of an 
  3584. error, _cwait returns immediately with a value of -1 and sets errno to one of 
  3585. the following values: 
  3586.  
  3587. Value     Meaning 
  3588. EINVAL    Incorrect action code 
  3589. ECHILD    No child process exists, or the process identifier is incorrect. 
  3590.  
  3591. Example of _cwait 
  3592.  
  3593. Related Information 
  3594.  
  3595. o exit  - End Program 
  3596. o _exit - End Process 
  3597. o _spawnl - _spawnvpe - Start and Run Child Processes 
  3598. o _wait - Wait for Child Process 
  3599. o return 
  3600. o process.h 
  3601.  
  3602.  
  3603. ΓòÉΓòÉΓòÉ 2.42.1. _debug_calloc - Reserve and Initialize Storage ΓòÉΓòÉΓòÉ
  3604.  
  3605. #define __DEBUG_ALLOC__
  3606. #include <stdlib.h>
  3607.  
  3608. void *_debug_calloc(size_t num, size_t size, const char *pFilename, size_t linenum);
  3609.  
  3610. Description 
  3611.  
  3612. The _debug_calloc function is the debug version of calloc, and performs the 
  3613. same function.  It reserves storage space for an array of num elements, each of 
  3614. length size bytes, and initializes all bits of each element to 0. 
  3615.  
  3616. In addition, _debug_calloc makes an implicit call to the _heap_check function. 
  3617. It also stores the name of the file pFilename and the line number linenum where 
  3618. the storage is allocated.  This information can be used later by _heap_check 
  3619. and the _dump_allocated function. 
  3620.  
  3621. The _debug_calloc function returns a pointer to the reserved space. If not 
  3622. enough storage is available, or if num or size is 0, _debug_calloc returns 
  3623. NULL. 
  3624.  
  3625. Language Level Extension, Migration (in <malloc.h>) 
  3626.  
  3627. Example of _debug_calloc 
  3628.  
  3629. Related Information 
  3630.  
  3631. o calloc  - Reserve and Initialize Storage 
  3632. o _debug_free - Release Storage Blocks 
  3633. o _debug_malloc - Reserve Storage Blocks 
  3634. o _debug_realloc - Change Reserved Storage Block Size 
  3635. o _dump_allocated - Get Information about Allocated Storage 
  3636. o _heap_check - Validate Run-Time Storage Heap 
  3637. o Using the Debug Memory Management Functions 
  3638. o malloc.h 
  3639. o stdlib.h 
  3640.  
  3641.  
  3642. ΓòÉΓòÉΓòÉ 2.42.2. _debug_free - Release Storage Blocks ΓòÉΓòÉΓòÉ
  3643.  
  3644. #define __DEBUG_ALLOC__
  3645. #include <stdlib.h>
  3646.  
  3647. void _debug_free(void *ptr, const char *pFilename, size_t linenum);
  3648. Description 
  3649.  
  3650. The _debug_free function is the debug version of free and performs the same 
  3651. function.  It frees the block of storage pointed to by ptr that has been 
  3652. allocated by either a normal or a debug version of the memory management 
  3653. functions. 
  3654.  
  3655. In addition, _debug_free makes an implicit call to the _heap_check function. It 
  3656. also stores the file name pFilename and  the line number linenum where the 
  3657. storage is freed.  This information can be used later by _heap_check and the 
  3658. _dump_allocated function. 
  3659.  
  3660. Note:  If the block of storage pointed to by ptr was not allocated using the 
  3661.        memory management functions or was previously freed, a message appears 
  3662.        and the program ends. 
  3663.  
  3664. There is no return value. 
  3665.  
  3666. Language Level Extension, Migration (in <malloc.h>) 
  3667.  
  3668. Example of _debug_free 
  3669.  
  3670. Related Information 
  3671.  
  3672. o _debug_calloc - Reserve and Initialize Storage 
  3673. o _debug_malloc - Reserve Storage Blocks 
  3674. o _debug_realloc - Change Reserved Storage Block Size 
  3675. o _dump_allocated - Get Information about Allocated Storage 
  3676. o free  - Release Storage Blocks 
  3677. o _heap_check - Validate Run-Time Storage Heap 
  3678. o Using the Debug Memory Management Functions 
  3679. o malloc.h 
  3680. o stdlib.h 
  3681.  
  3682.  
  3683. ΓòÉΓòÉΓòÉ 2.42.3. _debug_heapmin - Release Unused Memory in the Heap ΓòÉΓòÉΓòÉ
  3684.  
  3685. #define __DEBUG_ALLOC__
  3686. #include <stdlib.h>
  3687.  
  3688. int _debug_heapmin(const char *pFilename, size_t linenum);
  3689.  
  3690. Description 
  3691.  
  3692. The _debug_heapmin function is the debug version of _heapmin and performs the 
  3693. same function.  It returns all unused memory from the run-time heap to the 
  3694. operating system. 
  3695.  
  3696. In addition, _debug_heapmin makes an implicit call to the _heap_check function. 
  3697. It also stores the file name pFilename and the line number linenum where the 
  3698. memory is returned.  This information can be used later by _heap_check and the 
  3699. _dump_allocated function. 
  3700.  
  3701. If successful, _debug_heapmin returns 0; otherwise, it returns -1. 
  3702.  
  3703. Language Level Extension, Migration (in <malloc.h>) 
  3704.  
  3705. Example of _debug_heapmin 
  3706.  
  3707. Related Information 
  3708.  
  3709. o _dump_allocated - Get Information about Allocated Storage 
  3710. o _heapmin - Release Unused Memory in the Heap 
  3711. o _heap_check - Validate Run-Time Storage Heap 
  3712. o Using the Debug Memory Management Functions 
  3713. o malloc.h 
  3714. o stdlib.h 
  3715.  
  3716.  
  3717. ΓòÉΓòÉΓòÉ 2.42.4. _debug_malloc - Reserve Storage Blocks ΓòÉΓòÉΓòÉ
  3718.  
  3719. #define __DEBUG_ALLOC__
  3720. #include <stdlib.h>
  3721.  
  3722. void *_debug_malloc(size_t size, const char *pFilename, size_t linenum);
  3723.  
  3724. Description 
  3725.  
  3726. The _debug_malloc function is the debug version of malloc and performs the same 
  3727. function.  It reserves a block of storage of size bytes. 
  3728.  
  3729. In addition, _debug_malloc makes an implicit call to the _heap_check function. 
  3730. It also stores the file name pFilename and the line number linenum where the 
  3731. storage is allocated.  This information can later be used by _heap_check and 
  3732. the _dump_allocated function. 
  3733.  
  3734. The _debug_malloc function returns a pointer to the reserved space.  If not 
  3735. enough storage is available or if size is 0, _debug_malloc returns NULL. 
  3736.  
  3737. Language Level Extension, Migration (in <malloc.h>) 
  3738.  
  3739. Example of _debug_malloc 
  3740.  
  3741. Related Information 
  3742.  
  3743. o _debug_calloc - Reserve and Initialize Storage 
  3744. o _debug_free - Release Storage Blocks 
  3745. o _debug_realloc - Change Reserved Storage Block Size 
  3746. o _dump_allocated - Get Information about Allocated Storage 
  3747. o _heap_check - Validate Run-Time Storage Heap 
  3748. o malloc  - Reserve Storage Block 
  3749. o Using the Debug Memory Management Functions 
  3750. o malloc.h 
  3751. o stdlib.h 
  3752.  
  3753.  
  3754. ΓòÉΓòÉΓòÉ 2.42.5. _debug_realloc - Change Reserved Storage Block Size ΓòÉΓòÉΓòÉ
  3755.  
  3756. #define __DEBUG_ALLOC__
  3757. #include <stdlib.h>
  3758.  
  3759. void *_debug_realloc(void *ptr, size_t size, const char *pFilename, size_t linenum);
  3760.  
  3761. Description 
  3762.  
  3763. The _debug_realloc function is the debug version of realloc and performs the 
  3764. same function. It reallocates the block of storage pointed to by ptr to a new 
  3765. size, specified in bytes. In addition, _debug_realloc makes an implicit call to 
  3766. the _heap_check function. 
  3767.  
  3768. It also stores the file name pFilename and the line number linenum where the 
  3769. storage is reallocated.  This information can be used later by _heap_check and 
  3770. the _dump_allocated function. 
  3771.  
  3772. If ptr is NULL, _debug_realloc behaves like _debug_malloc. 
  3773.  
  3774. Note:  The _debug_realloc function reallocates storage that has been allocated 
  3775.        by either a normal or a debug version of the memory management 
  3776.        functions. If the block of storage pointed to by ptr was not allocated 
  3777.        using the memory management functions or was previously freed, a message 
  3778.        will appear and the program will end. 
  3779.  
  3780. The _debug_realloc function returns a pointer to the reallocated storage block. 
  3781. The ptr argument to _debug_realloc is not necessarily the same as the return 
  3782. value, as the storage location might be moved by _debug_realloc. 
  3783.  
  3784. If size is 0, _debug_realloc returns NULL.  If not enough storage space is 
  3785. available to expand the block to the given size, the original block is 
  3786. unchanged and NULL is returned. 
  3787.  
  3788. Language Level Extension, Migration (in <malloc.h>) 
  3789.  
  3790. Example of _debug_realloc 
  3791.  
  3792. Related Information 
  3793.  
  3794. o _debug_calloc - Reserve and Initialize Storage 
  3795. o _debug_free - Release Storage Blocks 
  3796. o _debug_malloc - Reserve Storage Blocks 
  3797. o _dump_allocated - Get Information about Allocated Storage 
  3798. o _heap_check - Validate Run-Time Storage Heap 
  3799. o realloc  - Change Reserved Storage Block Size 
  3800. o Using the Debug Memory Management Functions 
  3801. o malloc.h 
  3802. o stdlib.h 
  3803.  
  3804.  
  3805. ΓòÉΓòÉΓòÉ 2.43. difftime  - Compute Time Difference ΓòÉΓòÉΓòÉ
  3806.  
  3807. #include <time.h>
  3808.  
  3809. double difftime(time_t time2, time_t time1);
  3810.  
  3811. Language Level: ANSI, SAA 
  3812.  
  3813. Description 
  3814.  
  3815. The difftime function computes the difference in seconds between time2 and 
  3816. time1.  The difftime function returns the elapsed time in seconds from time1 to 
  3817. time2 as a double precision number.  Type time_t is defined in <time.h>. 
  3818.  
  3819. Example of difftime 
  3820.  
  3821. Related Information 
  3822.  
  3823. o asctime  - Convert Time 
  3824. o gmtime  - Convert Time 
  3825. o localtime  - Convert Time 
  3826. o time  - Determine Current Time 
  3827. o time.h 
  3828.  
  3829.  
  3830. ΓòÉΓòÉΓòÉ 2.44. _disable - Disable Interrupts ΓòÉΓòÉΓòÉ
  3831.  
  3832. #include <builtin.h>
  3833.  
  3834. void _disable( void );
  3835.  
  3836. Language Level: Extension 
  3837.  
  3838. Description 
  3839.  
  3840. The _disable function disables interrupts by executing the CLI machine 
  3841. instruction.  It disables interrupts until the instruction after a call to 
  3842. _enable has been executed. 
  3843.  
  3844. Because it is a built-in function and has no backing code in the library: 
  3845.  
  3846. o You cannot take the address of _disable. 
  3847. o You cannot parenthesize a _disable function call, because parentheses specify 
  3848.   a call to the backing code for the function in the library. 
  3849.  
  3850. You can run code containing this function only at ring zero. Otherwise, an 
  3851. invalid instruction exception will be received. 
  3852.  
  3853. This function has no return value and does not set errno. 
  3854.  
  3855. Example of _disable 
  3856.  
  3857. Related Information 
  3858.  
  3859. o _enable - Enable Interrupts 
  3860. o _interrupt - Call Interrupt  Procedure 
  3861.  
  3862.  
  3863. ΓòÉΓòÉΓòÉ 2.45. div  - Quotient and Remainder ΓòÉΓòÉΓòÉ
  3864.  
  3865. #include <stdlib.h>
  3866.  
  3867. div_t div(int numerator, int denominator);
  3868.  
  3869. Language Level: ANSI, SAA 
  3870.  
  3871. Description 
  3872.  
  3873. The div function calculates the quotient and remainder of the division of 
  3874. numerator by denominator. 
  3875.  
  3876. The div function returns a structure of type div_t, containing both the 
  3877. quotient int quot and the remainder int rem.  If the return value cannot be 
  3878. represented, its value is undefined. If denominator is 0, an exception will be 
  3879. raised. 
  3880.  
  3881. Example of div 
  3882.  
  3883. Related Information 
  3884.  
  3885. o ldiv  - Long Division 
  3886. o stdlib.h 
  3887.  
  3888.  
  3889. ΓòÉΓòÉΓòÉ 2.45.1. _dump_allocated - Get Information about Allocated Storage ΓòÉΓòÉΓòÉ
  3890.  
  3891. #define __DEBUG_ALLOC__
  3892. #include <stdlib.h>
  3893.  
  3894. void *_dump_allocated(int nbytes);
  3895.  
  3896. Description 
  3897.  
  3898. The _dump_allocated function prints out information about each memory block 
  3899. that is currently allocated if it was allocated by the debug versions of the 
  3900. memory management functions. The nbytes argument specifies how many bytes of 
  3901. each memory block are to be printed. 
  3902.  
  3903. If nbytes is a negative value, all the bytes of each memory block are printed. 
  3904. If nbytes is 0, no bytes are printed.  If nbytes is a positive value, the 
  3905. number of bytes printed for each block will be the minimum of the requested 
  3906. size and the block size. 
  3907.  
  3908. Language Level Extension, Migration (in <malloc.h>) 
  3909.  
  3910. Example of _dump_allocated 
  3911.  
  3912. Related Information 
  3913.  
  3914. o _debug_calloc - Reserve and Initialize Storage 
  3915. o _debug_free - Release Storage Blocks 
  3916. o _debug_malloc - Reserve Storage Blocks 
  3917. o _debug_realloc - Change Reserved Storage Block Size 
  3918. o _heap_check - Validate Run-Time Storage Heap 
  3919. o Using the Debug Memory Management Functions 
  3920. o malloc.h 
  3921. o stdlib.h 
  3922.  
  3923.  
  3924. ΓòÉΓòÉΓòÉ 2.46. _dup - Second Handle with Open File ΓòÉΓòÉΓòÉ
  3925.  
  3926. #include <io.h>
  3927.  
  3928. int _dup(int handle);
  3929.  
  3930. Language Level: Extension 
  3931.  
  3932. Description 
  3933.  
  3934. The _dup function associates a second file handle with a currently open file. 
  3935. You can carry out operations on the file using either file handle because all 
  3936. handles associated with a given file use the same file pointer. Creation of a 
  3937. new handle does not affect the type of access allowed for the file. 
  3938.  
  3939. For: 
  3940.  
  3941.    handle2 = _dup(handle1)
  3942. handle2 will have the same file access mode (text or binary) as handle1.  In 
  3943. addition, if handle1 was originally opened with the O_APPEND flag (see _open - 
  3944. Open File), handle2 will also have that attribute. 
  3945.  
  3946. Warning: Even though you have a duplicate file handle, both handles share a 
  3947. single file pointer. Therefore, if you reposition a file using handle1, the 
  3948. position in the file returned by handle2 will also change. 
  3949.  
  3950. If you duplicate a file handle for an open stream, the resulting file handle 
  3951. has the same restrictions as the original file handle. 
  3952.  
  3953. The _dup function returns the next available file handle for the given file. 
  3954. The _dup2 function forces the given handle, handle2, to refer to the same file 
  3955. as handle1. If handle2 is associated with an open file at the time of the call, 
  3956. that file is closed. The _dup function returns a new file handle. The _dup2 
  3957. function returns 0 to indicate success. Both functions return -1 if an error 
  3958. occurs and set errno to one of the following values: 
  3959.  
  3960. Value          Meaning 
  3961. EBADF          The file handle is not valid. 
  3962. EMFILE         No more file handles are available. 
  3963. EOS2ERR        The call to the operating system was not successful. 
  3964.  
  3965. Example of _dup - _dup2 
  3966.  
  3967. Related Information 
  3968.  
  3969. o _close - Closes File Associated with Handle 
  3970. o _creat - Create New File 
  3971. o _open - Open File 
  3972. o _sopen - Open Shared File 
  3973. o io.h 
  3974.  
  3975.  
  3976. ΓòÉΓòÉΓòÉ 2.47. _dup2 - Second Handle with Open File ΓòÉΓòÉΓòÉ
  3977.  
  3978. #include <io.h>
  3979.  
  3980. int _dup(int handle);
  3981.  
  3982. Language Level: Extension 
  3983.  
  3984. Description 
  3985.  
  3986. The _dup2 function associates a second file handle with a currently open file. 
  3987. You can carry out operations on the file using either file handle because all 
  3988. handles associated with a given file use the same file pointer. 
  3989.  
  3990. The handle handle2 will point to the same file as handle1, but will retain the 
  3991. file access mode (text or binary) that it had before duplication.  In addition, 
  3992. if handle2 was originally opened with the O_APPEND flag, it will also retain 
  3993. that attribute. 
  3994.  
  3995. Warning: Even though you have a duplicate file handle, both handles share a 
  3996. single file position.  Therefore, if you reposition a file using handle1, the 
  3997. position in the file returned by handle2 will also change. 
  3998.  
  3999. If you duplicate a file handle for an open stream (using fileno), the resulting 
  4000. file handle has the same restrictions as the original file handle. 
  4001.  
  4002. The _dup2 function forces the given handle, handle2, to refer to the same file 
  4003. as handle1. If handle2 is associated with an open file at the time of the call, 
  4004. that file is closed. The _dup2 function returns 0 to indicate success. It 
  4005. returns -1 if an error occurs and sets errno to one of the following values: 
  4006.  
  4007. Value          Meaning 
  4008. EBADF          The file handle is not valid. 
  4009. EMFILE         No more file handles are available. 
  4010. EOS2ERR        The call to the operating system was not successful. 
  4011.  
  4012. Example of _dup - _ 
  4013.  
  4014. Related Information 
  4015.  
  4016. o _close - Closes File Associated with Handle 
  4017. o _creat - Create New File 
  4018. o _open - Open File 
  4019. o _sopen - Open Shared File 
  4020. o io.h 
  4021.  
  4022.  
  4023. ΓòÉΓòÉΓòÉ 2.48. _ecvt - Convert Floating-Point to                 Character ΓòÉΓòÉΓòÉ
  4024.  
  4025. #include <stdlib.h>
  4026.  
  4027. char *_ecvt(double value, int ndigits, int *decptr, int *signptr);
  4028.  
  4029. Language Level: Extension 
  4030.  
  4031. Description 
  4032.  
  4033. The _ecvt function converts a floating-point number to a character string. The 
  4034. variable value is the floating-point number to be converted. The _ecvt function 
  4035. stores ndigits digits of value as a string and adds a null character (\0). If 
  4036. the number of digits in value exceeds ndigits, the low-order digit is rounded. 
  4037. If there are fewer than ndigits digits, the string is padded with zeros. 
  4038.  
  4039. Only digits are stored in the string. You can obtain the position of the 
  4040. decimal point and the sign of value after the call from decptr and signptr. The 
  4041. variable decptr points to an integer value that gives the position of the 
  4042. decimal point with respect to the beginning of the string. A 0 or a negative 
  4043. integer value indicates that the decimal point lies to the left of the first 
  4044. digit. The variable signptr points to an integer that indicates the sign of the 
  4045. converted number. If the integer value is 0, the number is positive. If it is 
  4046. not 0, the number is negative. 
  4047.  
  4048. The _ecvt function also converts NaN and infinity values to the strings NAN and 
  4049. INFINITY, respectively. For more information on NaN and infinity values, see 
  4050. Infinity and NaN Support. 
  4051.  
  4052. Warning: For each thread, the _ecvt, _fcvt and _gcvt functions use a single, 
  4053. dynamically allocated buffer for the conversion. Any subsequent call that the 
  4054. same thread makes to these functions destroys the result of the previous call. 
  4055.  
  4056. The _ecvt function returns a pointer to the string of digits. A failure to 
  4057. allocate memory results in a NULL return value, and errno is set to ENOMEM. 
  4058. Because of the limited precision of the double type, no more than 16 decimal 
  4059. digits are significant in any conversion. 
  4060.  
  4061. Example of _ecvt 
  4062.  
  4063. Related Information 
  4064.  
  4065. o atof  - Convert Character Strings 
  4066. o atoi  - Convert Character Strings 
  4067. o atol  - Convert Character Strings 
  4068. o _fcvt - Convert Floating-Point to         String 
  4069. o _gcvt - Convert Floating-Point to String 
  4070. o Infinity and NaN Support 
  4071. o stdlib.h 
  4072.  
  4073.  
  4074. ΓòÉΓòÉΓòÉ 2.49. _enable - Enable Interrupts ΓòÉΓòÉΓòÉ
  4075.  
  4076. #include <builtin.h>
  4077.  
  4078. void _enable( void );
  4079.  
  4080. Language Level: Extension 
  4081.  
  4082. Description 
  4083.  
  4084. The _enable function enables interrupts by executing the STI machine 
  4085. instruction.  Interrupts are enabled after the instruction following STI has 
  4086. executed.  If interrupts are disabled and you call _enable followed immediately 
  4087. by _disable then interrupts will remain disabled. 
  4088.  
  4089. Because it is a built-in function and has no backing code in the library: 
  4090.  
  4091. o You cannot take the address of _enable. 
  4092. o You cannot parenthesize an _enable function call because parentheses specify 
  4093.   a call to the backing code for the function in the library. 
  4094.  
  4095. You can run code containing this function only at ring zero. Otherwise, an 
  4096. invalid instruction exception will be received. 
  4097.  
  4098. This function has no return value and does not set errno. 
  4099.  
  4100. Example of _enable 
  4101.  
  4102. Related Information 
  4103.  
  4104. o _disable - Disable Interrupts 
  4105. o _interrupt - Call Interrupt  Procedure 
  4106.  
  4107.  
  4108. ΓòÉΓòÉΓòÉ 2.50. _eof - Determine End of File ΓòÉΓòÉΓòÉ
  4109.  
  4110. #include <io.h>
  4111.  
  4112. int _eof (int handle);
  4113.  
  4114. Language Level: Extension 
  4115.  
  4116. Description 
  4117.  
  4118. The _eof function determines whether the file pointer has reached the 
  4119. end-of-file for the file associated with handle. You cannot use _eof on a 
  4120. nonseekable file; it will fail. 
  4121.  
  4122. The _eof function returns the value 1 if the current position is the end of the 
  4123. file or 0 if it is not. A return value of -1 shows an error, and the system 
  4124. sets errno to the following values: 
  4125.  
  4126. Value          Meaning 
  4127. EBADF          File handle is not valid. 
  4128. EOS2ERR        The call to the operating system was not successful. 
  4129.  
  4130. Example of _eof 
  4131.  
  4132. Related Information 
  4133.  
  4134. o _chsize - Alter Length of File 
  4135. o _creat - Create New File 
  4136. o _filelength - Determine File Length 
  4137. o _sopen - Open Shared File 
  4138. o _open - Open File 
  4139. o io.h 
  4140.  
  4141.  
  4142. ΓòÉΓòÉΓòÉ 2.51. _endthread - Terminate Current Thread ΓòÉΓòÉΓòÉ
  4143.  
  4144. #include <stdlib.h>    /* also defined in <process.h> */
  4145.  
  4146. void _endthread(void);
  4147.  
  4148. Language Level: Extension 
  4149.  
  4150. Description 
  4151.  
  4152. The _endthread function explicitly ends a thread that you previously created 
  4153. with _beginthread before the thread has completed its function. For example, if 
  4154. some condition is not met, _endthread terminates the thread. When the thread 
  4155. has finished, it automatically ends itself with an implicit call to _endthread. 
  4156.  
  4157. Note:  When using the _beginthread and _endthread functions, you must specify 
  4158. the /Gm+ compiler option to use the multithread libraries. 
  4159.  
  4160. Note:  If you used DosCreateThread to create the thread, you must use DosExit, 
  4161. rather than _endthread, to terminate the thread. 
  4162.  
  4163. There is no return value. 
  4164.  
  4165. Example of _endthread 
  4166.  
  4167. Related Information 
  4168.  
  4169. o _beginthread - Create New Thread 
  4170. o /Gm+ option 
  4171. o stdlib.h 
  4172. o process.h 
  4173.  
  4174.  
  4175. ΓòÉΓòÉΓòÉ 2.52. erf - erfc  - Error Functions ΓòÉΓòÉΓòÉ
  4176.  
  4177. #include <math.h> /* SAA extensions to ANSI */
  4178.  
  4179. double erf(double x);
  4180.  
  4181. double erfc(double x);
  4182.  
  4183. Language Level: SAA 
  4184.  
  4185. Description 
  4186.  
  4187. The erf function computes the error function. The erfc function computes the 
  4188. value of 1.0 - erf(x);.  The erfc function is used in place of erf for large 
  4189. values of x. 
  4190.  
  4191. Example of erf - erfc 
  4192.  
  4193. Related Information 
  4194.  
  4195. o Bessel Functions 
  4196. o gamma  - Gamma Function 
  4197. o math.h 
  4198.  
  4199.  
  4200. ΓòÉΓòÉΓòÉ 2.53. _execl - _execvp - Load and Run Child Process ΓòÉΓòÉΓòÉ
  4201.  
  4202. #include <process.h>
  4203.  
  4204. int _execl(char *pathname, char *arg0, char *arg1,..., char *argn, NULL);
  4205.  
  4206. int _execle(char *pathname, char *arg0, char *arg1,..., char *argn,
  4207.                                                   NULL char *envp[ ]);
  4208.  
  4209. int _execlp(char *pathname, char *arg0, char *arg1,..., char *argn, NULL);
  4210.  
  4211. int _execlpe(char *pathname, char *arg0, char *arg1,..., char *argn,
  4212.                                                   NULL char *envp[ ]);
  4213.  
  4214. int _execv(char *pathname, char *argv[ ]);
  4215.  
  4216. int _execve(char *pathname, char *argv[ ],char *envp[ ]);
  4217.  
  4218. int _execvp(char *pathname, char *argv[ ]);
  4219.  
  4220. int _execvpe(char *pathname, char *argv[ ], char *envp[ ]);
  4221.  
  4222. Language Level: Extension 
  4223.  
  4224. Description 
  4225.  
  4226. The _exec functions load and run new child processes. The parent process is 
  4227. ended after the child process has started.  Sufficient storage must be 
  4228. available for loading and running the child process. 
  4229.  
  4230. All of the _exec functions are versions of the same routine;  the letters at 
  4231. the end determine the specific variation: 
  4232.  
  4233. Letter    Variation 
  4234.  p        Uses PATH environment variable to find the file to be run 
  4235.  l        Passes a list of command line arguments separately 
  4236.  v        Passes to the child process an array of pointers to command-line 
  4237.           arguments 
  4238.  e        Passes to the child process an array of pointers to environment 
  4239.           strings. 
  4240.  
  4241. The pathname argument specifies the file to run as the child process.  The 
  4242. pathname can specify a full path from the root, a partial path from the current 
  4243. working directory, or a file name.  If pathname does not have a file name 
  4244. extension or does not end with a period, the _exec functions will add the .EXE 
  4245. extension and search for the file.  If pathname has an extension, the _exec 
  4246. function uses only that extension. If pathname ends with a period, the _exec 
  4247. functions search for pathname with no extension.  The _execlp, _execlpe, 
  4248. _execvp, and _execvpe functions search for the pathname in the directories that 
  4249. the PATH environment variable specifies. 
  4250.  
  4251. You pass arguments to the new process by giving one or more pointers to 
  4252. character strings as arguments in the _exec call.  These character strings form 
  4253. the argument list for the child process. 
  4254.  
  4255. The compiler can pass the argument pointers as separate arguments (_execl, 
  4256. _execle, _execlp, and _execlpe) or as an array of pointers (_execv, _execve, 
  4257. _execvp, and _execvpe).  You should pass at least one argument, either arg0 or 
  4258. argv[0], to the child process. If you do not, an argument will be returned that 
  4259. points to the same file as the path name argument you specified. This argument 
  4260. may not be exactly identical to the path name argument you specified.  A 
  4261. different value does not produce an error. 
  4262.  
  4263. Use the _execl, _execle, _execlp, and _execlpe functions for the cases where 
  4264. you know the number of arguments in advance.  The arg0 argument is usually a 
  4265. pointer to pathname. The arg1 through argn arguments are pointers to the 
  4266. character strings forming the new argument list.  There must be a NULL pointer 
  4267. following argn to mark the end of the argument list. 
  4268.  
  4269. Use the _execv, _execve, _execvp, and _execvpe functions when the number of 
  4270. arguments to the new process is variable.  Pass pointers to the arguments of 
  4271. these functions as an array, argv[ ]. The argv[0] argument is usually a pointer 
  4272. to pathname. The argv[1] through argv[n] arguments are pointers to the 
  4273. character strings forming the new argument list.  If argv[n] is the last 
  4274. parameter, then argv[n+1] must be NULL. 
  4275.  
  4276. Files that are open when you make an _exec call remain open in the new process. 
  4277. In the _execl, _execlp, _execv, and _execvp calls, the child process receives 
  4278. the environment of the parent.  The _execle, _execlpe, _execve, and _execvpe 
  4279. functions let you change the environment for the child process by passing a 
  4280. list of environment settings through the envp argument.  The envp argument is 
  4281. an array of character pointers, each element of which points to a string ending 
  4282. with a null character that defines an environment variable.  Such a string 
  4283. usually has the following form: 
  4284.  
  4285.    NAME=value
  4286.  
  4287. where NAME is the name of an environment variable, and value is the string 
  4288. value to which the _exec function sets that variable. 
  4289.  
  4290. Note:  Do not enclose the value in double quotation marks. 
  4291.  
  4292. The final element of the envp array should be NULL.  When envp itself is NULL, 
  4293. the child process receives the environment settings of the parent process. 
  4294.  
  4295. The _exec functions do not preserve signal settings in child processes created 
  4296. by calls to _exec functions.  Calls to _exec functions reset the signal 
  4297. settings to the default in the child process. 
  4298.  
  4299. An alternative to this function is the DosExecPgm API call. 
  4300.  
  4301. The _exec functions do not normally return control to the calling process. 
  4302. They are equivalent to the corresponding spawn functions with P_OVERLAY as the 
  4303. value of modeflag.  If an _exec function returns, an error has occurred, and 
  4304. the return value is -1.  The errno variable then has one of the following 
  4305. values: 
  4306.  
  4307. Value          Meaning 
  4308. EACCESS        The specified file has a locking or sharing violation. 
  4309. EMFILE         There are too many open files.  The system must open the 
  4310.                specified file to tell whether it is an executable file. 
  4311. ENOENT         The file or pathname was not found or was specified incorrectly. 
  4312. ENOEXEC        The specified file cannot run or has an incorrect executable 
  4313.                file format. 
  4314. ENOMEM         One of the following conditions exists: 
  4315.  
  4316.    o Not enough storage is available to run the child process. 
  4317.    o Not enough storage is available for the argument or environment strings. 
  4318.  
  4319. Example of _execl - execvp 
  4320.  
  4321. Related Information 
  4322.  
  4323. o abort  - Stop a Program 
  4324. o _cwait - Wait for Child Process 
  4325. o exit  - End Program 
  4326. o _exit - End Process 
  4327. o _spawnl - _spawnvpe - Start and Run Child Processes 
  4328. o system - Invoke the Command Processor 
  4329. o _wait - Wait for Child Process 
  4330. o envp Parameter to main 
  4331. o process.h 
  4332.  
  4333.  
  4334. ΓòÉΓòÉΓòÉ 2.54. exit  - End Program ΓòÉΓòÉΓòÉ
  4335.  
  4336. #include <stdlib.h>
  4337.  
  4338. void exit(int status);
  4339.  
  4340. Language Level: ANSI, SAA, Extension 
  4341.  
  4342. Description 
  4343.  
  4344. The exit function returns control to the host environment from the program.  It 
  4345. first calls all functions registered with the atexit function, in reverse 
  4346. order;  that is, the last one registered is the first one called. It flushes 
  4347. all buffers and closes all open files before ending the program. 
  4348.  
  4349. The argument status can have a value from 0 to 255 inclusive or be one of the 
  4350. macros EXIT_SUCCESS or EXIT_FAILURE.  A status value of EXIT_SUCCESS or 0 
  4351. indicates a normal exit; otherwise another status value is returned. 
  4352.  
  4353. All files opened with tmpfile are deleted.  Both control and the value of 
  4354. status are returned to the operating system. 
  4355.  
  4356. Example of exit 
  4357.  
  4358. Related Information 
  4359.  
  4360. o abort  - Stop a Program 
  4361. o atexit  - Record Program Termination Function 
  4362. o _exit - End Process 
  4363. o signal - Install Interrupt Handlers 
  4364. o stdlib.h 
  4365. o tmpfile  - Create Temporary File 
  4366.  
  4367.  
  4368. ΓòÉΓòÉΓòÉ 2.55. _exit - End Process ΓòÉΓòÉΓòÉ
  4369.  
  4370. #include <stdlib.h>      /* Declared in both   */
  4371. #include <process.h>
  4372.  
  4373. void _exit(int status);
  4374.  
  4375. Language Level: Extension 
  4376.  
  4377. Description 
  4378.  
  4379. The _exit function ends the calling process without calling functions 
  4380. registered by _onexit or atexit. It also does not flush stream buffers or 
  4381. delete temporary files. You supply the status value as a parameter;  the value 
  4382. 0 typically means a normal exit. 
  4383.  
  4384. Although _exit does not return a value, the value is available to the waiting 
  4385. parent process, if there is one, after the child process ends.  If no parent 
  4386. process waits for the exiting process, the status value is lost.  The status 
  4387. value is available through the operating system batch command IF ERRORLEVEL. 
  4388.  
  4389. Example of _exit 
  4390.  
  4391. Related Information 
  4392.  
  4393. o abort  - Stop a Program 
  4394. o atexit  - Record Program Termination Function 
  4395. o _execl - _execvp - Load and Run Child Process 
  4396. o exit  - End Program 
  4397. o _onexit - Record Termination Function 
  4398. o process.h 
  4399. o stdlib.h 
  4400.  
  4401.  
  4402. ΓòÉΓòÉΓòÉ 2.56. exp  - Exponential Function ΓòÉΓòÉΓòÉ
  4403.  
  4404. #include <math.h>
  4405.  
  4406. double exp(double x);
  4407.  
  4408. Language Level: ANSI, SAA 
  4409.  
  4410. Description 
  4411.  
  4412. The exp function returns the exponential function of a floating-point argument 
  4413. x (e**x, where e equals 2.17128128...). 
  4414.  
  4415. If an overflow occurs, the function returns HUGE_VAL; when an underflow occurs, 
  4416. it returns 0.  Overflow or underflow sets errno to ERANGE. 
  4417.  
  4418. Example of exp 
  4419.  
  4420. Related Information 
  4421.  
  4422. o log  - Calculate Natural Logarithm 
  4423. o log10  - Calculate Base 10 Logarithm 
  4424. o math.h 
  4425.  
  4426.  
  4427. ΓòÉΓòÉΓòÉ 2.57. fabs  - Floating-Point Absolute Value ΓòÉΓòÉΓòÉ
  4428.  
  4429. #include <math.h>
  4430.  
  4431. double fabs(double x);
  4432.  
  4433. Language Level: ANSI, SAA 
  4434.  
  4435. Description 
  4436.  
  4437. The fabs function returns the absolute value of a floating-point argument. 
  4438.  
  4439. There is no error return value. 
  4440.  
  4441. Example of fabs 
  4442.  
  4443. Related Information 
  4444.  
  4445. o abs  - Integer Absolute Value 
  4446. o cabs - Absolute Value of Complex Number 
  4447. o labs  - long Absolute Value 
  4448. o math.h 
  4449.  
  4450.  
  4451. ΓòÉΓòÉΓòÉ 2.58. _facos - Calculate Arccosine ΓòÉΓòÉΓòÉ
  4452.  
  4453. #include <builtin.h>
  4454.  
  4455. double _facos(double x);
  4456.  
  4457. Language Level: Extension 
  4458.  
  4459. Description 
  4460.  
  4461. The _facos function calculates the arccosine of x. This function causes the 
  4462. compiler to emit the appropriate 80387 instructions for the calculation of 
  4463. arccosines. 
  4464.  
  4465. Because it is a built-in function and has no backing code in the library: 
  4466.  
  4467. o You cannot take the address of _facos. 
  4468. o You cannot parenthesize a _facos function call, because parentheses specify a 
  4469.   call to the backing code for the function in the library. 
  4470.  
  4471. This function returns the arccosine of a variable x. 
  4472.  
  4473. Example of _facos 
  4474.  
  4475. Related Information 
  4476.  
  4477. o acos - Arc Cosine 
  4478. o cos  - Cosine 
  4479. o _fcos - Calculate Cosine 
  4480.  
  4481.  
  4482. ΓòÉΓòÉΓòÉ 2.59. _fasin - Calculate Arcsine ΓòÉΓòÉΓòÉ
  4483.  
  4484. #include <builtin.h>
  4485.  
  4486. double _fasin(double x);
  4487.  
  4488. Language Level: Extension 
  4489.  
  4490. Description 
  4491.  
  4492. The _fasin function calculates the arcsine of x. This function causes the 
  4493. compiler to emit the appropriate 80387 instructions for the calculation of 
  4494. arcsines. 
  4495.  
  4496. Because it is a built-in function and has no backing code in the library: 
  4497.  
  4498. o You cannot take the address of _fasin. 
  4499. o You cannot parenthesize a _fasin function call, because parentheses specify a 
  4500.   call to the backing code for the function in the library. 
  4501.  
  4502. This function returns the arcsine of a variable x. 
  4503.  
  4504. Example of _fasin 
  4505.  
  4506. Related Information 
  4507.  
  4508. o asin  - Arc Sine 
  4509. o sin  - Sine 
  4510. o _fsin - Calculate Sine 
  4511.  
  4512.  
  4513. ΓòÉΓòÉΓòÉ 2.60. fclose  - Close Stream ΓòÉΓòÉΓòÉ
  4514.  
  4515. #include <stdio.h>
  4516.  
  4517. int fclose(FILE *stream);
  4518.  
  4519. Language Level: ANSI, SAA 
  4520.  
  4521. Description 
  4522.  
  4523. The fclose function closes a stream pointed to by stream.  This function 
  4524. flushes all buffers associated with the stream before closing it.  When it 
  4525. closes the stream, the function releases any buffers that the system reserved. 
  4526.  
  4527. The fclose function returns 0 if it successfully closes the stream, or EOF if 
  4528. any errors were detected. 
  4529.  
  4530. Note:  Once a stream has been closed with fclose, it must be opened again 
  4531. before it can be used. 
  4532.  
  4533. Example of fclose 
  4534.  
  4535. Related Information 
  4536.  
  4537. o _fcloseall - Close All Open Streams 
  4538. o fflush  - Write Buffer to File 
  4539. o fopen  - Open Files 
  4540. o freopen  - Redirect Open Files 
  4541. o stdio.h 
  4542.  
  4543.  
  4544. ΓòÉΓòÉΓòÉ 2.61. _fcloseall - Close All Open Streams ΓòÉΓòÉΓòÉ
  4545.  
  4546. #include <stdio.h>
  4547.  
  4548. int _fcloseall(void);
  4549.  
  4550. Language Level: Extension 
  4551.  
  4552. Description 
  4553.  
  4554. The _fcloseall function closes all open streams, except stdin, stdout, and 
  4555. stderr. It also closes and deletes any temporary files created by tmpfile. 
  4556.  
  4557. The function flushes all buffers associated with the streams before closing 
  4558. them. When it closes streams, it releases the buffers that the system reserved, 
  4559. but does not release user-allocated buffers. 
  4560.  
  4561. The _fcloseall function returns the total number of streams closed, or EOF if 
  4562. an error occurs. 
  4563.  
  4564. Example of _fcloseall 
  4565.  
  4566. Related Information 
  4567.  
  4568. o fclose  - Close Stream 
  4569. o fflush  - Write Buffer to File 
  4570. o fopen  - Open Files 
  4571. o freopen  - Redirect Open Files 
  4572. o tmpfile  - Create Temporary File 
  4573. o stdio.h 
  4574.  
  4575.  
  4576. ΓòÉΓòÉΓòÉ 2.62. _fcos - Calculate Cosine ΓòÉΓòÉΓòÉ
  4577.  
  4578. #include <builtin.h>
  4579.  
  4580. double _fcos( double x);
  4581.  
  4582. Language Level: Extension 
  4583.  
  4584. Description 
  4585.  
  4586. The _fcos function calculates the cosine of x, where x is expressed in radians. 
  4587. The value of x must be less than 2**63. This function causes the compiler to 
  4588. emit the FSINCOS 80387 instruction and return only the cosine. 
  4589.  
  4590. Because it is a built-in function and has no backing code in the library: 
  4591.  
  4592. o You cannot take the address of _fcos. 
  4593. o You cannot parenthesize a _fcos function call, because parentheses specify a 
  4594.   call to the backing code for the function in the library. 
  4595.  
  4596. This function returns the cosine of a variable x expressed in radians. 
  4597.  
  4598. Example of _fcos 
  4599.  
  4600. Related Information 
  4601.  
  4602. o cos  - Cosine 
  4603. o _fsincos - Calculate Sine and Cosine 
  4604.  
  4605.  
  4606. ΓòÉΓòÉΓòÉ 2.63. _fcossin - Calculate Cosine and Sine ΓòÉΓòÉΓòÉ
  4607.  
  4608. #include <builtin.h>
  4609.  
  4610. double _fcossin(double x, double *y);
  4611.  
  4612. Language Level: Extension 
  4613.  
  4614. Description 
  4615.  
  4616. The _fcossin function calculates the cosine of x, and stores the sine of x in 
  4617. *y. This is faster than separately calculating the sine and cosine. Use this 
  4618. function instead of _fsincos when you will be using the cosine first, and then 
  4619. the sine. This function causes the compiler to emit the FSINCOS 80387 
  4620. instruction. 
  4621.  
  4622. Because it is a built-in function and has no backing code in the library: 
  4623.  
  4624. o You cannot take the address of _fcossin. 
  4625. o You cannot parenthesize a _fcossin function call, because parentheses specify 
  4626.   a call to the backing code for the function in the library. 
  4627.  
  4628. This function returns the cosine of a variable x. 
  4629.  
  4630. Example of _fcossin 
  4631.  
  4632. Related Information 
  4633.  
  4634. o asin  - Arc Sine 
  4635. o sin  - Sine 
  4636. o _fsin - Calculate Sine 
  4637. o _fsincos - Calculate Sine and Cosine 
  4638.  
  4639.  
  4640. ΓòÉΓòÉΓòÉ 2.64. _fcvt - Convert Floating-Point to                 String ΓòÉΓòÉΓòÉ
  4641.  
  4642. Language Level: Extension 
  4643.  
  4644. #include <stdlib.h>
  4645.  
  4646. char *_fcvt(double value, int ndec, int *decptr, int *signptr);
  4647.  
  4648. Description 
  4649.  
  4650. The _fcvt function converts a floating-point number to a character string. The 
  4651. variable value is the floating-point number to be converted. The _fcvt function 
  4652. stores the digits of value as a string and adds a null character (\0). The ndec 
  4653. variable specifies the number of digits to be stored after the decimal point. 
  4654.  
  4655. If the number of digits after the decimal point in value exceeds ndec, _fcvt 
  4656. rounds the correct digit according to the FORTRAN F format.  If there are fewer 
  4657. than ndec digits of precision, _fcvt pads the string with zeros. 
  4658.  
  4659. A FORTRAN F number has the following format: 
  4660.  
  4661.              ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ       ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  4662.  ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitΓöÇΓö┤ΓöÇΓöÇΓöÇ.ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4663.      Γö£ΓöÇΓöÇ+ΓöÇΓöÇΓöñ                  ΓööΓöÇdigitΓöÇΓöÿ
  4664.      ΓööΓöÇΓöÇ-ΓöÇΓöÇΓöÿ
  4665.  
  4666. The _fcvt function stores only digits in the string. You can obtain the 
  4667. position of the decimal point and the sign of value after the call from decptr 
  4668. and signptr. The decptr variable points to an integer value giving the position 
  4669. of the decimal point with respect to the beginning of the string.  A 0 or 
  4670. negative integer value shows that the decimal point lies to the left of the 
  4671. first digit. The signptr variable points to an integer showing the sign of 
  4672. value. The _fcvt function sets the integer to 0 if value is positive and to a 
  4673. nonzero number if value is negative. 
  4674.  
  4675. The _fcvt function also converts NaN and infinity values to the strings NAN and 
  4676. INFINITY, respectively. For more information on NaN and infinity values, see 
  4677. Infinity and NaN Support. 
  4678.  
  4679. Warning: For each thread, the _ecvt, _fcvt, and _gcvt functions use a single, 
  4680. dynamically allocated buffer for the conversion. Any subsequent call that the 
  4681. same thread makes to these functions destroys the result of the previous call. 
  4682.  
  4683. The _fcvt function returns a pointer to the string of digits. A failure to 
  4684. allocate memory results in a NULL return value and sets errno to ENOMEM. 
  4685. Because of the limited precision of the double type, no more than 16 decimal 
  4686. digits are significant in any conversion. 
  4687.  
  4688. Example of _fcvt 
  4689.  
  4690. Related Information 
  4691.  
  4692. o atof  - Convert Character Strings 
  4693. o atoi  - Convert Character Strings 
  4694. o atol  - Convert Character Strings 
  4695. o _ecvt - Convert Floating-Point to         Character 
  4696. o _gcvt - Convert Floating-Point to String 
  4697. o Infinity and NaN Support 
  4698. o stdlib.h 
  4699.  
  4700.  
  4701. ΓòÉΓòÉΓòÉ 2.65. _fdopen - Associates Input Or Output With File ΓòÉΓòÉΓòÉ
  4702.  
  4703. #include <stdio.h>
  4704.  
  4705. FILE *_fdopen(int handle, char *type);
  4706.  
  4707. Language Level: Extension 
  4708.  
  4709. Description 
  4710.  
  4711. The _fdopen function associates an input or output stream with the file 
  4712. identified by handle. The type variable is a character string specifying the 
  4713. type of access requested for the stream. 
  4714.  
  4715. Mode Description 
  4716.      Create a stream to read a text file. The file pointer is set to the 
  4717.      beginning of the file. 
  4718.      Create a stream to write to a text file. The file pointer is set to the 
  4719.      beginning of the file. 
  4720.      Create a stream to write, in append mode, at the end of the text file. The 
  4721.      file pointer is set to the end of the file. 
  4722. r+ 
  4723.      Create a stream for reading and writing a text file. The file pointer is 
  4724.      set to the beginning of the file. 
  4725. w+ 
  4726.      Create a stream for reading and writing a text file. The file pointer is 
  4727.      set to the beginning of the file. 
  4728. a+ 
  4729.      Create a stream for reading or writing, in append mode, at the end of the 
  4730.      text file. The file pointer is set to the end of the file. 
  4731. rb 
  4732.      Create a stream to read a binary file. The file pointer is set to the 
  4733.      beginning of the file. 
  4734. wb 
  4735.      Create a stream to write to a binary file. The file pointer is set to the 
  4736.      beginning of the file. 
  4737. ab 
  4738.      Create a stream to write to a binary file in append mode. The file pointer 
  4739.      is set to the end of the file. 
  4740. r+b or rb+ 
  4741.      Create a stream for reading and writing a binary file. The file pointer is 
  4742.      set to the beginning of the file. 
  4743. w+b or wb+ 
  4744.      As above. 
  4745. a+b or ab+ 
  4746.      Create a stream for reading and writing to a binary file in append mode. 
  4747.      The file pointer is set to the end of the file. 
  4748.  
  4749. Warning: Use thew, w+, wb, wb+, and w+b modes with care; they can destroy 
  4750. existing files. 
  4751.  
  4752. The specified type must be compatible with the access mode you used to open the 
  4753. file. 
  4754.  
  4755. If the file was opened with the O_APPEND FLAG, the stream mode must be r, a, 
  4756. a+, rb, ab, a+b, and ab+. 
  4757.  
  4758. When you open a file with a, a+, ab, a+b, or ab+ as the value of type, all 
  4759. write operations take place at the end of the file. Although you can reposition 
  4760. the file pointer using fseek or rewind, the file pointer always moves back to 
  4761. the end of the file before the system carries out any write operation. This 
  4762. action prevents you from writing over existing data. 
  4763.  
  4764. When you specify any of the types containing +, you can read from and write to 
  4765. the file. The file is said to be open for update. However, when switching from 
  4766. reading to writing or from writing to reading, you must include an intervening 
  4767. fseek, fsetpos, or rewind operation. You can specify the current file position 
  4768. with fseek. 
  4769.  
  4770. In accessing text files, carriage-return line-feed (CR-LF) combinations are 
  4771. translated into a single line feed (LF) on input; LF characters are translated 
  4772. to CR-LF combinations on output. Accesses to binary files suppress all of these 
  4773. translations. ( See IBM Giverny Programming Guide for differences between text 
  4774. and binary streams.) 
  4775.  
  4776. If _fdopen returns null, use the _close function to close the file. If _fdopen 
  4777. is successful, you must use fclose to close the stream and file. 
  4778.  
  4779. Example of _fdopen 
  4780.  
  4781. Related Information 
  4782.  
  4783. o _creat - Create New File 
  4784. o fclose  - Close Stream 
  4785. o fopen  - Open Files 
  4786. o fseek  - Reposition File Position 
  4787. o fsetpos  - Set File Position 
  4788. o _open - Open File 
  4789. o rewind  - Adjust Current File Position 
  4790. o _sopen - Open Shared File 
  4791. o stdio.h 
  4792.  
  4793.  
  4794. ΓòÉΓòÉΓòÉ 2.66. feof  - Test End-of-File Indicator ΓòÉΓòÉΓòÉ
  4795.  
  4796. #include <stdio.h>
  4797.  
  4798. int feof(FILE *stream);
  4799.  
  4800. Language Level: ANSI, SAA 
  4801.  
  4802. Description 
  4803.  
  4804. The feof function tells whether the end-of-file flag is set for the given 
  4805. stream.  The end-of-file flag is set by several functions to indicate the end 
  4806. of the file.  The end-of-file flag is cleared by calling rewind, fsetpos, 
  4807. fseek, or clearerr for this stream. 
  4808.  
  4809. The feof function returns a nonzero value if and only if the EOF flag is set; 
  4810. otherwise, zero (0) is returned. 
  4811.  
  4812. Example of feof 
  4813.  
  4814. Related Information 
  4815.  
  4816. o clearerr  - Reset Error Indicators 
  4817. o ferror  - Test for Read/Write Errors 
  4818. o fseek  - Reposition File Position 
  4819. o fsetpos  - Set File Position 
  4820. o perror  - Print Error Message 
  4821. o rewind  - Adjust Current File Position 
  4822. o stdio.h 
  4823.  
  4824.  
  4825. ΓòÉΓòÉΓòÉ 2.67. ferror  - Test for Read/Write Errors ΓòÉΓòÉΓòÉ
  4826.  
  4827. #include <stdio.h>
  4828.  
  4829. int ferror(FILE *stream);
  4830.  
  4831. Language Level: ANSI, SAA 
  4832.  
  4833. Description 
  4834.  
  4835. The ferror function tests for an error in reading from or writing to the given 
  4836. stream.  If an error occurs, the error indicator for the stream remains set 
  4837. until you close stream, call rewind, or call clearerr. 
  4838.  
  4839. The ferror function returns a nonzero value to indicate an error on the given 
  4840. stream.  A return value of 0 means no error has occurred. 
  4841.  
  4842. Note:  Some compilers are able to continue reading past EOF. Others require a 
  4843. call to another function such as clearerr in order to read beyond EOF. See the 
  4844. IBM Giverny Programming Guide for more information. 
  4845.  
  4846. Example of ferror 
  4847.  
  4848. Related Information 
  4849.  
  4850. o clearerr  - Reset Error Indicators 
  4851. o feof  - Test End-of-File Indicator 
  4852. o fopen  - Open Files 
  4853. o perror  - Print Error Message 
  4854. o stdio.h 
  4855.  
  4856.  
  4857. ΓòÉΓòÉΓòÉ 2.68. fflush  - Write Buffer to File ΓòÉΓòÉΓòÉ
  4858.  
  4859. #include <stdio.h>
  4860.  
  4861. int fflush(FILE *stream);
  4862.  
  4863. Language Level: ANSI, SAA 
  4864.  
  4865. Description 
  4866.  
  4867. The fflush function causes the system to empty the buffer associated with the 
  4868. specified output stream, if possible. If the stream is open for input, fflush 
  4869. undoes the effect of any ungetc function. The stream remains open after the 
  4870. call. 
  4871.  
  4872. If stream is NULL, the system flushes all open streams. 
  4873.  
  4874. The fflush function returns the value 0 if it successfully flushes the buffer. 
  4875. The fflush function returns EOF if an error occurs. 
  4876.  
  4877. Note:  The system automatically flushes buffers when you close the stream, or 
  4878.        when a program ends normally without closing the stream. 
  4879.  
  4880. Example of fflush 
  4881.  
  4882. Related Information 
  4883.  
  4884. o fclose  - Close Stream 
  4885. o _flushall - Write Buffers to Files 
  4886. o setbuf  - Control Buffering 
  4887. o ungetc  - Push Character onto Input Stream 
  4888. o stdio.h 
  4889.  
  4890.  
  4891. ΓòÉΓòÉΓòÉ 2.69. fgetc  - Read a Character ΓòÉΓòÉΓòÉ
  4892.  
  4893. #include <stdio.h>
  4894.  
  4895. int fgetc(FILE *stream);
  4896.  
  4897. Language Level: ANSI, SAA 
  4898.  
  4899. Description 
  4900.  
  4901. The fgetc function reads a single unsigned character from the input stream at 
  4902. the current position and increases the associated file pointer, if any, so that 
  4903. it points to the next character. 
  4904.  
  4905. The fgetc function returns the character read as an integer. An EOF return 
  4906. value indicates an error or an end-of-file condition.  Use feof or ferror to 
  4907. determine whether the EOF value indicates an error or the end of the file. 
  4908.  
  4909. The fgetc function is identical to getc but is guaranteed to be a function. 
  4910.  
  4911. Example of fgetc 
  4912.  
  4913. Related Information 
  4914.  
  4915. o _fgetchar - Read Single Character from stdin 
  4916. o feof  - Test End-of-File Indicator 
  4917. o ferror  - Test for Read/Write Errors 
  4918. o fputc  - Write a Character 
  4919. o getc - getchar  - Read a Character 
  4920. o _getch - _getche - Read Character from Keyboard 
  4921. o stdio.h 
  4922.  
  4923.  
  4924. ΓòÉΓòÉΓòÉ 2.70. _fgetchar - Read Single Character from stdin ΓòÉΓòÉΓòÉ
  4925.  
  4926. #include <stdio.h>
  4927.  
  4928. int _fgetchar(void);
  4929.  
  4930. Language Level: Extension 
  4931.  
  4932. Description 
  4933.  
  4934. The _fgetchar function reads a single character from the stdin stream. It is 
  4935. equivalent to a call to the SAA function fgetc: 
  4936.  
  4937.    fgetc(c, stdin);
  4938.  
  4939. For portability, replace _fgetchar with its SAA equivalent. 
  4940.  
  4941. The _fgetchar function returns the character read.  A return value of EOF 
  4942. indicates an error or end-of-file position. Use feof or ferror to tell whether 
  4943. the return value indicates an error or an end-of-file position. 
  4944.  
  4945. Example of _fgetchar 
  4946.  
  4947. Related Information 
  4948.  
  4949. o fgetc  - Read a Character 
  4950. o _fputchar - Write Character 
  4951. o getc - getchar  - Read a Character 
  4952. o _getch - _getche - Read Character from Keyboard 
  4953. o stdio.h 
  4954.  
  4955.  
  4956. ΓòÉΓòÉΓòÉ 2.71. fgetpos  - Get File Position ΓòÉΓòÉΓòÉ
  4957.  
  4958. #include <stdio.h>
  4959.  
  4960. int fgetpos(FILE *stream, fpos_t *pos);
  4961.  
  4962. Language Level: ANSI, SAA 
  4963.  
  4964. Description 
  4965.  
  4966. The fgetpos function stores the current position of the file pointer associated 
  4967. with stream into the object pointed to by pos.  The value pointed to by pos can 
  4968. be used later in a call to fsetpos to reposition the stream. 
  4969.  
  4970. If successful, the fgetpos function returns zero.  On error, fgetpos returns 
  4971. nonzero and sets errno to a nonzero value. 
  4972.  
  4973. Example of fgetpos 
  4974.  
  4975. Related Information 
  4976.  
  4977. o fseek  - Reposition File Position 
  4978. o fsetpos  - Set File Position 
  4979. o ftell  - Get Current Position 
  4980. o stdio.h 
  4981.  
  4982.  
  4983. ΓòÉΓòÉΓòÉ 2.72. fgets  - Read a String ΓòÉΓòÉΓòÉ
  4984.  
  4985. #include <stdio.h>
  4986.  
  4987. char *fgets (char *string, int n, FILE *stream);
  4988.  
  4989. Language Level: ANSI, SAA 
  4990.  
  4991. Description 
  4992.  
  4993. The fgets function reads characters from the current stream position up to and 
  4994. including the first new-line character (\n), up to the end of the stream, or 
  4995. until the number of characters read is equal to n-1, whichever comes first. 
  4996. The fgets function stores the result in string and adds a null character (\0) 
  4997. to the end of the string.  The string includes the new-line character, if read. 
  4998. If n is equal to 1, the string is empty. 
  4999.  
  5000. The fgets function returns a pointer to the string buffer if successful.  A 
  5001. NULL return value indicates an error or an end-of-file condition.  Use feof or 
  5002. ferror to determine whether the NULL value indicates an error or the end of the 
  5003. file. In either case, the value of the string is unchanged. 
  5004.  
  5005. Example of fgets 
  5006.  
  5007. Related Information 
  5008.  
  5009. o feof  - Test End-of-File Indicator 
  5010. o ferror  - Test for Read/Write Errors 
  5011. o fputs  - Print Strings 
  5012. o gets  - Read a Line 
  5013. o puts  - Write a String 
  5014. o stdio.h 
  5015.  
  5016.  
  5017. ΓòÉΓòÉΓòÉ 2.73. _filelength - Determine File Length ΓòÉΓòÉΓòÉ
  5018.  
  5019. #include <io.h>
  5020.  
  5021. long _filelength(int handle);
  5022.  
  5023. Language Level: Extension 
  5024.  
  5025. Description 
  5026.  
  5027. The _filelength function returns the length, in bytes, of the file associated 
  5028. with handle. The length of the file will be correct even if you have the handle 
  5029. opened and have appended data to the file. 
  5030.  
  5031. A return value of -1L indicates an error, and errno is set to one of the 
  5032. following values: 
  5033.  
  5034. Value          Meaning 
  5035. EBADF          Either the file handle is incorrect or the mode that you have 
  5036.                specified doesn't match the mode you opened the file with. 
  5037. EOS2ERR        The call to the operating system was not successful. 
  5038.  
  5039. Example of _filelength 
  5040.  
  5041. Related Information 
  5042.  
  5043. o _chsize - Alter Length of File 
  5044. o _eof - Determine End of File 
  5045. o io.h 
  5046.  
  5047.  
  5048. ΓòÉΓòÉΓòÉ 2.74. _fileno - File Handle ΓòÉΓòÉΓòÉ
  5049.  
  5050. #include <stdio.h>
  5051.  
  5052. int _fileno(FILE *stream);
  5053.  
  5054. Language Level: Extension 
  5055.  
  5056. Description 
  5057.  
  5058. The _fileno function determines the file handle currently associated with 
  5059. stream. 
  5060.  
  5061. The _fileno function returns the file handle. If the function fails, the return 
  5062. value is -1 and the errno variable may be set to one of the following values: 
  5063.  
  5064. Value          Meaning 
  5065. ENULLFCB       The input stream is NULL. 
  5066. EBADTYPE       The input stream file is not a stream file. 
  5067.  
  5068. The result is undefined if stream does not specify an open file. 
  5069.  
  5070. Example of _fileno 
  5071.  
  5072. Related Information 
  5073.  
  5074. o _dup - Second Handle with Open File 
  5075. o fopen  - Open Files 
  5076. o freopen  - Redirect Open Files 
  5077. o _isatty - Test Handle for Character Device 
  5078. o stdio.h 
  5079.  
  5080.  
  5081. ΓòÉΓòÉΓòÉ 2.75. floor - Integer <= Argument ΓòÉΓòÉΓòÉ
  5082.  
  5083. #include <math.h>
  5084.  
  5085. double floor(double x);
  5086.  
  5087. Language Level: ANSI, SAA 
  5088.  
  5089. Description 
  5090.  
  5091. The floor function calculates the floating-point value representing the largest 
  5092. integer less than or equal to x.  The floor function returns the floating-point 
  5093. result as a double value. 
  5094.  
  5095. The result of the floor function cannot have a range error. 
  5096.  
  5097. Example of floor 
  5098.  
  5099. Related Information 
  5100.  
  5101. o ceil - Integer >= Argument 
  5102. o fmod  - Floating-Point Remainder 
  5103. o math.h 
  5104.  
  5105.  
  5106. ΓòÉΓòÉΓòÉ 2.76. _flushall - Write Buffers to Files ΓòÉΓòÉΓòÉ
  5107.  
  5108. #include <stdio.h>
  5109.  
  5110. int _flushall(void);
  5111.  
  5112. Language Level: Extension 
  5113.  
  5114. Description 
  5115.  
  5116. The _flushall function causes the system to write to files the contents of all 
  5117. buffers associated with open output streams (including stdin, stdout, and 
  5118. stderr). It clears all buffers associated with open input streams of their 
  5119. current contents. The next read operation, if there is one, reads new data from 
  5120. the input files into the buffers.  All streams remain open after the call. 
  5121.  
  5122. Use the SAA function fflush to replace _flushall in your programs. 
  5123.  
  5124. The _flushall function returns the number of open streams of input and output. 
  5125. If an error occurs, _flushall returns EOF. 
  5126.  
  5127. Example of _flushall 
  5128.  
  5129. Related Information 
  5130.  
  5131. o fclose  - Close Stream 
  5132. o fflush  - Write Buffer to File 
  5133. o stdio.h 
  5134.  
  5135.  
  5136. ΓòÉΓòÉΓòÉ 2.77. fmod  - Floating-Point Remainder ΓòÉΓòÉΓòÉ
  5137.  
  5138. #include <math.h>
  5139.  
  5140. double fmod(double x, double y);
  5141.  
  5142. Language Level: ANSI, SAA 
  5143.  
  5144. Description 
  5145.  
  5146. The fmod function returns the floating-point remainder of x/y. The absolute 
  5147. value of the result is always less than the absolute value of y. The result 
  5148. will have the same sign as x. 
  5149.  
  5150. If y is zero or if x/y causes an overflow, the function returns 0. 
  5151.  
  5152. Example of fmod 
  5153.  
  5154. Related Information 
  5155.  
  5156. o ceil - Integer >= Argument 
  5157. o fabs  - Floating-Point Absolute Value 
  5158. o floor - Integer <= Argument 
  5159. o math.h 
  5160.  
  5161.  
  5162. ΓòÉΓòÉΓòÉ 2.78. fopen  - Open Files ΓòÉΓòÉΓòÉ
  5163.  
  5164. #include <stdio.h>
  5165.  
  5166. FILE *fopen(const char *filename, const char *mode);
  5167.  
  5168. Language Level: ANSI, SAA 
  5169.  
  5170. Description 
  5171.  
  5172. The fopen function opens the file specified by filename.  The mode variable is 
  5173. a character string specifying the type of access requested for the file.  The 
  5174. mode variable contains one positional parameter followed by optional keyword 
  5175. parameters. 
  5176.  
  5177. CAUTION:
  5178. Use the w, w+, wb, w+b, and wb+ parameters with care;  data in existing files 
  5179. of the same name will be lost. 
  5180.  
  5181. The possible values for the positional parameters follow: 
  5182.  
  5183. Mode Description 
  5184.   Open a text file for reading.  (The file must exist.) 
  5185.   Create a text file for writing.  If the given file exists, its contents are 
  5186.   destroyed. 
  5187.   Open a text file in append mode for writing at the end of the file.  fopen 
  5188.   creates the file first if it does not exist. 
  5189. r+ 
  5190.   Open a text file for both reading and writing.  (The file must exist.) 
  5191. w+ 
  5192.   Create a text file for both reading and writing.  If the given file exists, 
  5193.   its contents are destroyed. 
  5194. a+ 
  5195.   Open a text file in append mode for reading or updating at the end of the 
  5196.   file.  fopen creates the file first if it does not exist. 
  5197. rb 
  5198.   Open a binary file for reading.  (The file must exist.) 
  5199. wb 
  5200.   Create an empty binary file for writing.  If the file exists, its contents 
  5201.   will be destroyed. 
  5202. ab 
  5203.   Append a binary file for writing.  Create the file first if it does not 
  5204.   exist. 
  5205. r+b or rb+ 
  5206.   Open a binary file for both reading and writing.  (The file must exist.) 
  5207. w+b or wb+ 
  5208.   Create an empty binary file for both reading and writing.  If the file 
  5209.   exists, its contents will be destroyed. 
  5210. a+b or ab+ 
  5211.   Open a binary file in append mode for writing at the end of the file.  fopen 
  5212.   creates the file first if it does not exist. 
  5213.  
  5214. Text files contain printable characters and control characters organized into 
  5215. lines.  Each line ends with a new-line character, except possibly the last 
  5216. line, depending on the compiler. The system may insert or convert control 
  5217. characters in an output text stream.  Note that data output to a text stream 
  5218. may not compare as equal to the same data on input. 
  5219.  
  5220. Binary files contain a series of characters.  For binary files, the system does 
  5221. not translate control characters on input or output. 
  5222.  
  5223. When you open a file with a, a+, ab, a+b or ab+ mode, all write operations take 
  5224. place at the end of the file.  Although you can reposition the file pointer 
  5225. using fseek or rewind, the write functions move the file pointer back to the 
  5226. end of the file before they carry out any operation.  Thus, you cannot write 
  5227. over existing data. 
  5228.  
  5229. When you specify the update mode (using + in the second or third position), you 
  5230. can both read from and write to the file.  However, when switching between 
  5231. reading and writing, you must include an intervening positioning function such 
  5232. as fseek, fsetpos, rewind, or fflush.  Output may immediately follow input if 
  5233. end of file was detected. 
  5234.  
  5235. In different compilers, some keywords are ignored or mapped to the appropriate 
  5236. system. See for more information. 
  5237.  
  5238. The keyword parameters are: 
  5239.  
  5240. blksize=value 
  5241.   Specifies the maximum length, in bytes, of a physical block of records. For 
  5242.   fixed-length records, the maximum size is 32760 bytes.  For variable-length 
  5243.   records, the maximum is 32756. The default buffer size is 4096 bytes. 
  5244. lrecl=value 
  5245.   Specifies the length, in bytes, for fixed-length records and the maximum 
  5246.   length for variable-length records. For fixed-length records, the maximum 
  5247.   length is 32760 bytes.  For variable-length records, the maximum is 32756. If 
  5248.   the value of LRECL is larger than the value of BLKSIZE, the LRECL value is 
  5249.   ignored 
  5250. recfm=value 
  5251.   value can be: 
  5252.  
  5253.    F    fixed-length, unblocked records 
  5254.    V    variable-length, unblocked records The default for the Giverny compiler 
  5255.   is fixed-length record format. 
  5256. type=value 
  5257.   value can be: 
  5258.  
  5259.   memory  This parameter identifies this file as an in-memory file that is 
  5260.   accessible only from C programs. If you want to use an in-memory file, you 
  5261.   must compile with option /Sv. 
  5262.  
  5263. Giverny does not support record I/O. 
  5264.  
  5265. The fopen function generally fails if parameters are mismatched. 
  5266.  
  5267. The file attributes can be altered only if the open mode specified with the 
  5268. fopen function is one of the write modes (w, w+, wb, or wb+). The system 
  5269. deletes the existing file and creates a new file with the attributes specified 
  5270. in fopen. 
  5271.  
  5272. The fopen function returns a pointer to a file structure that can be used to 
  5273. access the open file.  A NULL pointer return value indicates an error. 
  5274.  
  5275. Example of fopen 
  5276.  
  5277. Related Information 
  5278.  
  5279. o fclose  - Close Stream 
  5280. o fflush  - Write Buffer to File 
  5281. o fread  - Read Items 
  5282. o freopen  - Redirect Open Files 
  5283. o fseek  - Reposition File Position 
  5284. o fsetpos  - Set File Position 
  5285. o fwrite  - Write Items 
  5286. o rewind  - Adjust Current File Position 
  5287. o stdio.h 
  5288.  
  5289.  
  5290. ΓòÉΓòÉΓòÉ 2.79. _fpatan - Calculate Arctangent ΓòÉΓòÉΓòÉ
  5291.  
  5292. #include <builtin.h>
  5293.  
  5294. double _fpatan(double x, double y);
  5295.  
  5296. Language Level: Extension 
  5297.  
  5298. Description 
  5299.  
  5300. The _fpatan function calculates the arctangent of x/y. This function causes the 
  5301. compiler to emit the FPATAN 80387 instruction. 
  5302.  
  5303. Because it is a built-in function and has no backing code in the library: 
  5304.  
  5305. o You cannot take the address of _fpatan. 
  5306. o You cannot parenthesize a _fpatan function call, because parentheses specify 
  5307.   a call to the backing code for the function in the library. 
  5308.  
  5309. This function returns the arctangent of x/y. 
  5310.  
  5311. Example of _fpatan 
  5312.  
  5313. Related Information 
  5314.  
  5315. o atan - atan2  - Arc Tangent 
  5316. o _fptan - Calculate Tangent 
  5317.  
  5318.  
  5319. ΓòÉΓòÉΓòÉ 2.80. _fpreset - Reset Floating-Point Unit ΓòÉΓòÉΓòÉ
  5320.  
  5321. #include <float.h>
  5322.  
  5323. void _fpreset(void);
  5324.  
  5325. Language Level: Extension 
  5326.  
  5327. Description 
  5328.  
  5329. The _fpreset function resets the floating-point unit to the default state that 
  5330. the math library requires to function properly. This function is often used 
  5331. within signal handlers, and can be registered by using the signal function. 
  5332.  
  5333. If a program traps floating-point error signals (SIGFPE) with signal, the 
  5334. program can safely recover from floating-point errors by calling longjmp. 
  5335.  
  5336. The _fpreset function resets the floating-point unit of the current thread 
  5337. only.  It does not affect any other threads that may be processing. 
  5338.  
  5339. There is no return value. 
  5340.  
  5341. Example of _fpreset 
  5342.  
  5343. Related Information 
  5344.  
  5345. o _clear87 - Clear Floating-Point Statu         s Word 
  5346. o _control87 - Set Floating-Point Status         Word 
  5347. o longjmp  - Restore Stack Environment 
  5348. o signal - Install Interrupt Handlers 
  5349. o _status87 - Get Floating-Point Status Word 
  5350. o float.h 
  5351.  
  5352.  
  5353. ΓòÉΓòÉΓòÉ 2.81. fprintf  - Formatted Write ΓòÉΓòÉΓòÉ
  5354.  
  5355. #include <stdio.h>
  5356.  
  5357. int fprintf(FILE *stream, const char *format-string, argument-list);
  5358.  
  5359. Language Level: ANSI, SAA, Extension 
  5360.  
  5361. Description 
  5362.  
  5363. The fprintf function formats and writes a series of characters and values to 
  5364. the output stream.  The fprintf function converts each entry in argument-list, 
  5365. if any, and writes to the stream according to the corresponding format 
  5366. specification in the format-string. 
  5367.  
  5368. The format-string has the same form and function as the format-string argument 
  5369. for the printf function. 
  5370.  
  5371. In extended mode, fprintf also converts floating-point values of NaN and 
  5372. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  5373. and sign of the string is determined by the format specifiers.  See Infinity 
  5374. and NaN Support for more information on infinity and NaN values. 
  5375.  
  5376. The fprintf function returns the number of characters printed or a negative 
  5377. value if an output error occurs. 
  5378.  
  5379. Example of fprintf 
  5380.  
  5381. Related Information 
  5382.  
  5383. o fscanf  - Read Formatted Data 
  5384. o printf  - Formatted Print 
  5385. o sprintf  - Formatted Print to Buffer 
  5386. o vfprintf  - Print Argument Data 
  5387. o vprintf  - Print Argument Data 
  5388. o vsprintf  - Print Argument Data 
  5389. o Infinity and NaN Support 
  5390. o stdio.h 
  5391.  
  5392.  
  5393. ΓòÉΓòÉΓòÉ 2.82. _fptan - Calculate Tangent ΓòÉΓòÉΓòÉ
  5394.  
  5395. #include <builtin.h>
  5396.  
  5397. double _fptan(double x);
  5398.  
  5399. Language Level: Extension 
  5400.  
  5401. Description 
  5402.  
  5403. The _fptan function calculates the tangent of x, where x is expressed in 
  5404. radians. The value of x must be less than 2**63. This function causes the 
  5405. compiler to emit the FPTAN 80387 instruction. 
  5406.  
  5407. Because it is a built-in function and has no backing code in the library: 
  5408.  
  5409. o You cannot take the address of _fptan. 
  5410. o You cannot parenthesize a _fptan function call, because parentheses specify a 
  5411.   call to the backing code for the function in the library. 
  5412.  
  5413. This function returns the tangent of a variable x expressed in radians. 
  5414.  
  5415. Example of _fptan 
  5416.  
  5417. Related Information 
  5418.  
  5419. o tan  - Tangent 
  5420. o _fpatan - Calculate Arctangent 
  5421.  
  5422.  
  5423. ΓòÉΓòÉΓòÉ 2.83. fputc  - Write a Character ΓòÉΓòÉΓòÉ
  5424.  
  5425. #include <stdio.h>
  5426.  
  5427. int fputc(int c, FILE *stream);
  5428.  
  5429. Language Level: ANSI, SAA 
  5430.  
  5431. Description 
  5432.  
  5433. The fputc function converts c to an unsigned char and then writes c to the 
  5434. output stream at the current position and advances the file position 
  5435. appropriately. If the stream is opened with one of the append modes, the 
  5436. character is appended to the end of the stream. 
  5437.  
  5438. The fputc function returns the character written.  A return value of EOF 
  5439. indicates an error. 
  5440.  
  5441. The fputc function is identical to putc but is guaranteed to be a function. 
  5442.  
  5443. Example of fputc 
  5444.  
  5445. Related Information 
  5446.  
  5447. o fgetc  - Read a Character 
  5448. o _fputchar - Write Character 
  5449. o putc - putchar  - Write a Character 
  5450. o _putch - Write Character to Screen 
  5451. o stdio.h 
  5452.  
  5453.  
  5454. ΓòÉΓòÉΓòÉ 2.84. _fputchar - Write Character ΓòÉΓòÉΓòÉ
  5455.  
  5456. #include <stdio.h>
  5457.  
  5458. int _fputchar(int c);
  5459.  
  5460. Language Level: Extension 
  5461.  
  5462. Description 
  5463.  
  5464. The _fputchar function writes the single character c to the stdout stream at 
  5465. the current position. It is equivalent to a call to the SAA function fputc: 
  5466.  
  5467.    fputc(c, stdout);
  5468.  
  5469. For portability, replace _fputchar with the SAA equivalent. 
  5470.  
  5471. The function returns the character written.  A return value of EOF indicates 
  5472. that a write error has occurred. Use ferror and feof to tell whether this is an 
  5473. error condition or the end of the file. 
  5474.  
  5475. Example of _fputchar 
  5476.  
  5477. Related Information 
  5478.  
  5479. o _cputs - Write String to Screen 
  5480. o _fgetchar - Read Single Character from stdin 
  5481. o fputc  - Write a Character 
  5482. o putc - putchar  - Write a Character 
  5483. o _putch - Write Character to Screen 
  5484. o stdio.h 
  5485.  
  5486.  
  5487. ΓòÉΓòÉΓòÉ 2.85. fputs  - Print Strings ΓòÉΓòÉΓòÉ
  5488.  
  5489. #include <stdio.h>
  5490.  
  5491. int fputs(const char *string, FILE *stream);
  5492.  
  5493. Language Level: ANSI, SAA 
  5494.  
  5495. Description 
  5496.  
  5497. The fputs function copies string to the output stream at the current position. 
  5498. It does not copy the null character (\0) at the end of the string. 
  5499.  
  5500. If an error occurs, the fputs function returns EOF;  otherwise, it returns a 
  5501. non-negative value. 
  5502.  
  5503. Example of fputs 
  5504.  
  5505. Related Information 
  5506.  
  5507. o fgets  - Read a String 
  5508. o gets  - Read a Line 
  5509. o puts  - Write a String 
  5510. o stdio.h 
  5511.  
  5512.  
  5513. ΓòÉΓòÉΓòÉ 2.86. fread  - Read Items ΓòÉΓòÉΓòÉ
  5514.  
  5515. #include <stdio.h>
  5516.  
  5517. size_t fread(void *buffer, size_t size, size_t count,
  5518.                 FILE *stream);
  5519.  
  5520. Language Level: ANSI, SAA 
  5521.  
  5522. Description 
  5523.  
  5524. The fread function reads up to count items of size length from the input stream 
  5525. and stores them in the given buffer.  The position in the file increases by the 
  5526. number of bytes read. 
  5527.  
  5528. The fread function returns the number of full items successfully read, which 
  5529. can be less than count if an error occurs or if the file end is met before 
  5530. reaching count.  If size or count is zero, fread returns zero and the contents 
  5531. of the array and the state of the stream remain unchanged. 
  5532.  
  5533. The ferror and feof functions are used to distinguish between a read error and 
  5534. an end-of-file. 
  5535.  
  5536. Example of fread 
  5537.  
  5538. Related Information 
  5539.  
  5540. o feof  - Test End-of-File Indicator 
  5541. o ferror  - Test for Read/Write Errors 
  5542. o fopen  - Open Files 
  5543. o fwrite  - Write Items 
  5544. o stdio.h 
  5545.  
  5546.  
  5547. ΓòÉΓòÉΓòÉ 2.87. free  - Release Storage Blocks ΓòÉΓòÉΓòÉ
  5548.  
  5549. #include <stdlib.h>
  5550.  
  5551. void free(void *ptr);
  5552.  
  5553. Language Level: ANSI, SAA, Extension 
  5554.  
  5555. Description 
  5556.  
  5557. The free function frees a block of storage.  The ptr variable points to a block 
  5558. previously reserved with a call to calloc, malloc, or realloc.  The number of 
  5559. bytes freed is the number of bytes specified when you reserved (or reallocated, 
  5560. in the case of realloc) the block of storage.  If ptr is NULL, free simply 
  5561. returns. 
  5562.  
  5563. There is no return value. 
  5564.  
  5565. Note:  Attempting to free a block of storage not allocated with calloc, malloc, 
  5566.        or realloc (or previously freed storage) can affect the subsequent 
  5567.        reserving of storage and lead to undefined results. 
  5568.  
  5569. Example of free 
  5570.  
  5571. Related Information 
  5572.  
  5573. o _alloca - Temporarily Reserve Storag         e Block 
  5574. o calloc  - Reserve and Initialize Storage 
  5575. o _debug_free - Release Storage Blocks 
  5576. o malloc  - Reserve Storage Block 
  5577. o realloc  - Change Reserved Storage Block Size 
  5578. o malloc.h 
  5579. o stdlib.h 
  5580.  
  5581.  
  5582. ΓòÉΓòÉΓòÉ 2.88. _freemod - Free User DLL ΓòÉΓòÉΓòÉ
  5583.  
  5584. #include <stdlib.h>
  5585.  
  5586. int _freemod(unsigned long module_handle);
  5587.  
  5588. Language Level: Extension 
  5589.  
  5590. Description 
  5591.  
  5592. The _freemod function frees all references to a user-created dynamic linked 
  5593. library (DLL) for the calling process.  It is the counterpart of the _loadmod 
  5594. function, which loads a DLL for the process. The module_handle is the module 
  5595. handle of the DLL, which was returned by _loadmod. 
  5596.  
  5597. If successful, the _freemod function returns 0. If not, _freemod returns -1 and 
  5598. sets errno to EOS2ERR and _doserrno to the OS/2 error code. 
  5599.  
  5600. Example of _freemod 
  5601.  
  5602. Related Information 
  5603.  
  5604. o _loadmod - Load User DLL 
  5605. o stdlib.h 
  5606.  
  5607.  
  5608. ΓòÉΓòÉΓòÉ 2.89. freopen  - Redirect Open Files ΓòÉΓòÉΓòÉ
  5609.  
  5610. #include <stdio.h>
  5611.  
  5612. FILE *freopen(const char *filename, const char *mode, FILE *stream);
  5613.  
  5614. Language Level: ANSI, SAA 
  5615.  
  5616. Description 
  5617.  
  5618. The freopen function closes the file currently associated with stream and 
  5619. reassigns stream to the file specified by filename.  Use the freopen function 
  5620. to redirect the previously opened files stdin, stdout, and stderr to files that 
  5621. you specify.  The freopen function opens the new file associated with stream 
  5622. with the given mode, which is a character string specifying the type of access 
  5623. requested for the file. 
  5624.  
  5625. If filename is an empty string, freopen closes and reopens the stream to the 
  5626. new open mode, rather than reassigning it to a new file or device.  This is 
  5627. supported so that you can change the stream modes, for example, from a text 
  5628. stream to a binary stream. 
  5629.  
  5630. See fopen for a description of the mode parameter. 
  5631.  
  5632. The freopen function returns the value of stream to the newly-opened file.  If 
  5633. an error occurs, freopen closes the original file and returns a NULL pointer 
  5634. value. 
  5635.  
  5636. Example of freopen 
  5637.  
  5638. Related Information 
  5639.  
  5640. o fclose  - Close Stream 
  5641. o fopen  - Open Files 
  5642. o stdio.h 
  5643.  
  5644.  
  5645. ΓòÉΓòÉΓòÉ 2.90. frexp  - Separate Floating-Point Value ΓòÉΓòÉΓòÉ
  5646.  
  5647. #include <math.h>
  5648.  
  5649. double frexp(double x, int *expptr);
  5650.  
  5651. Language Level: ANSI, SAA 
  5652.  
  5653. Description 
  5654.  
  5655. The frexp function breaks down the floating-point value x into a term m for the 
  5656. mantissa and another term n for the exponent, such that the absolute value of m 
  5657. is greater than or equal to 0.5 and less than 1.0 or equal to 0, and x = m * 
  5658. (2**n). The frexp function stores the integer exponent n at the location to 
  5659. which expptr points. 
  5660.  
  5661. The frexp function returns the mantissa term m.  If x is zero, the function 
  5662. returns 0 for both the mantissa and exponent.  The mantissa has the same sign 
  5663. as the argument x.  The result of the frexp function cannot have a range error. 
  5664.  
  5665. Example of frexp 
  5666.  
  5667. Related Information 
  5668.  
  5669. o ldexp  - Multiply by a Power of Two 
  5670. o modf  - Separate Floating-Point Value 
  5671. o math.h 
  5672.  
  5673.  
  5674. ΓòÉΓòÉΓòÉ 2.91. fscanf  - Read Formatted Data ΓòÉΓòÉΓòÉ
  5675.  
  5676. #include <stdio.h>
  5677.  
  5678. int fscanf (FILE *stream, const char *format-string, argument-list);
  5679.  
  5680. Language Level: ANSI, SAA, Extension 
  5681.  
  5682. Description 
  5683.  
  5684. The fscanf function reads data from the current position of the specified 
  5685. stream into the locations given by the entries in argument-list, if any.  Each 
  5686. entry in argument-list must be a pointer to a variable with a type that 
  5687. corresponds to a type specifier in format-string. 
  5688.  
  5689. The format-string controls the interpretation of the input fields and has the 
  5690. same form and function as the format-string argument for the scanf function. 
  5691. See scanf for a description of format-string. 
  5692.  
  5693. In extended mode, the fscanf function also reads in the strings "INFINITY", 
  5694. "INF", and "NAN" (in upper or lowercase) and converts them to the corresponding 
  5695. floating-point value.  The sign of the value is determined by the format 
  5696. specification. See Infinity and NaN Support for more information on infinity 
  5697. and NaN values. 
  5698.  
  5699. The fscanf function returns the number of fields that it successfully converted 
  5700. and assigned.  The return value does not include fields that fscanf read but 
  5701. did not assign. 
  5702.  
  5703. The return value is EOF if an input failure occurs before any conversion, or 
  5704. the number of input items assigned if successful. 
  5705.  
  5706. Example of fscanf 
  5707.  
  5708. Related Information 
  5709.  
  5710. o fprintf  - Formatted Write 
  5711. o scanf  - Read Data 
  5712. o sscanf  - Read Data 
  5713. o Infinity and NaN Support 
  5714. o stdio.h 
  5715.  
  5716.  
  5717. ΓòÉΓòÉΓòÉ 2.92. fseek  - Reposition File Position ΓòÉΓòÉΓòÉ
  5718.  
  5719. #include <stdio.h>
  5720.  
  5721. int fseek(FILE *stream, long int offset, int origin);
  5722.  
  5723. Language Level: ANSI, SAA 
  5724.  
  5725. Description 
  5726.  
  5727. The fseek function changes the current file position associated with stream to 
  5728. a new location within the file. The next operation on the stream takes place at 
  5729. the new location.  On a stream open for update, the next operation can be 
  5730. either a reading or a writing operation. 
  5731.  
  5732. The origin must be one of the following constants defined in <stdio.h>: 
  5733.  
  5734. Origin            Definition 
  5735. SEEK_SET          Beginning of file 
  5736. SEEK_CUR          Current position of file pointer 
  5737. SEEK_END          End of file 
  5738.  
  5739. For a binary stream, you can also change the position beyond the end of the 
  5740. file.  An attempt to position before the beginning of the file causes an error. 
  5741. If successful, the fseek function clears the end-of-file indicator, even when 
  5742. origin is SEEK_END, and undoes the effect of any preceding ungetc function on 
  5743. the same stream. 
  5744.  
  5745. The fseek function returns the value 0 if it successfully moves the pointer.  A 
  5746. nonzero return value indicates an error.  On devices that cannot seek, such as 
  5747. terminals and printers, the return value is nonzero. 
  5748.  
  5749. Note:  For streams opened in text mode, fseek has limited use because some 
  5750.        system translations (such as those between carriage return/line feed and 
  5751.        newline) can produce unexpected results.  The only fseek operations that 
  5752.        can be relied upon to work on streams opened in text mode are seeking 
  5753.        with an offset of zero relative to any of the origin values or seeking 
  5754.        from the beginning of the file with an offset value returned from a call 
  5755.        to ftell. See the IBM Giverny Programming Guide for more information. 
  5756.  
  5757. Example of fseek 
  5758.  
  5759. Related Information 
  5760.  
  5761. o ftell  - Get Current Position 
  5762. o rewind  - Adjust Current File Position 
  5763. o ungetc  - Push Character onto Input Stream 
  5764. o stdio.h 
  5765.  
  5766.  
  5767. ΓòÉΓòÉΓòÉ 2.93. fsetpos  - Set File Position ΓòÉΓòÉΓòÉ
  5768.  
  5769. #include <stdio.h>
  5770.  
  5771. int fsetpos(FILE *stream, const fpos_t *pos);
  5772.  
  5773. Language Level: ANSI, SAA 
  5774.  
  5775. Description 
  5776.  
  5777. The fsetpos function moves any file position associated with stream to a new 
  5778. location within the file according to the value pointed to by pos.  The value 
  5779. of pos was obtained by a previous call to the fgetpos library function. 
  5780.  
  5781. If fsetpos successfully changes the current position of the file, it returns 
  5782. the value 0. If successful, the fsetpos function clears the end-of-file 
  5783. indicator, and undoes the effect of any previous ungetc function on the same 
  5784. stream.  A nonzero return value indicates an error. 
  5785.  
  5786. After the fsetpos call, the next operation on a stream in update mode may be 
  5787. input or output. 
  5788.  
  5789. Example of fsetpos 
  5790.  
  5791. Related Information 
  5792.  
  5793. o fgetpos  - Get File Position 
  5794. o ftell  - Get Current Position 
  5795. o rewind  - Adjust Current File Position 
  5796. o ungetc  - Push Character onto Input Stream 
  5797. o stdio.h 
  5798.  
  5799.  
  5800. ΓòÉΓòÉΓòÉ 2.94. _fsin - Calculate Sine ΓòÉΓòÉΓòÉ
  5801.  
  5802. #include <builtin.h>
  5803.  
  5804. double _fsin( double x);
  5805.  
  5806. Language Level: Extension 
  5807.  
  5808. Description 
  5809.  
  5810. The _fsin function calculates the sine of x, where x is expressed in radians. 
  5811. The value of x must be less than 2**63. This function causes the compiler to 
  5812. emit the FSIN 80387 instruction. 
  5813.  
  5814. Because it is a built-in function and has no backing code in the library: 
  5815.  
  5816. o You cannot take the address of _fsin. 
  5817. o You cannot parenthesize a _fsin function call, because parentheses specify a 
  5818.   call to the backing code for the function in the library. 
  5819.  
  5820. This function returns the sine of a variable x expressed in radians. 
  5821.  
  5822. Example of _fsin 
  5823.  
  5824. Related Information 
  5825.  
  5826. o sin  - Sine 
  5827. o _fsincos - Calculate Sine and Cosine 
  5828.  
  5829.  
  5830. ΓòÉΓòÉΓòÉ 2.95. _fsincos - Calculate Sine and Cosine ΓòÉΓòÉΓòÉ
  5831.  
  5832. #include <builtin.h>
  5833.  
  5834. double _fsincos(double x, double *y);
  5835.  
  5836. Language Level: Extension 
  5837.  
  5838. Description 
  5839.  
  5840. The _fsincos function calculates the sine of x, and stores the cosine in *y. 
  5841. This operation is faster than separately calculating the sine and cosine. Use 
  5842. _fsincos instead of _fcossin when you will be using the sine first, and then 
  5843. the cosine. This function causes the compiler to emit the FSINCOS 80387 
  5844. instruction. 
  5845.  
  5846. Because it is a built-in function and has no backing code in the library: 
  5847.  
  5848. o You cannot take the address of _fsincos. 
  5849. o You cannot parenthesize a _fsincos function call because parentheses specify 
  5850.   a call to the backing code for the function in the library. 
  5851.  
  5852. This function returns the sine of x. 
  5853.  
  5854. Example of _fsincos 
  5855.  
  5856. Related Information 
  5857.  
  5858. o asin  - Arc Sine 
  5859. o sin  - Sine 
  5860. o _fsin - Calculate Sine 
  5861. o _fcossin - Calculate Cosine and Sine 
  5862.  
  5863.  
  5864. ΓòÉΓòÉΓòÉ 2.96. _fsqrt -  Compute Square Root ΓòÉΓòÉΓòÉ
  5865.  
  5866. #include <builtin.h>
  5867.  
  5868. double _fsqrt(double x);
  5869.  
  5870. Language Level: Extension 
  5871.  
  5872. Description 
  5873.  
  5874. The _fsqrt function computes the square root of x using the FSQRT 80387 
  5875. instruction. Note that this function does not set errno as the ΓêÜ function does. 
  5876. If you pass negative values to this function, it will result in an exception. 
  5877.  
  5878. Because it is a built-in function and has no backing code in the library: 
  5879.  
  5880. o You cannot take the address of _fsqrt. 
  5881. o You cannot parenthesize a _fsqrt function call, because parentheses specify a 
  5882.   call to the backing code for the function in the library. 
  5883.  
  5884. This function returns the value of the square root of x. 
  5885.  
  5886. Example of _fsqrt 
  5887.  
  5888. Related Information 
  5889.  
  5890. o sqrt  - Calculate Square Root 
  5891.  
  5892.  
  5893. ΓòÉΓòÉΓòÉ 2.97. _fstat - Information about Open File ΓòÉΓòÉΓòÉ
  5894.  
  5895. #include <sys\stat.h>
  5896. #include <sys\types.h>
  5897.  
  5898. int _fstat(int handle, struct stat *buffer);
  5899.  
  5900. Language Level: Extension 
  5901.  
  5902. Description 
  5903.  
  5904. The _fstat function obtains information about the open file associated with the 
  5905. given handle and stores it in the structure to which buffer points.  The 
  5906. <sys\stat.h> include file defines the stat structure.  The stat structure 
  5907. contains the following fields: 
  5908.  
  5909. Field       Value 
  5910.  
  5911. st_mode     Bit mask for file mode information. The _fstat function sets the 
  5912.             S_IFCHR bit if handle refers to a device. The S_IFDIR bit is set if 
  5913.             pathname specifies a directory. It sets the S_IFREG bit if handle 
  5914.             refers to an ordinary file.  It sets user read/write bits according 
  5915.             to the permission mode of the file.  The other bits have undefined 
  5916.             values. 
  5917.  
  5918.                                             F E D C B A 9 8 7 6 5 4 3 2 1 0
  5919.                                            Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé
  5920.                                            ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
  5921.                                                          
  5922.                                S_IFREGΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ Γöé Γöé         Γöé Γöé ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇexecute/search permission,
  5923.                         (regular file)        Γöé Γöé         Γöé Γöé        owner (S_IEXEC)
  5924.                                S_IFDIRΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ Γöé         Γöé ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇwrite permission, owner
  5925.                                S_IFCHRΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ         ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇread permission, owner
  5926.  
  5927. st_dev      Drive number of the disk containing the file. 
  5928.  
  5929. st_rdev     Drive number of the disk containing the file (same as st_dev). 
  5930.  
  5931. st_nlink    Always 1. 
  5932.  
  5933. st_size     Size of the file in bytes. 
  5934.  
  5935. st_atime    Time of last modification of file. 
  5936.  
  5937. st_mtime    Same as st_atime if not provided by the file system. 
  5938.  
  5939. st_ctime    Same as st_atime if not provided by the file system. 
  5940.  
  5941. There are three additional fields in the stat structure for portability to 
  5942. other operating systems;  they have no meaning on the DOS or OS/2 operating 
  5943. system. 
  5944.  
  5945. Note:  If the given handle refers to a device, the size and time fields in the 
  5946. stat structure are not meaningful. 
  5947.  
  5948. The _fstat function returns the value 0 if it obtains the file status 
  5949. information.  A return value of -1 indicates an error;  in this case, _fstat 
  5950. sets errno to EBADF, showing an incorrect file handle. 
  5951.  
  5952. Example of _fstat 
  5953.  
  5954. Related Information 
  5955.  
  5956. o _stat - Get Information about File or Directory 
  5957. o sys\stat.h 
  5958. o sys\types.h 
  5959.  
  5960.  
  5961. ΓòÉΓòÉΓòÉ 2.98. ftell  - Get Current Position ΓòÉΓòÉΓòÉ
  5962.  
  5963. #include <stdio.h>
  5964.  
  5965. long int ftell(FILE *stream);
  5966.  
  5967. Language Level: ANSI, SAA 
  5968.  
  5969. Description 
  5970.  
  5971. The ftell function returns a value indicating the current position of the file 
  5972. associated with stream. For a fixed-length binary file, the value returned by 
  5973. ftell is an offset relative to the beginning of the stream. 
  5974.  
  5975. On error, ftell returns -1L and sets errno to a nonzero value. 
  5976.  
  5977. Example of ftell 
  5978.  
  5979. Related Information 
  5980.  
  5981. o fseek  - Reposition File Position 
  5982. o fgetpos  - Get File Position 
  5983. o fopen  - Open Files 
  5984. o stdio.h 
  5985.  
  5986.  
  5987. ΓòÉΓòÉΓòÉ 2.99. _ftime - Store Current Time ΓòÉΓòÉΓòÉ
  5988.  
  5989. #include <sys\timeb.h>
  5990. #include <sys\types.h>
  5991.  
  5992. void _ftime(struct timeb *timeptr);
  5993.  
  5994. Language Level: Extension 
  5995.  
  5996. Description 
  5997.  
  5998. The _ftime function gets the current time and stores it in the structure to 
  5999. which timeptr points.  The <sys\timeb.h> include file contains the definition 
  6000. of the timeb structure.  It contains four fields:  time, millitm, timezone, and 
  6001. dstflag. 
  6002.  
  6003. The time field gives the time in seconds since 00:00:00 Coordinated Universal 
  6004. Time, January 1, 1970.  The millitm field gives the fraction of a second, in 
  6005. milliseconds. The timezone field gives the difference in minutes between 
  6006. Coordinated Universal Time and local time, going from east to west.  The _ftime 
  6007. function sets the value of timezone from the value of the global variable 
  6008. _timezone. The dstflag is nonzero if daylight saving time is currently in 
  6009. effect for the local time zone.  For an explanation of how daylight saving time 
  6010. is determined, see _tzset - Assign Values to Locale Information         . 
  6011.  
  6012. The _ftime function gives values to the fields in the structure to which 
  6013. timeptr points.  It does not return a value. 
  6014.  
  6015. Example of _ftime 
  6016.  
  6017. Related Information 
  6018.  
  6019. o asctime  - Convert Time 
  6020. o ctime  - Convert Time 
  6021. o gmtime  - Convert Time 
  6022. o localtime  - Convert Time 
  6023. o time  - Determine Current Time 
  6024. o _tzset - Assign Values to Locale Information 
  6025. o sys\timeb.h 
  6026. o sys\types.h 
  6027.  
  6028.  
  6029. ΓòÉΓòÉΓòÉ 2.100. _fullpath - Get Full Path Name of Partial Path ΓòÉΓòÉΓòÉ
  6030.  
  6031. #include <stdlib.h>
  6032.  
  6033. char *_fullpath(char *pathbuf, char *partialpath, size_t n);
  6034.  
  6035. Language Level: Extension 
  6036.  
  6037. Description 
  6038.  
  6039. The _fullpath function gets the full path name of the given partial path name 
  6040. partialpath, and stores it in pathbuf. The integer argument n specifies the 
  6041. maximum length for the path name.  An error occurs if the length of the path 
  6042. name, including the terminating null character, exceeds n characters. 
  6043.  
  6044. If the pathbuf argument is NULL, _fullpath uses malloc to allocate a buffer of 
  6045. size _MAX_PATH bytes to store the path name. 
  6046.  
  6047. The _fullpath function returns a pointer to pathbuf.  If an error occurs, 
  6048. _fullpath returns NULL and sets errno to one of the following values: 
  6049.  
  6050. Value          Meaning 
  6051. ENOMEM         Unable to allocate storage for the buffer. 
  6052. ERANGE         The path name is longer than n characters. 
  6053. EOS2ERR        A system error occurred.  Check _doserrno for the specific OS/2 
  6054.                error code. 
  6055.  
  6056. Example of _fullpath 
  6057.  
  6058. Related Information 
  6059.  
  6060. o _getcwd - Get Path Name of Current Directory 
  6061. o _getdcwd - Get Full Path Name of Current Directory 
  6062. o _makepath - Create Path 
  6063. o malloc  - Reserve Storage Block 
  6064. o _splitpath - Decompose Path Name 
  6065. o stdlib.h 
  6066.  
  6067.  
  6068. ΓòÉΓòÉΓòÉ 2.101. fwrite  - Write Items ΓòÉΓòÉΓòÉ
  6069.  
  6070. #include <stdio.h>
  6071.  
  6072. size_t fwrite(const void *buffer, size_t size, size_t count,
  6073.                  FILE *stream);
  6074.  
  6075. Language Level: ANSI, SAA 
  6076.  
  6077. Description 
  6078.  
  6079. The fwrite function writes up to count items of size length from buffer to the 
  6080. output stream. 
  6081.  
  6082. The fwrite function returns the number of full items successfully written, 
  6083. which can be less than count if an error occurs. 
  6084.  
  6085. Giverny does not support record I/O. 
  6086.  
  6087. Example of fwrite 
  6088.  
  6089. Related Information 
  6090.  
  6091. o fopen  - Open Files 
  6092. o fread  - Read Items 
  6093. o stdio.h 
  6094.  
  6095.  
  6096. ΓòÉΓòÉΓòÉ 2.102. _fyl2x - Compute y * log2(x) ΓòÉΓòÉΓòÉ
  6097.  
  6098. #include <builtin.h>
  6099.  
  6100. double _fyl2x(double x, double y);
  6101.  
  6102. Language Level: Extension 
  6103.  
  6104. Description 
  6105.  
  6106. The _fyl2x function computes the base-2 logarithm of x and multiplies it by y 
  6107. (y * log2(x)), using the FYL2X 80387 instruction. The variable x cannot be 
  6108. negative. This instruction is designed with a built-in multiplication to 
  6109. optimize the calculation of logarithms with arbitrary positive base: log b (x) 
  6110. = (log2(b)**-1) * log2(x) 
  6111.  
  6112. Because it is a built-in function and has no backing code in the library: 
  6113.  
  6114. o You cannot take the address of _fyl2x. 
  6115. o You cannot parenthesize a _fyl2x function call, because parentheses specify a 
  6116.   call to the backing code for the function in the library. 
  6117.  
  6118. This function returns the result of the formula y * log2(x) 
  6119.  
  6120. Example of _fyl2x 
  6121.  
  6122. Related Information 
  6123.  
  6124.  
  6125. ΓòÉΓòÉΓòÉ 2.103. _fyl2xp1 -  Calculate y * log2(x+1) ΓòÉΓòÉΓòÉ
  6126.  
  6127. #include <builtin.h>
  6128.  
  6129. double _fyl2xp1(double x, double y);
  6130.  
  6131. Language Level: Extension 
  6132.  
  6133. Description 
  6134.  
  6135. The _fyl2x function computes the base-2 logarithm of x+1 and multiplies it by y 
  6136. y * log2(x+1), using the FYL2XP1 80387 instruction. The variable x must be in 
  6137. the range -(1-(sqrt(2)/2)) to (sqrt(2) - 1). This function provides improved 
  6138. accuracy over the _fyl2x function when computing logarithms of numbers very 
  6139. close to 1. When x is small, you can retain more significant digits by 
  6140. providing x to the _fyl2xp1 function than by providing x+1 as an argument to 
  6141. the _fyl2x function. 
  6142.  
  6143. Because it is a built-in function and has no backing code in the library: 
  6144.  
  6145. o You cannot take the address of _fyl2xp1. 
  6146. o You cannot parenthesize a _fyl2xp1 function call, because parentheses specify 
  6147.   a call to the backing code for the function in the library. 
  6148.  
  6149. This function returns the result of the formula y * log2(x+1). 
  6150.  
  6151. Example of _fyl2xp1 
  6152.  
  6153. Related Information 
  6154.  
  6155.  
  6156. ΓòÉΓòÉΓòÉ 2.104. _f2xm1 -  Calculate 2**x - 1 ΓòÉΓòÉΓòÉ
  6157.  
  6158. #include <builtin.h>
  6159.  
  6160. double _f2xm1(double x);
  6161.  
  6162. Language Level: Extension 
  6163.  
  6164. Description 
  6165.  
  6166. The _f2xm1 function calculates 2 raised to the power of x, minus 1 ((2**x)-1), 
  6167. using the F2XM1 80387 instruction. The variable x must be in the range -1 to 1. 
  6168. This instruction is designed to produce very accurate results when x is close 
  6169. to 0. Large errors can be incurred for operands with magnitudes close to 1. You 
  6170. can exponentiate values other than 2 by using the formula x**y = 2**(y * 
  6171. log2(x)). 
  6172.  
  6173. Because it is a built-in function and has no backing code in the library: 
  6174.  
  6175. o You cannot take the address of _f2xm1. 
  6176. o You cannot parenthesize a _f2xm1 function call, because parentheses specify a 
  6177.   call to the backing code for the function in the library. 
  6178.  
  6179. This function returns the value of the formula (2**x)-1. 
  6180.  
  6181. Example of _f2xm1 
  6182.  
  6183. Related Information 
  6184.  
  6185.  
  6186. ΓòÉΓòÉΓòÉ 2.105. gamma  - Gamma Function ΓòÉΓòÉΓòÉ
  6187.  
  6188. #include <math.h> /* SAA extension to ANSI */
  6189.  
  6190. double gamma(double x);
  6191.  
  6192. Language Level: SAA 
  6193.  
  6194. Description 
  6195.  
  6196. The gamma function computes ln( |G(x)| ). The argument x must be a positive 
  6197. real value.  If x is a negative value, errno is set to EDOM.  If the result 
  6198. causes an overflow, the function returns HUGE_VAL and sets errno to ERANGE. 
  6199.  
  6200. C Set/2 allows x to be a negative integer. 
  6201.  
  6202. Example of gamma 
  6203.  
  6204. Related Information 
  6205.  
  6206. o Bessel Functions 
  6207. o erf - erfc  - Error Functions 
  6208. o math.h 
  6209.  
  6210.  
  6211. ΓòÉΓòÉΓòÉ 2.106. _gcvt - Convert Floating-Point to String ΓòÉΓòÉΓòÉ
  6212.  
  6213. #include <stdlib.h>
  6214.  
  6215. char *_gcvt(double value, int ndec, char *buffer);
  6216.  
  6217. Language Level: Extension 
  6218.  
  6219. Description 
  6220.  
  6221. The _gcvt function converts a floating-point value to a character string 
  6222. pointed to by buffer. The buffer should be large enough to hold the converted 
  6223. value and a null character (\0), that _gcvt automatically adds to the end of 
  6224. the string. There is no provision for overflow. 
  6225.  
  6226. The _gcvt function tries to produce ndec significant digits in FORTRAN F 
  6227. format. Failing that, it produces ndec significant digits in FORTRAN E format. 
  6228. Trailing zeros might be suppressed in the conversion if they are significant. 
  6229.  
  6230. A FORTRAN F number has the following format: 
  6231.  
  6232.              ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ       ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  6233.  ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitΓöÇΓö┤ΓöÇΓöÇΓöÇ.ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6234.      Γö£ΓöÇΓöÇ+ΓöÇΓöÇΓöñ                  ΓööΓöÇdigitΓöÇΓöÿ
  6235.      ΓööΓöÇΓöÇ-ΓöÇΓöÇΓöÿ
  6236.  
  6237. A FORTRAN E number has the following format: 
  6238.  
  6239.                        ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ                   ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  6240.  ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇdigitsΓöÇΓöÇ.ΓöÇΓöÇdigitsΓöÇΓö┤ΓöÇEΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇdigitsΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γö┤ΓöÇ
  6241.     Γö£ΓöÇΓöÇ+ΓöÇΓöÇΓöñ                         Γö£ΓöÇΓöÇ+ΓöÇΓöÇΓöñ         ΓööΓöÇdigitsΓöÇΓöÿ
  6242.     ΓööΓöÇΓöÇ-ΓöÇΓöÇΓöÿ                         ΓööΓöÇΓöÇ-ΓöÇΓöÇΓöÿ
  6243.  
  6244. The _gcvt function also converts NaN and infinity values to the strings NAN and 
  6245. INFINITY, respectively. For more information on NaN and infinity values, see 
  6246. Infinity and NaN Support. 
  6247.  
  6248. Warning: For each thread, the _ecvt, _fcvt and _gcvt functions use a single, 
  6249. dynamically allocated buffer for the conversion. Any subsequent call that the 
  6250. same thread makes to these functions destroys the result of the previous call. 
  6251.  
  6252. The _gcvt function returns a pointer to the string of digits. A failure to 
  6253. allocate memory returns an empty string and sets errno to ENOMEM. 
  6254.  
  6255. Example of _gcvt 
  6256.  
  6257. Related Information 
  6258.  
  6259. o atof  - Convert Character Strings 
  6260. o atoi  - Convert Character Strings 
  6261. o atol  - Convert Character Strings 
  6262. o _ecvt - Convert Floating-Point to         Character 
  6263. o _fcvt - Convert Floating-Point to         String 
  6264. o Infinity and NaN Support 
  6265. o stdlib.h 
  6266.  
  6267.  
  6268. ΓòÉΓòÉΓòÉ 2.107. getc - getchar  - Read a Character ΓòÉΓòÉΓòÉ
  6269.  
  6270. #include <stdio.h>
  6271.  
  6272. int getc(FILE *stream);
  6273.  
  6274. int getchar(void);
  6275.  
  6276. Language Level: ANSI, SAA 
  6277.  
  6278. Description 
  6279.  
  6280. The getc function reads a single character from the current stream position and 
  6281. advances the stream position to the next character.  The getchar function is 
  6282. identical to getc(stdin). 
  6283.  
  6284. The getc and getchar functions return the character read.  A return value of 
  6285. EOF indicates an error or end-of-file condition.  Use ferror or feof to 
  6286. determine whether an error or an end-of-file condition occurred. 
  6287.  
  6288. The difference between the getc and the getchar functions is that the getc 
  6289. function can be implemented so that its arguments can be evaluated multiple 
  6290. times.  The stream argument to getc should not be an expression with side 
  6291. effects. 
  6292.  
  6293. Example of getc - getchar 
  6294.  
  6295. Related Information 
  6296.  
  6297. o fgetc  - Read a Character 
  6298. o _fgetchar - Read Single Character from stdin 
  6299. o _getch - _getche - Read Character from Keyboard 
  6300. o putc - putchar  - Write a Character 
  6301. o ungetc  - Push Character onto Input Stream 
  6302. o gets  - Read a Line 
  6303. o stdio.h 
  6304.  
  6305.  
  6306. ΓòÉΓòÉΓòÉ 2.108. _getch - _getche - Read Character from Keyboard ΓòÉΓòÉΓòÉ
  6307.  
  6308. #include <conio.h>
  6309.  
  6310. int _getch(void);
  6311.  
  6312. int _getche(void);
  6313.  
  6314. Language Level: Extension 
  6315.  
  6316. Description 
  6317.  
  6318. The _getch function reads a single character from the keyboard, without 
  6319. echoing.  The _getche function reads a single character from the keyboard and 
  6320. displays the character read. Neither function can be used to read Ctrl-Break. 
  6321.  
  6322. When reading a function key or cursor-moving key, the _getch and _getche 
  6323. functions must be called twice.  The first call returns 0 or E0H, and the 
  6324. second call returns the particular extended key code. 
  6325.  
  6326. Example of _getch - _getche 
  6327.  
  6328. Related Information 
  6329.  
  6330. o _cgets - Read String of Characters from Keyboard 
  6331. o fgetc  - Read a Character 
  6332. o getc - getchar  - Read a Character 
  6333. o _putch - Write Character to Screen 
  6334. o _ungetch - Push Character Back to Keyboard 
  6335. o conio.h 
  6336.  
  6337.  
  6338. ΓòÉΓòÉΓòÉ 2.109. _getcwd - Get Path Name of Current Directory ΓòÉΓòÉΓòÉ
  6339.  
  6340. #include <direct.h>
  6341.  
  6342. char *_getcwd(char *pathbuf, int n);
  6343.  
  6344. Language Level: Extension 
  6345.  
  6346. Description 
  6347.  
  6348. The _getcwd function gets the full path name of the current working directory 
  6349. and stores it in the buffer pointed to by pathbuf.  The integer argument n 
  6350. specifies the maximum length for the path name.  An error occurs if the length 
  6351. of the path name, including the terminating null character, exceeds n 
  6352. characters. 
  6353.  
  6354. If the pathbuf argument is NULL, _getcwd uses malloc to reserve a buffer of at 
  6355. least n bytes to store the path name.  If the current working directory string 
  6356. is more than n bytes, a large enough buffer will be allocated to contain the 
  6357. string.  You can later free this buffer using the _getcwd return value as the 
  6358. argument to free. 
  6359.  
  6360. An alternative to this function is the DosQueryCurrentDir API call. 
  6361.  
  6362. The _getcwd function returns pathbuf.  If an error occurs, _getcwd returns NULL 
  6363. and sets errno to one of the following values: 
  6364.  
  6365. Value       Meaning 
  6366. ENOMEM      Not enough storage space available to reserve n bytes (when NULL 
  6367.             argument is pathbuf). 
  6368. ERANGE      The path name is longer than n characters. 
  6369. EOS2ERR     An OS/2 call failed. Use _doserrno to obtain more information about 
  6370.             the return code. 
  6371.  
  6372. Example of _getcwd 
  6373.  
  6374. Related Information 
  6375.  
  6376. o _chdir - Change Current Working Directory 
  6377. o _chdrive - Change Current Working Drive 
  6378. o free  - Release Storage Blocks 
  6379. o _fullpath - Get Full Path Name of Partial Path 
  6380. o _getdcwd - Get Full Path Name of Current Directory 
  6381. o _getdrive - Get Current Working Drive 
  6382. o malloc  - Reserve Storage Block 
  6383. o _mkdir - Create New Directory 
  6384. o _rmdir - Remove Directory 
  6385. o direct.h 
  6386.  
  6387.  
  6388. ΓòÉΓòÉΓòÉ 2.110. _getdcwd - Get Full Path Name of Current Directory ΓòÉΓòÉΓòÉ
  6389.  
  6390. #include <direct.h>
  6391.  
  6392. char *_getdcwd(int drive, char *pathbuf, int n);
  6393.  
  6394. Language Level: Extension 
  6395.  
  6396. Description 
  6397.  
  6398. The _getdcwd function gets the full path name for the current directory of the 
  6399. specified drive, and stores it in the location pointed to by pathbuf. The drive 
  6400. argument is an integer value representing the drive (A: is 1, B: is 2, and so 
  6401. on). 
  6402.  
  6403. The integer argument n specifies the maximum length for the path name. An error 
  6404. occurs if the length of the path name, including the terminating null 
  6405. character, exceeds n characters. 
  6406.  
  6407. If the pathbuf argument is NULL, _getdcwd uses malloc to reserve a buffer of at 
  6408. least n bytes to store the path name.  If the current working directory string 
  6409. is more than n bytes, a large enough buffer will be allocated to contain the 
  6410. string. You can later free this buffer using the _getdcwd return value as the 
  6411. argument to free. 
  6412.  
  6413. An alternative to this function are the DosQueryCurrentDir and 
  6414. DosQueryCurrentDisk API calls. 
  6415.  
  6416. The _getdcwd function returns pathbuf.  If an error occurs, _getdcwd returns 
  6417. NULL and sets errno to one of the following values: 
  6418.  
  6419. Value          Meaning 
  6420. ENOMEM         Not enough storage space available to reserve n bytes (when NULL 
  6421.                argument is pathbuf). 
  6422. ERANGE         The path name is longer than n characters. 
  6423. EOS2ERR        An OS/2 call failed. Use _doserrno to obtain more information 
  6424.                about the return code. 
  6425.  
  6426. Example of _getdcwd 
  6427.  
  6428. Related Information 
  6429.  
  6430. o _chdir - Change Current Working Directory 
  6431. o _chdrive - Change Current Working Drive 
  6432. o free  - Release Storage Blocks 
  6433. o _fullpath - Get Full Path Name of Partial Path 
  6434. o _getcwd - Get Path Name of Current Directory 
  6435. o _getdrive - Get Current Working Drive 
  6436. o malloc  - Reserve Storage Block 
  6437. o _mkdir - Create New Directory 
  6438. o _rmdir - Remove Directory 
  6439. o direct.h 
  6440.  
  6441.  
  6442. ΓòÉΓòÉΓòÉ 2.111. _getdrive - Get Current Working Drive ΓòÉΓòÉΓòÉ
  6443.  
  6444. #include <direct.h>
  6445.  
  6446. int _getdrive(void);
  6447.  
  6448. Language Level: Extension 
  6449.  
  6450. Description 
  6451.  
  6452. Gets the drive number for the current working drive. 
  6453.  
  6454. The _getdrive function returns an integer corresponding to alphabetical 
  6455. position of the letter representing the current working drive. For example, A: 
  6456. is 1, B: is 2, J: is 10, and so on. 
  6457.  
  6458. An alternative to this function is the DosQueryCurrentDisk API call. 
  6459.  
  6460. Example of _getdrive 
  6461.  
  6462. Related Information 
  6463.  
  6464. o _chdir - Change Current Working Directory 
  6465. o _chdrive - Change Current Working Drive 
  6466. o _getcwd - Get Path Name of Current Directory 
  6467. o _getdcwd - Get Full Path Name of Current Directory 
  6468. o direct.h 
  6469.  
  6470.  
  6471. ΓòÉΓòÉΓòÉ 2.112. getenv  - Search for Environment Variables ΓòÉΓòÉΓòÉ
  6472.  
  6473. #include <stdlib.h>
  6474.  
  6475. char *getenv(const char *varname);
  6476.  
  6477. Language Level: ANSI, SAA 
  6478.  
  6479. Description 
  6480.  
  6481. The getenv function searches the list of environment variables for an entry 
  6482. corresponding to varname. 
  6483.  
  6484. The getenv function returns a pointer to the environment table entry containing 
  6485. the current string value of varname.  The return value is NULL if the given 
  6486. variable is not currently defined or if the system does not support environment 
  6487. variables. 
  6488.  
  6489. You should copy the string that is returned because it may be written over by a 
  6490. subsequent call to getenv. 
  6491.  
  6492. Example of getenv 
  6493.  
  6494. Related Information 
  6495.  
  6496. o _putenv - Modify Environment Variables 
  6497. o envp Parameter to main 
  6498. o stdlib.h 
  6499.  
  6500.  
  6501. ΓòÉΓòÉΓòÉ 2.113. _getpid - Get Process Identifier ΓòÉΓòÉΓòÉ
  6502.  
  6503. #include <process.h>
  6504.  
  6505. int _getpid(void);
  6506.  
  6507. Language Level: Extension 
  6508.  
  6509. Description 
  6510.  
  6511. The _getpid function gets the process identifier that uniquely identifies the 
  6512. calling process. 
  6513.  
  6514. An alternative to this function is the DosGetInfoBlocks API call. 
  6515.  
  6516. The _getpid function returns the process identifier as an integer value.  There 
  6517. is no error return value. 
  6518.  
  6519. Example of _getpid 
  6520.  
  6521. Related Information 
  6522.  
  6523. o _cwait - Wait for Child Process 
  6524. o _execl - _execvp - Load and Run Child Process 
  6525. o _spawnl - _spawnvpe - Start and Run Child Processes 
  6526. o _wait - Wait for Child Process 
  6527. o process.h 
  6528.  
  6529.  
  6530. ΓòÉΓòÉΓòÉ 2.114. gets  - Read a Line ΓòÉΓòÉΓòÉ
  6531.  
  6532. #include <stdio.h>
  6533.  
  6534. char *gets(char *buffer);
  6535.  
  6536. Language Level: ANSI, SAA 
  6537.  
  6538. Description 
  6539.  
  6540. The gets function reads a line from the standard input stream stdin and stores 
  6541. it in buffer.  The line consists of all characters up to and including the 
  6542. first newline character (\n) or EOF. The gets function then replaces the 
  6543. newline character, if read with a null character (\0), before returning the 
  6544. line. 
  6545.  
  6546. If successful, the gets function returns its argument.  A NULL pointer return 
  6547. value indicates an error or an end-of-file condition with no characters read. 
  6548. Use ferror or feof to determine which of these conditions occurred. If there 
  6549. was an error, the value stored in buffer is undefined.  If an end-of-file 
  6550. condition occurred, buffer is not changed. 
  6551.  
  6552. Example of gets 
  6553.  
  6554. Related Information 
  6555.  
  6556. o fgets  - Read a String 
  6557. o feof  - Test End-of-File Indicator 
  6558. o ferror  - Test for Read/Write Errors 
  6559. o fputs  - Print Strings 
  6560. o getc - getchar  - Read a Character 
  6561. o puts  - Write a String 
  6562. o stdio.h 
  6563.  
  6564.  
  6565. ΓòÉΓòÉΓòÉ 2.115. _getTIBvalue - Get TIB Value ΓòÉΓòÉΓòÉ
  6566.  
  6567. #include <builtin.h>
  6568.  
  6569. unsigned long _getTIBvalue( const unsigned int offset );
  6570.  
  6571. Language Level: Extension 
  6572.  
  6573. Description 
  6574.  
  6575. The _getTIBvalue function retrieves an unsigned long value from the Thread 
  6576. Information Block (TIB) at the offset specified. The selector value for the TIB 
  6577. belonging to the current thread of execution is stored in the FS segment 
  6578. register. You should use the offsetof macro to calculate offset. 
  6579.  
  6580. Because it is a built-in function and has no backing code in the library: 
  6581.  
  6582. o You cannot take the address of _getTIBvalue. 
  6583. o You cannot parenthesize a _getTIBvalue function call, because parentheses 
  6584.   specify a call to the backing code for the function in the library, and 
  6585.   _getTIBvalue has no backing code. 
  6586.  
  6587. This function returns an unsigned long value.  There is no error return value 
  6588. and this function does not set errno.  If offset is too large, it will cause an 
  6589. access violation when running the program. 
  6590.  
  6591. Example of _getTIBvalue 
  6592.  
  6593. Related Information 
  6594.  
  6595.  
  6596. ΓòÉΓòÉΓòÉ 2.116. gmtime  - Convert Time ΓòÉΓòÉΓòÉ
  6597.  
  6598. #include <time.h>
  6599.  
  6600. struct tm *gmtime(const time_t *time);
  6601.  
  6602. Language Level: ANSI, SAA 
  6603.  
  6604. Description 
  6605.  
  6606. The gmtime function converts a time value to a struct tm.  The value time is 
  6607. usually obtained from a call to time. 
  6608.  
  6609. The gmtime function breaks down the time value and stores it in a tm structure, 
  6610. defined in time.h.  The structure pointed to by the return value reflects 
  6611. Coordinated Universal Time (UTC), not local time. 
  6612.  
  6613. The fields of the tm structure include: 
  6614.  
  6615. Field            Value Stored 
  6616. tm_sec           Seconds (0-61) 
  6617. tm_min           Minutes (0-59) 
  6618. tm_hour          Hours (0-23) 
  6619. tm_mday          Day of month (1-31) 
  6620. tm_mon           Month (0-11;  January = 0) 
  6621. tm_year          Year (current year minus 1900) 
  6622. tm_wday          Day of week (0-6;  Sunday = 0) 
  6623. tm_yday          Day of year (0-365;  January 1 = 0) 
  6624. tm_isdst         Zero if Daylight Saving Time is not in effect;  positive if 
  6625.                  Daylight Saving Time is in effect;  negative if the 
  6626.                  information is not available. 
  6627.  
  6628. The gmtime function returns a pointer to the structure result.  The gmtime 
  6629. function returns NULL if Coordinated Universal Time is not available. 
  6630.  
  6631. Note:  The gmtime and localtime functions may use a common, statically 
  6632.        allocated buffer for the conversion.  Each call to one of these 
  6633.        functions may alter the result of the previous call. 
  6634.  
  6635. Note:  The time and date functions begin at 00:00:00 UTC, January 1, 1970. 
  6636. :enote. 
  6637.  
  6638. Example of gmtime 
  6639.  
  6640. Related Information 
  6641.  
  6642. o asctime  - Convert Time 
  6643. o ctime  - Convert Time 
  6644. o localtime  - Convert Time 
  6645. o time  - Determine Current Time 
  6646. o time.h 
  6647.  
  6648.  
  6649. ΓòÉΓòÉΓòÉ 2.116.1. _heap_check - Validate Run-Time Storage Heap ΓòÉΓòÉΓòÉ
  6650.  
  6651. #define __DEBUG_ALLOC__
  6652. #include <stdlib.h>
  6653.  
  6654. void *_heap_check(void);
  6655.  
  6656. Description 
  6657.  
  6658. The _heap_check function checks all memory blocks allocated or freed by the 
  6659. debug memory management functions to make sure that overwriting has not 
  6660. occurred outside the bounds of allocated blocks and that free memory blocks 
  6661. have not been overwritten. 
  6662.  
  6663. The _heap_check function is automatically called whenever a debug function is 
  6664. called.  You can also explicitly call _heap_check. 
  6665.  
  6666. There is no return value. 
  6667.  
  6668. For an explanation of how to interpret the output from _heap_check, see Sample 
  6669. _heap_check Output. 
  6670.  
  6671. Language Level Extension, Migration (in <malloc.h>) 
  6672.  
  6673. Example of _heap_check 
  6674.  
  6675. Related Information 
  6676.  
  6677. o _debug_calloc - Reserve and Initialize Storage 
  6678. o _debug_free - Release Storage Blocks 
  6679. o _debug_malloc - Reserve Storage Blocks 
  6680. o _debug_realloc - Change Reserved Storage Block Size 
  6681. o _dump_allocated - Get Information about Allocated Storage 
  6682. o Using the Debug Memory Management Functions 
  6683. o malloc.h 
  6684. o stdlib.h 
  6685.  
  6686.  
  6687. ΓòÉΓòÉΓòÉ 2.116.1.1. Sample _heap_check Output ΓòÉΓòÉΓòÉ
  6688.  
  6689. This section shows several examples of output from the _heap_check function. 
  6690.  
  6691. Example 1 
  6692.  
  6693. An internal data structure starting at address 0x00120000 was overwritten.
  6694.  
  6695. An internal data structure that is allocated from a separate page of memory has 
  6696. been overwritten. The program is incorrectly writing to an area of memory at 
  6697. approximately the address given. 
  6698.  
  6699. Example 2 
  6700.  
  6701. The invalid memory block address 0x00130000 was passed in at line 101 of SAMPPROG.C.
  6702.  
  6703. The free or realloc function was passed a pointer that did not point to a 
  6704. memory block allocated by malloc, calloc, or realloc. The line number and file 
  6705. name are given to determine which function was called and where the address 
  6706. came from. 
  6707.  
  6708. Example 3 
  6709.  
  6710. Memory was overwritten before the allocated memory block which starts
  6711.       at address 0x00110FD0.
  6712. The first eight bytes of the memory block (in hex) are: 4445414442454546.
  6713. This memory block was (re)allocated at line number 81 in SAMPPROG.C.
  6714.  
  6715. Memory just before the allocated memory block, which starts at address 
  6716. 0x00110FD0, has been overwritten.  The file name and line number tell where the 
  6717. memory block was allocated and are given to determine what the block is being 
  6718. used for. The first 8 bytes of the memory block are printed to help determine 
  6719. the block's use. 
  6720.  
  6721. Example 4 
  6722.  
  6723. Memory was overwritten before the allocated memory block which starts
  6724.       at address 0x00110FD0.
  6725. The first eight bytes of the memory block (in hex) are: 4445414442454546.
  6726. The file name and line number are not available.
  6727.  
  6728. Memory just before the allocated memory block, which starts at address 
  6729. 0x00110FD0, has been overwritten. The first 8 bytes of the memory block are 
  6730. printed to help determine what the block is being used for. The file name and 
  6731. line number are not available because too much memory was overwritten. 
  6732.  
  6733. Example 5 
  6734.  
  6735. Memory was overwritten after the allocated memory block which starts
  6736.       at address 0x00110FD0.
  6737. The first eight bytes of the memory block (in hex) are: 6161616161616161.
  6738. This memory block was (re)allocated at line number 81 in SAMPPROG.C.
  6739.  
  6740. Memory after the allocated memory block, which starts at address 0x00110FD0, 
  6741. has been overwritten.  The file name and line number where this memory block 
  6742. was allocated are given to help you determine the size of the block and what it 
  6743. is used for. The first 8 bytes of the memory block are also printed to help 
  6744. determine what the block is used for. 
  6745.  
  6746. Example 6 
  6747.  
  6748. The free memory block which starts at address 0x00110FD0 has been accessed.
  6749. The first eight bytes of the memory block (in hex) are: 6161616142454546.
  6750. This memory block was freed at line number 141 in SAMPPROG.C.
  6751.  
  6752. The memory block that starts at address 0x00110FD0 and that has been freed has 
  6753. been overwritten. The line number and file name given is where the call to free 
  6754. or realloc freed the memory block.  The first 8 bytes of the memory block are 
  6755. printed to help determine what was written to the free memory block. 
  6756.  
  6757. Example 7 
  6758.  
  6759. Memory was overwritten before the free memory block which starts
  6760.       at address 0x00110FD0.
  6761. The first eight bytes of the memory block (in hex) are: B5B5A5A542454546.
  6762. This memory block was freed at line number 150 in SAMPPROG.C.
  6763.  
  6764. Memory immediately before a freed memory block has been overwritten.  The line 
  6765. number and file name where the memory block was freed are given to help 
  6766. determine what this block was used for before it was freed.  The first 8 bytes 
  6767. of the memory block are also printed to help determine what the freed memory 
  6768. was used for before it was freed. 
  6769.  
  6770. Example 8 
  6771.  
  6772. Memory was overwritten before the free memory block which starts
  6773.       at address 0x00110FD0.
  6774. The first eight bytes of the memory block (in hex) are: B5B5A5A542454546.
  6775. The file name and line number are not available.
  6776.  
  6777. Memory immediately before a freed memory block has been overwritten.  The line 
  6778. number and file name of where this memory block was freed cannot be printed 
  6779. because this information may have been overwritten.  The first 8 bytes of the 
  6780. memory block are printed to help determine what the freed memory was used for 
  6781. before it was freed. 
  6782.  
  6783. Example 9 
  6784.  
  6785. Memory was overwritten at the end of the free memory block which starts
  6786.       at address 0x00110FD0.
  6787. The first eight bytes of the memory block (in hex) are: B5B5A5A542454546.
  6788. This memory block was freed at line number 170 in SAMPPROG.C.
  6789.  
  6790. Memory at the end of a freed memory block starting at the given address has 
  6791. been overwritten.  The line number and file name of where this block was freed 
  6792. are given to help determine what the block was used for before it was freed. 
  6793. The first 8 bytes of the memory block are printed also to help determine what 
  6794. the block was used for before it was freed. 
  6795.  
  6796. Related Information 
  6797.  
  6798. o _debug_calloc - Reserve and Initialize Storage 
  6799. o _debug_free - Release Storage Blocks 
  6800. o _debug_malloc - Reserve Storage Blocks 
  6801. o _debug_heapmin - Release Unused Memory in the Heap 
  6802. o _debug_realloc - Change Reserved Storage Block Size 
  6803. o _dump_allocated - Get Information about Allocated Storage 
  6804. o _heap_check - Validate Run-Time Storage Heap 
  6805. o Using the Debug Memory Management Functions 
  6806. o malloc.h 
  6807. o stdlib.h 
  6808.  
  6809.  
  6810. ΓòÉΓòÉΓòÉ 2.117. _heapmin - Release Unused Memory in the Heap ΓòÉΓòÉΓòÉ
  6811.  
  6812. #include <stdlib.h>  /* also defined in <malloc.h> */
  6813.  
  6814. int _heapmin(void);
  6815.  
  6816. Language Level: Extension 
  6817.  
  6818. Description 
  6819.  
  6820. The _heapmin function returns all unused memory from the run-time heap to the 
  6821. operating system. 
  6822.  
  6823. If successful, _heapmin returns 0; if not, it returns -1. 
  6824.  
  6825. Example of _heapmin 
  6826.  
  6827. Related Information 
  6828.  
  6829. o _debug_heapmin - Release Unused Memory in the Heap 
  6830. o malloc.h 
  6831. o stdlib.h 
  6832.  
  6833.  
  6834. ΓòÉΓòÉΓòÉ 2.118. hypot  - Calculate Hypotenuse ΓòÉΓòÉΓòÉ
  6835.  
  6836. #include <math.h> /* SAA extension to ANSI */
  6837.  
  6838. double hypot(double side1, double side2);
  6839.  
  6840. Language Level: SAA 
  6841.  
  6842. Description 
  6843.  
  6844. The hypot function calculates the length of the hypotenuse of a right-angled 
  6845. triangle based on the lengths of two sides side1 and side2.  A call to hypot is 
  6846. equal to: 
  6847.  
  6848. sqrt(side1 * side1 + side2 * side2); 
  6849.  
  6850. The hypot function returns the length of the hypotenuse.  If an overflow 
  6851. results, the function sets errno to ERANGE and returns the value HUGE_VAL. 
  6852.  
  6853. Example of hypot 
  6854.  
  6855. Related Information 
  6856.  
  6857. o sqrt  - Calculate Square Root 
  6858. o math.h 
  6859.  
  6860.  
  6861. ΓòÉΓòÉΓòÉ 2.119. _inp - Read Byte from Input Port ΓòÉΓòÉΓòÉ
  6862.  
  6863. #include <conio.h>
  6864.      OR
  6865. #include <builtin.h>
  6866.  
  6867. int _inp( const unsigned int port );
  6868.  
  6869. Language Level: Extension 
  6870.  
  6871. Description 
  6872.  
  6873. The _inp function reads a byte from the specified input port. The port number 
  6874. must be an unsigned int value in the range 0 to 65,535 inclusive. 
  6875.  
  6876. Because it is a built-in function and has no backing code in the library: 
  6877.  
  6878. o You cannot take the address of _inp. 
  6879. o You cannot parenthesize an _inp function call, because parentheses specify a 
  6880.   call to the backing code for the function in the library, and _inp has no 
  6881.   backing code. 
  6882.  
  6883. You can run code containing this function only at ring zero. Otherwise, an 
  6884. invalid instruction exception will be received. 
  6885.  
  6886. This function returns the byte value as an integer that was read from the 
  6887. specified port. There is no error return value and this function does not set 
  6888. errno. 
  6889.  
  6890. Example of _inp 
  6891.  
  6892. Related Information 
  6893.  
  6894. o _inpw - Read Unsigned Short from Input Port 
  6895. o _inpd - Read Double Word from Input Port 
  6896. o _outp - Write Byte to Output Port 
  6897. o _outpw - Write Word to Output Port 
  6898. o _outpd - Write Double Word to Output Port 
  6899.  
  6900.  
  6901. ΓòÉΓòÉΓòÉ 2.120. _inpd - Read Double Word from Input Port ΓòÉΓòÉΓòÉ
  6902.  
  6903. #include <conio.h>
  6904.      OR
  6905. #include <builtin.h>
  6906.  
  6907. unsigned int _inpd( const unsigned short port );
  6908.  
  6909. Description 
  6910.  
  6911. The _inpd function reads a 4-byte (double word) unsigned value from the 
  6912. specified input port. The port number must be an unsigned short value within 
  6913. the range 0 to 65,535 inclusive. 
  6914.  
  6915. Because it is a built-in function and has no backing code in the library: 
  6916.  
  6917. o You cannot take the address of _inpd. 
  6918. o You cannot parenthesize an _inpd function call, because parentheses specify a 
  6919.   call to the backing code for the function in the library, and _inpd has no 
  6920.   backing code. 
  6921.  
  6922. You can run code containing this function only at ring zero. Otherwise, an 
  6923. invalid instruction exception will be received. 
  6924.  
  6925. This function returns the unsigned integer value that was read from the 
  6926. specified port. There is no error return value and this function does not set 
  6927. errno. 
  6928.  
  6929. Example of _inpd 
  6930.  
  6931. Related Information 
  6932.  
  6933. o _inp - Read Byte from Input Port 
  6934. o _inpw - Read Unsigned Short from Input Port 
  6935. o _outp - Write Byte to Output Port 
  6936. o _outpw - Write Word to Output Port 
  6937. o _outpd - Write Double Word to Output Port 
  6938.  
  6939.  
  6940. ΓòÉΓòÉΓòÉ 2.121. _inpw - Read Unsigned Short from Input Port ΓòÉΓòÉΓòÉ
  6941.  
  6942. #include <conio.h>
  6943.      OR
  6944. #include <builtin.h>
  6945.  
  6946. unsigned short _inpw( const unsigned short port );
  6947. Language Level: Extension 
  6948.  
  6949. Description 
  6950.  
  6951. The _inpw function reads an unsigned short value from the specified input port. 
  6952. The port number must be an unsigned short value within the range 0 to 65,535 
  6953. inclusive. 
  6954.  
  6955. Because it is a built-in function and has no backing code in the library: 
  6956.  
  6957. o You cannot take the address of _inpw. 
  6958. o You cannot parenthesize an _inpw function call, because parentheses specify a 
  6959.   call to the backing code for the function in the library, and _inpw has no 
  6960.   backing code. 
  6961.  
  6962. You can run code containing this function only at ring zero. Otherwise, an 
  6963. invalid instruction exception will be received. 
  6964.  
  6965. This function returns the unsigned short value that was read from the specified 
  6966. port. There is no error return value and this function does not set errno. 
  6967.  
  6968. Example of _inpw 
  6969.  
  6970. Related Information 
  6971.  
  6972. o _inp - Read Byte from Input Port 
  6973. o _inpd - Read Double Word from Input Port 
  6974. o _outp - Write Byte to Output Port 
  6975. o _outpw - Write Word to Output Port 
  6976. o _outpd - Write Double Word to Output Port 
  6977. o builtin.h 
  6978. o conio.h 
  6979.  
  6980.  
  6981. ΓòÉΓòÉΓòÉ 2.122. _interrupt - Call Interrupt  Procedure ΓòÉΓòÉΓòÉ
  6982.  
  6983. #include <builtin.h>
  6984.  
  6985. void _interrupt( const unsigned int intnum );
  6986.  
  6987. Description 
  6988.  
  6989. The _interrupt function calls the interrupt procedure specified by intnum using 
  6990. the INT machine instruction. The integer intnum must have a value within the 
  6991. range 0 to 255 inclusive. 
  6992.  
  6993. Because it is a built-in function and has no backing code in the library: 
  6994.  
  6995. o You cannot take the address of _interrupt. 
  6996. o You cannot parenthesize an _interrupt function call, because parentheses 
  6997.   specify a call to the backing code for the function in the library. 
  6998.  
  6999. This function has no return value and it does not set errno. 
  7000.  
  7001. Example of _interrupt 
  7002.  
  7003. Related Information 
  7004.  
  7005. o _disable - Disable Interrupts 
  7006. o _enable - Enable Interrupts 
  7007.  
  7008.  
  7009. ΓòÉΓòÉΓòÉ 2.123. isalnum to isxdigit  - Test Integer Value ΓòÉΓòÉΓòÉ
  7010.  
  7011. #include <ctype.h>
  7012.  
  7013. int isalnum(int c);
  7014.          /* Test for upper- or lowercase letters, or decimal digit */
  7015. int isalpha(int c);
  7016.          /* Test for alphabetic character */
  7017. int iscntrl(int c);
  7018.          /* Test for any control character */
  7019. int isdigit(int c);
  7020.          /* Test for decimal digit */
  7021. int isgraph(int c);
  7022.          /* Test for printable character excluding space */
  7023. int islower(int c);
  7024.          /* Test for lowercase */
  7025. int isprint(int c);
  7026.          /* Test for printable character including space */
  7027. int ispunct(int c);
  7028.          /* Test for any nonalphanumeric printable character excluding space */
  7029. int isspace(int c);
  7030.          /* Test for whitespace character */
  7031. int isupper(int c);
  7032.          /* Test for uppercase */
  7033. int isxdigit(int c);
  7034.          /* Test for hexadecimal digit */
  7035.  
  7036. Language Level: ANSI, SAA 
  7037.  
  7038. Description 
  7039.  
  7040. The ctype.h functions listed test a given integer value.  They return a nonzero 
  7041. value if the integer satisfies the test condition, or a zero value if it does 
  7042. not. 
  7043.  
  7044. c must be representable as an unsigned char. 
  7045.  
  7046. Note:  EOF is a valid input value. 
  7047.  
  7048. Example of isalnum 
  7049.  
  7050. Related Information 
  7051.  
  7052. o isascii - Test Integer Values 
  7053. o _iscsym - _iscsymf - Test Integer 
  7054. o tolower - toupper  - Convert Character Case 
  7055. o toascii - _tolower - _toupper - Convert Character 
  7056. o ctype.h 
  7057.  
  7058.  
  7059. ΓòÉΓòÉΓòÉ 2.124. isascii - Test Integer Values ΓòÉΓòÉΓòÉ
  7060.  
  7061. #include <ctype.h>
  7062.  
  7063. int isascii(int c);
  7064.  
  7065. Description 
  7066.  
  7067. The isascii macro tests if an integer is within the ASCII range.  This macro 
  7068. assumes that the system uses the ASCII character set. 
  7069.  
  7070. The isascii macro returns a nonzero value if the integer is within the ASCII 
  7071. set, and 0 otherwise. 
  7072.  
  7073. Language Level: Extension 
  7074.  
  7075. Example of isascii 
  7076.  
  7077. Related Information 
  7078.  
  7079. o isalnum to isxdigit  - Test Integer Value 
  7080. o _iscsym - _iscsymf - Test Integer 
  7081. o toascii - _tolower - _toupper - Convert Character 
  7082. o tolower - toupper  - Convert Character Case 
  7083. o ctype.h 
  7084.  
  7085.  
  7086. ΓòÉΓòÉΓòÉ 2.125. _isatty - Test Handle for Character Device ΓòÉΓòÉΓòÉ
  7087.  
  7088. #include <io.h>
  7089.  
  7090. int _isatty(int handle);
  7091.  
  7092. Language Level: Extension 
  7093.  
  7094. Description 
  7095.  
  7096. The _isatty function determines whether the given handle is associated with a 
  7097. character device (a keyboard, display, printer or serial port). 
  7098.  
  7099. The _isatty function returns a nonzero value if the device is a character 
  7100. device. Otherwise, the return value is 0. 
  7101.  
  7102. Example of _isatty 
  7103.  
  7104. Related Information 
  7105.  
  7106. o io.h 
  7107.  
  7108.  
  7109. ΓòÉΓòÉΓòÉ 2.126. _iscsym - _iscsymf - Test Integer ΓòÉΓòÉΓòÉ
  7110.  
  7111. #include <ctype.h>
  7112.  
  7113. int _iscsym(int c);
  7114.  
  7115. int _iscsymf(int c);
  7116.  
  7117. Language Level: Extension 
  7118.  
  7119. Description 
  7120.  
  7121. These macros test if an integer is within a particular ASCII set. The macros 
  7122. assume that the system uses the ASCII character set. 
  7123.  
  7124. The _iscsymf macro tests if a character is alphabetic or an underscore (_). The 
  7125. _iscsym macro tests if a character is alphabetic, a digit, or an underscore. 
  7126.  
  7127. The _iscsym and _iscsymf macros return a nonzero value if the integer is within 
  7128. the ASCII set for which it tests, and 0 otherwise. 
  7129.  
  7130. Example of _iscsym - _iscsymf 
  7131.  
  7132. Related Information 
  7133.  
  7134. o isalnum to isxdigit  - Test Integer Value 
  7135. o isascii - Test Integer Values 
  7136. o ctype.h 
  7137.  
  7138.  
  7139. ΓòÉΓòÉΓòÉ 2.127. _itoa - Convert Integer to String ΓòÉΓòÉΓòÉ
  7140.  
  7141. #include <stdlib.h>
  7142.  
  7143. char *_itoa(int value, char * string, int radix);
  7144.  
  7145. Language Level: Extension 
  7146.  
  7147. Description 
  7148.  
  7149. The _itoa function converts the digits of the given value to a character string 
  7150. that ends with a null character and stores the result in string. The radix 
  7151. argument specifies the base of value; it must be in the range 2 to 36. If radix 
  7152. equals 10 and value is negative, the first character of the stored string is 
  7153. the minus sign (-). 
  7154.  
  7155. Note:  The space reserved for string must be large enough to hold the returned 
  7156. string. The function can return up to 33 bytes including the null character 
  7157. (\0). 
  7158.  
  7159. The _itoa function returns a pointer to string. There is no error return value. 
  7160.  
  7161. Example of _itoa 
  7162.  
  7163. Related Information 
  7164.  
  7165. o atoi  - Convert Character Strings 
  7166. o _ltoa - Convert Long Integer to String 
  7167. o _ultoa - Convert Unsigned Long Integer to Str         ing 
  7168. o stdlib.h 
  7169.  
  7170.  
  7171. ΓòÉΓòÉΓòÉ 2.128. _kbhit - Test for Keystroke ΓòÉΓòÉΓòÉ
  7172.  
  7173. include <conio.h>
  7174.  
  7175. int _kbhit(void);
  7176.  
  7177. Language Level: Extension 
  7178.  
  7179. Description 
  7180.  
  7181. The _kbhit function tests if a key has been pressed on the keyboard.  If the 
  7182. result is nonzero, a keystroke is waiting in the buffer.  You can get the 
  7183. keystroke using the _getch or _getche function.  If you call _getch or _getche 
  7184. without first calling _kbhit, the program waits for a key to be pressed. 
  7185.  
  7186. The _kbhit function returns a nonzero value if a key has been pressed. 
  7187. Otherwise, it returns 0. 
  7188.  
  7189. Example of _kbhit 
  7190.  
  7191. Related Information 
  7192.  
  7193. o _getch - _getche - Read Character from Keyboard 
  7194. o conio.h 
  7195.  
  7196.  
  7197. ΓòÉΓòÉΓòÉ 2.129. labs  - long Absolute Value ΓòÉΓòÉΓòÉ
  7198.  
  7199. #include <stdlib.h>
  7200.  
  7201. long int labs(long int n);
  7202.  
  7203. Language Level: ANSI, SAA 
  7204.  
  7205. Description 
  7206.  
  7207. The labs function produces the absolute value of its long integer argument n. 
  7208. There is no error-return value. 
  7209.  
  7210. The result may be undefined when the argument is equal to LONG_MIN, the 
  7211. smallest available long integer (-2 147 483 648). The value LONG_MIN in defined 
  7212. in the <limits.h> include file. 
  7213.  
  7214. Example of labs 
  7215.  
  7216. Related Information 
  7217.  
  7218. o abs  - Integer Absolute Value 
  7219. o cabs - Absolute Value of Complex Number 
  7220. o fabs  - Floating-Point Absolute Value 
  7221. o limits.h 
  7222.  
  7223.  
  7224. ΓòÉΓòÉΓòÉ 2.130. ldexp  - Multiply by a Power of Two ΓòÉΓòÉΓòÉ
  7225.  
  7226. #include <math.h>
  7227.  
  7228. double ldexp(double x, int exp);
  7229.  
  7230. Language Level: ANSI, SAA 
  7231.  
  7232. Description 
  7233.  
  7234. The ldexp function returns the value of x * (2**exp). If an overflow results, 
  7235. the function returns +HUGE_VAL for a large result or -HUGE_VAL for a small 
  7236. result, and sets errno to ERANGE. 
  7237.  
  7238. Example of ldexp 
  7239.  
  7240. Related Information 
  7241.  
  7242. o frexp  - Separate Floating-Point Value 
  7243. o modf  - Separate Floating-Point Value 
  7244. o math.h 
  7245.  
  7246.  
  7247. ΓòÉΓòÉΓòÉ 2.131. ldiv  - Long Division ΓòÉΓòÉΓòÉ
  7248.  
  7249. #include <stdlib.h>
  7250.  
  7251. ldiv_t ldiv(long int numerator, long int denominator);
  7252.  
  7253. Language Level: ANSI, SAA 
  7254.  
  7255. Description 
  7256.  
  7257. The ldiv function calculates the quotient and remainder of the division of 
  7258. numerator by denominator. 
  7259.  
  7260. The ldiv function returns a structure of type ldiv_t, containing both the 
  7261. quotient long int quot and the remainder long int rem.  If the value cannot be 
  7262. represented, the return value is undefined. If denominator is 0, an exception 
  7263. will be raised. 
  7264.  
  7265. Example of ldiv 
  7266.  
  7267. Related Information 
  7268.  
  7269. o div  - Quotient and Remainder 
  7270. o stdlib.h 
  7271.  
  7272.  
  7273. ΓòÉΓòÉΓòÉ 2.132. _lfind - _lsearch - Find Key in Array ΓòÉΓòÉΓòÉ
  7274.  
  7275. #include <search.h>
  7276.  
  7277. char *_lsearch(char *search_key, char *base, unsigned int *num, unsigned int *width,
  7278.                     int (*)(const void *key, const void *compare));
  7279.  
  7280. char *_lfind(char *search_key, char *base, unsigned int *num, unsigned int *width,
  7281.                     int (*)(const void *key, const void *compare));
  7282.  
  7283. Language Level: Extension 
  7284.  
  7285. Description 
  7286.  
  7287. The _lsearch and _lfind functions perform a linear search for the value 
  7288. search_key in an array of num elements, each of width bytes in size.  Unlike 
  7289. bsearch, _lsearch and _lfind do no t require that you sort the array first. 
  7290. The argument base points to the base of the array to be searched. 
  7291.  
  7292. If _lsearch does not find the search_key, it adds the search_key to the end of 
  7293. the array and increments num by one.  If _lfind does not find the search_key, 
  7294. it does not add the search_key to the array. 
  7295.  
  7296. The argument compare is a pointer to a function that you supply.  This function 
  7297. compares the specified key with an array element and returns a value specifying 
  7298. their relationship.  Both _lsearch and _lfind call the compare function one or 
  7299. more times during the search, passing pointers to two array elements on each 
  7300. call. 
  7301.  
  7302. The compare argument is returned as one of the following values: 
  7303.  
  7304. Value          Meaning 
  7305. Nonzero        key and element are different. 
  7306. 0              key and element are identical. 
  7307.  
  7308. If the search_key is found, both _lsearch and _lfind return a pointer to that 
  7309. element of the array to which base points. If the search_key is not found, 
  7310. _lsearch returns a pointer to a newly added item at the end of the array, while 
  7311. _lfind returns NULL. 
  7312.  
  7313. Example of _lfind 
  7314.  
  7315. Related Information 
  7316.  
  7317. o bsearch  - Search Arrays 
  7318. o search.h 
  7319.  
  7320.  
  7321. ΓòÉΓòÉΓòÉ 2.133. _loadmod - Load User DLL ΓòÉΓòÉΓòÉ
  7322.  
  7323. #include <stdlib.h>
  7324.  
  7325. int _loadmod(char *module_name, unsigned long *module_handle);
  7326.  
  7327. Language Level: Extension 
  7328.  
  7329. Description 
  7330.  
  7331. The _loadmod function loads a user-created dynamic link library (DLL) for the 
  7332. calling process. The module_name is the name of the DLL to be loaded, and the 
  7333. module_handle is the file handle associated with the DLL. 
  7334.  
  7335. If the operation is successful, _loadmod returns the handle of the loaded DLL 
  7336. to the calling process.  The process can use this handle with the OS/2 API 
  7337. DosQueryProcAddr to get the address of the required function from within the 
  7338. DLL.  Once the reference is established, the calling process can then call the 
  7339. specific function. 
  7340.  
  7341. The return value of _loadmod is 0 if the DLL was successfully loaded.  If 
  7342. unsuccessful, _loadmod returns -1, and sets errno to one of the following 
  7343. values: 
  7344.  
  7345. Value             Meaning 
  7346. EMODNAME          The specified module_name is not valid. 
  7347. EOS2ERR           A system error occurred.  Check _doserrno for the specific 
  7348.                   OS/2 error code. 
  7349.  
  7350. Example of _loadmod 
  7351.  
  7352. Related Information 
  7353.  
  7354. o _freemod - Free User DLL 
  7355. o stdlib.h 
  7356.  
  7357.  
  7358. ΓòÉΓòÉΓòÉ 2.134. localeconv  - Query Locale Conventions ΓòÉΓòÉΓòÉ
  7359.  
  7360. #include <locale.h>
  7361.  
  7362. struct lconv *localeconv(void);
  7363.  
  7364. Language Level: ANSI, SAA 
  7365.  
  7366. Description 
  7367.  
  7368. The localeconv function sets the components of a structure having type struct 
  7369. lconv to values appropriate for the current locale.  The structure may be 
  7370. overwritten by another call to localeconv or by calling setlocale and passing 
  7371. LC_ALL, LC_MONETARY, or LC_NUMERIC. 
  7372.  
  7373. Defaults shown are for the C locale. The structure contains the following 
  7374. elements: 
  7375.  
  7376. ELEMENT                  PURPOSE OF ELEMENT           DEFAULT
  7377. "char *decimal_point"    Decimal-point character      "."
  7378.                          used to format nonmonetary
  7379.                          quantities.
  7380. "char *thousands_sep"    Character used to separate   ""
  7381.                          groups of digits to the
  7382.                          left of the decimal-point
  7383.                          character in formatted
  7384.                          nonmonetary quantities.
  7385. "char *grouping"         String indicating the size   ""
  7386.                          of each group of digits in
  7387.                          formatted nonmonetary
  7388.                          quantities.  The value of
  7389.                          each character in the
  7390.                          string determines the
  7391.                          number of digits in a
  7392.                          group.  A value of
  7393.                          "CHAR_MAX" indicates that
  7394.                          there are no further
  7395.                          groupings.  "0" indicates
  7396.                          that the previous element
  7397.                          is to be used for the
  7398.                          remainder of the digits.
  7399. "char                    International currency       ""
  7400. *int_curr_symbol"        symbol for the current
  7401.                          locale.  The first three
  7402.                          characters contain the
  7403.                          alphabetic international
  7404.                          currency symbol.  The
  7405.                          fourth character (usually
  7406.                          a space) is the character
  7407.                          used to separate the
  7408.                          international currency
  7409.                          symbol from the monetary
  7410.                          quantity.
  7411. "char                    Local currency symbol of     ""
  7412. *currency_symbol"        the current locale.
  7413. "char                    Separator for digits in      ""
  7414. *mon_thousands_sep"      formatted monetary quanti-
  7415.                          ties.
  7416. "char *mon_grouping"     String indicating the size   ""
  7417.                          of each group of digits in
  7418.                          formatted monetary quanti-
  7419.                          ties.  The value of each
  7420.                          character in the string
  7421.                          determines the number of
  7422.                          digits in a group.  A
  7423.                          value of "CHAR_MAX" indi-
  7424.                          cates that there are no
  7425.                          further groupings.  "0"
  7426.                          indicates that the pre-
  7427.                          vious element is to be
  7428.                          used for the remainder of
  7429.                          the digits.
  7430. "char *positive_sign"    String indicating the pos-   ""
  7431.                          itive sign used in mone-
  7432.                          tary quantities.
  7433. "char *negative_sign"    String indicating the neg-   ""
  7434.                          ative sign used in mone-
  7435.                          tary quantities.
  7436. "char int_frac_digits"   The number of displayed      "UCHAR_MAX"
  7437.                          digits to the right of the
  7438.                          decimal place for interna-
  7439.                          tionally formatted mone-
  7440.                          tary quantities.
  7441. "char frac_digits"       Number of digits to the      "UCHAR_MAX"
  7442.                          right of the decimal place
  7443.                          in monetary quantities.
  7444. "char p_cs_precedes"     1 if the "currency_symbol"   "UCHAR_MAX"
  7445.                          precedes the value for a
  7446.                          nonnegative formatted mon-
  7447.                          etary quantity;  0 if it
  7448.                          does not.
  7449. "char p_sep_by_space"    1 if the "currency_symbol"   "UCHAR_MAX"
  7450.                          is separated by a space
  7451.                          from the value of a non-
  7452.                          negative formatted mone-
  7453.                          tary quantity;  0 if it
  7454.                          does not.
  7455. "char n_cs_precedes"     1 if the "currency_symbol"   "UCHAR_MAX"
  7456.                          precedes the value for a
  7457.                          negative formatted mone-
  7458.                          tary quantity;  0 if it
  7459.                          does not.
  7460. "char n_sep_by_space"    1 if the "currency_symbol"   "UCHAR_MAX"
  7461.                          is separated by a space
  7462.                          from the value of a nega-
  7463.                          tive formatted monetary
  7464.                          quantity;  0 if it does
  7465.                          not.
  7466. "char p_sign_posn"       Value indicating the posi-   "UCHAR_MAX"
  7467.                          tion of the
  7468.                          "positive_sign" for a non-
  7469.                          negative formatted mone-
  7470.                          tary quantity.
  7471. "char n_sign_posn"       Value indicating the posi-   "UCHAR_MAX"
  7472.                          tion of the
  7473.                          "negative_sign" for a neg-
  7474.                          ative formatted monetary
  7475.                          quantity.
  7476.  
  7477. The n_sign_posn and p_sign_posn elements can have one of the following values: 
  7478.  
  7479.  0   The quantity and currency_symbol are enclosed in parentheses. 
  7480.  1   The sign precedes the quantity and currency_symbol. 
  7481.  2   The sign follows the quantity and currency_symbol. 
  7482.  3   The sign precedes the currency_symbol. 
  7483.  4   The sign follows the currency_symbol. 
  7484.  
  7485. Example of localeconv 
  7486.  
  7487. Related Information 
  7488.  
  7489. o setlocale  - Sets Locale 
  7490. o locale.h 
  7491.  
  7492.  
  7493. ΓòÉΓòÉΓòÉ 2.135. localtime  - Convert Time ΓòÉΓòÉΓòÉ
  7494.  
  7495. #include <time.h>
  7496.  
  7497. struct tm *localtime(const time_t *timeval);
  7498.  
  7499. Language Level: ANSI, SAA 
  7500.  
  7501. Description 
  7502.  
  7503. The localtime function converts a time value stored as a time_t value to a 
  7504. structure.  The time value is usually obtained by a call to the time function. 
  7505.  
  7506. The localtime function breaks down the timeval value, corrects for the local 
  7507. time zone and Daylight Saving Time, if appropriate, and stores the corrected 
  7508. time in a structure of type tm.  See gmtime for a description of the fields in 
  7509. a tm structure. 
  7510.  
  7511. The localtime function returns a pointer to the structure result.  There is no 
  7512. error return value. 
  7513.  
  7514. Note:  The gmtime and localtime functions may use a common, statically 
  7515.        allocated buffer for the conversion.  Each call to one of these 
  7516.        functions may alter the result of the previous call. 
  7517.  
  7518. Note:  The time and date functions begin at 00:00:00 Universal Time, January 1, 
  7519. 1970. :enote. 
  7520.  
  7521. Example of localtime 
  7522.  
  7523. Related Information 
  7524.  
  7525. o asctime  - Convert Time 
  7526. o ctime  - Convert Time 
  7527. o gmtime  - Convert Time 
  7528. o mktime  - Convert Local Time 
  7529. o time  - Determine Current Time 
  7530. o time.h 
  7531.  
  7532.  
  7533. ΓòÉΓòÉΓòÉ 2.136. log  - Calculate Natural Logarithm ΓòÉΓòÉΓòÉ
  7534.  
  7535. #include <math.h>
  7536.  
  7537. double log(double x);
  7538.  
  7539. Language Level: ANSI, SAA 
  7540.  
  7541. Description 
  7542.  
  7543. The log function calculates the natural logarithm (base e) of x. 
  7544.  
  7545. The log function returns the computed value.  If x is negative, it will set 
  7546. errno to EDOM and may return the value -HUGE_VAL. If x is zero, log returns the 
  7547. value -HUGE_VAL, and may set errno to ERANGE. 
  7548.  
  7549. Example of log 
  7550.  
  7551. Related Information 
  7552.  
  7553. o exp  - Exponential Function 
  7554. o log10  - Calculate Base 10 Logarithm 
  7555. o pow  - Compute Power 
  7556. o math.h 
  7557.  
  7558.  
  7559. ΓòÉΓòÉΓòÉ 2.137. log10  - Calculate Base 10 Logarithm ΓòÉΓòÉΓòÉ
  7560.  
  7561. #include <math.h>
  7562.  
  7563. double log10(double x);
  7564.  
  7565. Language Level: ANSI, SAA 
  7566.  
  7567. Description 
  7568.  
  7569. The log10 function calculates the base 10 logarithm of x. 
  7570.  
  7571. The log10 function returns the computed value.  If x is negative, it will set 
  7572. errno to EDOM and may return the value -HUGE_VAL. If x is zero, log10 returns 
  7573. the value -HUGE_VAL, and may set errno to ERANGE. 
  7574.  
  7575. Example of log10 
  7576.  
  7577. Related Information 
  7578.  
  7579. o exp  - Exponential Function 
  7580. o log  - Calculate Natural Logarithm 
  7581. o pow  - Compute Power 
  7582. o math.h 
  7583.  
  7584.  
  7585. ΓòÉΓòÉΓòÉ 2.138. longjmp  - Restore Stack Environment ΓòÉΓòÉΓòÉ
  7586.  
  7587. #include <setjmp.h>
  7588.  
  7589. void longjmp(jmp_buf env, int value);
  7590.  
  7591. Language Level: ANSI, SAA 
  7592.  
  7593. Description 
  7594.  
  7595. The longjmp function restores a stack environment previously saved in env by 
  7596. setjmp.  The setjmp and longjmp functions provide a way to perform a nonlocal 
  7597. goto. 
  7598.  
  7599. A call to setjmp causes the current stack environment to be saved in env.  A 
  7600. subsequent call to longjmp restores the saved environment and returns control 
  7601. to a point in the program corresponding to the setjmp call.  Execution resumes 
  7602. as if the setjmp call had just returned the given value.  All variables, 
  7603. (except register variables) that are accessible to the function that receives 
  7604. control contain the values they had when you called longjmp.  The values of 
  7605. register variables are unpredictable.  Nonvolatile auto variables that are 
  7606. changed between calls to setjmp and longjmp are also unpredictable. 
  7607.  
  7608. Note:  If you call the longjmp function, the function in which the 
  7609.        corresponding call to setjmp was made must not have returned first. 
  7610.        Calling longjmp after the function calling setjmp returns causes 
  7611.        unpredictable program behavior. 
  7612.  
  7613. The value argument passed to longjmp must be nonzero.  If you give a zero 
  7614. argument for value, longjmp substitutes a 1 in its place. 
  7615.  
  7616. The longjmp function does not use the normal function call and return 
  7617. mechanisms;  it has no return value. 
  7618.  
  7619. Example of longjmp 
  7620.  
  7621. Related Information 
  7622.  
  7623. o setjmp  - Preserve Environment 
  7624. o goto 
  7625. o volatile and const Attributes 
  7626. o auto Storage Class Specifier 
  7627. o setjmp.h 
  7628.  
  7629.  
  7630. ΓòÉΓòÉΓòÉ 2.139. _lrotl - _lrotr - Rotate Bits ΓòÉΓòÉΓòÉ
  7631.  
  7632. #include <stdlib.h>
  7633.  
  7634. unsigned long _lrotl(unsigned long value, int shift);
  7635.  
  7636. unsigned long _lrotr(unsigned long value, int shift);
  7637.  
  7638. Language Level: Extension 
  7639.  
  7640. Description 
  7641.  
  7642. These functions rotate value by shift bits. The _lrotl function rotates to the 
  7643. left, and _lrotr to the right. 
  7644.  
  7645. Both functions return the rotated value.  There is no error return. 
  7646.  
  7647. Example of _lrotl - _lrotr 
  7648.  
  7649. Related Information 
  7650.  
  7651. o _rotl - _rotr - Bit Rotation 
  7652. o stdlib.h 
  7653.  
  7654.  
  7655. ΓòÉΓòÉΓòÉ 2.140. _lseek - Move File Pointer ΓòÉΓòÉΓòÉ
  7656.  
  7657. #include <io.h>
  7658. #include <stdio.h>
  7659.  
  7660. long _lseek(int handle, long offset, int origin);
  7661.  
  7662. Language Level: Extension 
  7663.  
  7664. Description 
  7665.  
  7666. The _lseek function moves any file pointer associated with handle to a new 
  7667. location that is offset bytes from the origin. The next operation on the file 
  7668. takes place at the new location. Origin must be one of the following constants, 
  7669. defined in <stdio.h>: 
  7670.  
  7671. Origin         Definition 
  7672. SEEK_SET       Beginning of file 
  7673. SEEK_CUR       Current position of file pointer 
  7674. SEEK_END       End of file. 
  7675.  
  7676. The _lseek function can reposition the pointer anywhere in a file. The pointer 
  7677. can also be positioned beyond the end of the file; the data between the eof and 
  7678. the new file position is undefined. (See _chsize - Alter Length of File for 
  7679. more information on extending the length of the file.) However, an attempt to 
  7680. position the pointer before the beginning of the file causes an error. 
  7681.  
  7682. The _lseek function returns the offset, in bytes, of the new position from the 
  7683. beginning of the file. A return value of -1L indicates an error, and errno is 
  7684. set to one of the following values: 
  7685.  
  7686. Value          Meaning 
  7687. EBADF          The file handle is incorrect. 
  7688. EINVAL         The value for origin is incorrect, or the position specified by 
  7689.                offset is before the beginning of the file. 
  7690. EOS2ERR        The call to the operating system was not successful. 
  7691.  
  7692. On devices incapable of seeking (such as keyboards and printers), the return 
  7693. value is -1, with errno set to EOS2ERR. 
  7694.  
  7695. Example of _lseek 
  7696.  
  7697. Related Information 
  7698.  
  7699. o _tell - Get Pointer Position 
  7700. o _chsize - Alter Length of File 
  7701. o io.h 
  7702. o stdio.h 
  7703.  
  7704.  
  7705. ΓòÉΓòÉΓòÉ 2.141. _ltoa - Convert Long Integer to String ΓòÉΓòÉΓòÉ
  7706.  
  7707. #include <stdlib.h>
  7708.  
  7709. char *_ltoa(long value, char *string, int radix);
  7710.  
  7711. Language Level: Extension 
  7712.  
  7713. Description 
  7714.  
  7715. The _ltoa function converts the digits of the given long integer value to a 
  7716. character string that ends with a null character and stores the result in 
  7717. string.  The radix argument specifies the base of value; it must be in the 
  7718. range 2 to 36. If radix equals 10 and value is negative, the first character of 
  7719. the stored string is the minus sign (-). 
  7720.  
  7721. Note:  The space allocated for string must be large enough to hold the returned 
  7722. string. The function can return up to 33 bytes including the null character 
  7723. (\0). 
  7724.  
  7725. The _ltoa function returns a pointer to string.  There is no error return 
  7726. value. 
  7727.  
  7728. Example of _ltoa 
  7729.  
  7730. Related Information 
  7731.  
  7732. o atol  - Convert Character Strings 
  7733. o _itoa - Convert Integer to String 
  7734. o _ultoa - Convert Unsigned Long Integer to Str         ing 
  7735. o stdlib.h 
  7736.  
  7737.  
  7738. ΓòÉΓòÉΓòÉ 2.142. _makepath - Create Path ΓòÉΓòÉΓòÉ
  7739.  
  7740. #include <stdlib.h>
  7741.  
  7742. void _makepath(char *path, char *drive, char *dir, char *fname, char *ext);
  7743.  
  7744. Language Level: Extension 
  7745.  
  7746. Description 
  7747.  
  7748. The _makepath function creates a single path name, composed of a drive letter, 
  7749. directory path, file name, and file name extension. 
  7750.  
  7751. The path argument should point to an empty buffer large enough to hold the 
  7752. complete path name. The constant _MAX_PATH, defined in <stdlib.h>, specifies 
  7753. the maximum size allowed for path. The other arguments point to the following 
  7754. buffers containing the path name elements: 
  7755.  
  7756. Buffer         Description 
  7757.  
  7758. drive          Contains a letter (A, B, ...) corresponding to the desired drive 
  7759.                and an optional following colon.  The _makepath routine inserts 
  7760.                the colon automatically in the composite path name if it is 
  7761.                missing.  If drive is a null character or an empty string, no 
  7762.                drive letter or colon appears in the composite path string. 
  7763.  
  7764. dir            Contains the path of directories, not including the drive 
  7765.                designator or the actual file name.  The trailing slash is 
  7766.                optional, and either slash (/) or backslash (\) or both can be 
  7767.                used in a single dir argument.  If a trailing slash or backslash 
  7768.                (/ or \) is not specified, it is inserted automatically.  If dir 
  7769.                is a null character or an empty string, no slash is inserted in 
  7770.                the composite path string. 
  7771.  
  7772. fname          Contains the base file name without any extensions. 
  7773.  
  7774. ext            Contains the actual file name extension, with or without a 
  7775.                leading period.  The _makepath function inserts the period 
  7776.                automatically if it does not appear in ext.  If ext is a null 
  7777.                character or an empty string, no period is inserted in the 
  7778.                composite path string. 
  7779.  
  7780. The size limits on the above four fields are those specified by the constants 
  7781. _MAX_DRIVE, _MAX_DIR, _MAX_FNAME, and _MAX_EXT, which are defined in 
  7782. <stdlib.h>. The composite path should be no larger than the _MAX_PATH constant 
  7783. also defined in <stdlib.h>; otherwise, the operating system does not handle it 
  7784. correctly. 
  7785.  
  7786. Note:  No checking is done to see if the syntax of the file name is correct. 
  7787.  
  7788. There is no return value. 
  7789.  
  7790. Example of _makepath 
  7791.  
  7792. Related Information 
  7793.  
  7794. o _fullpath - Get Full Path Name of Partial Path 
  7795. o _splitpath - Decompose Path Name 
  7796. o stdlib.h 
  7797.  
  7798.  
  7799. ΓòÉΓòÉΓòÉ 2.143. malloc  - Reserve Storage Block ΓòÉΓòÉΓòÉ
  7800.  
  7801. #include <stdlib.h>
  7802.  
  7803. void *malloc(size_t size);
  7804.  
  7805. Language Level: ANSI, SAA, Extension 
  7806.  
  7807. Description 
  7808.  
  7809. The malloc function reserves a block of storage of size bytes. Unlike the 
  7810. calloc function, malloc does not necessarily give all the bits of each element 
  7811. an initial value of zero (0). 
  7812.  
  7813. The malloc function returns a pointer to the reserved space.  The storage space 
  7814. to which the return value points is guaranteed to be suitably aligned for 
  7815. storage of any type of object. 
  7816.  
  7817. The return value is NULL if there is not enough storage available, or if size 
  7818. was specified as zero. 
  7819.  
  7820. Example of malloc 
  7821.  
  7822. Related Information 
  7823.  
  7824. o calloc  - Reserve and Initialize Storage 
  7825. o _debug_malloc - Reserve Storage Blocks 
  7826. o free  - Release Storage Blocks 
  7827. o realloc  - Change Reserved Storage Block Size 
  7828. o malloc.h 
  7829. o stdlib.h 
  7830.  
  7831.  
  7832. ΓòÉΓòÉΓòÉ 2.144. _matherr - Process Math Library Errors ΓòÉΓòÉΓòÉ
  7833.  
  7834. #include <math.h>
  7835.  
  7836. int _matherr(struct exception *x);
  7837.  
  7838. Language Level: Extension 
  7839.  
  7840. Description 
  7841.  
  7842. You can use the _matherr function to process errors generated by the functions 
  7843. in the math library. The math functions call _matherr whenever they detect an 
  7844. error. The _matherr function supplied with the Giverny library performs no 
  7845. error handling and returns 0 to the calling function. You can provide a 
  7846. different definition of the _matherr function to carry out special error 
  7847. handling. Be sure to use the /NOE link option, if you are using your own 
  7848. _matherr function. For the Giverny compiler, you can use the /B option on the 
  7849. icc command line to do so as in: 
  7850.  
  7851.    icc /Sm /B"/NOE" yourfile.c
  7852.  
  7853. When an error occurs in a math routine, _matherr is called with a pointer to 
  7854. the following structure (defined in <math.h>) as an argument: 
  7855.  
  7856.    struct exception {
  7857.        int type;
  7858.        char *name;
  7859.        double arg1, arg2, retval;
  7860.    };
  7861.  
  7862. The type variable specifies the type of math error. It is one of the following 
  7863. values, defined in <math.h>: 
  7864.  
  7865. Value          Meaning 
  7866. DOMAIN         Argument domain error 
  7867. OVERFLOW       Overflow range error 
  7868. UNDERFLOW      Underflow range error 
  7869. TLOSS          Total loss of significance 
  7870. PLOSS          Partial loss of significance 
  7871. SING           Argument singularity. 
  7872.  
  7873. Because PLOSS is used by the C/2 compiler, it is provided to prevent errors 
  7874. during compiling. The Giverny compiler does not actually generate this value. 
  7875.  
  7876. The name is a pointer to a null-ended string containing the name of the 
  7877. function that caused the error. The arg1 and arg2 variables specify the 
  7878. argument values that caused the error. If only one argument is given, it is 
  7879. stored in arg1. 
  7880.  
  7881. The retval is the default return value; you can change the return value. The 
  7882. return value from _matherr must specify whether or not an error actually 
  7883. occurred. If _matherr returns 0, an error message appears, and errno is set to 
  7884. an appropriate error value. If _matherr returns a nonzero value, no error 
  7885. message appears and errno remains unchanged. 
  7886.  
  7887. Example of _matherr 
  7888.  
  7889. Related Information 
  7890.  
  7891. o log  - Calculate Natural Logarithm 
  7892. o log10  - Calculate Base 10 Logarithm 
  7893. o math.h 
  7894.  
  7895.  
  7896. ΓòÉΓòÉΓòÉ 2.145. max - Return Larger of Two Values ΓòÉΓòÉΓòÉ
  7897.  
  7898. #include <stdlib.h>
  7899.  
  7900. type max(type a, type b);
  7901.  
  7902. Language Level: Extension 
  7903.  
  7904. Description 
  7905.  
  7906. The max macro compares two values to find out which is larger. The data type 
  7907. can be any arithmetic data type, signed or unsigned.  Both arguments must have 
  7908. the same type for each call to max. 
  7909.  
  7910. Note:  Because max is a macro, if the evaluation of the arguments contains side 
  7911. effects (post-increment operators, for example), the results of both the side 
  7912. effects and the macro will be undefined. 
  7913.  
  7914. The max macro returns the larger of the two values. 
  7915.  
  7916. Example of max 
  7917.  
  7918. Related Information 
  7919.  
  7920. o min - Return Lesser of Two Values 
  7921. o stdlib.h 
  7922.  
  7923.  
  7924. ΓòÉΓòÉΓòÉ 2.146. mblen  - Multibyte String Length ΓòÉΓòÉΓòÉ
  7925.  
  7926. #include <stdlib.h>
  7927.  
  7928. int mblen(const char *string, size_t n);
  7929.  
  7930. Language Level: ANSI, SAA 
  7931.  
  7932. Description 
  7933.  
  7934. The mblen function determines the length in bytes of the multibyte character 
  7935. pointed to by string. A maximum of n bytes is examined. 
  7936.  
  7937. If string is NULL, the mblen function returns: 
  7938.  
  7939. o Nonzero when DBCS-host code (EBCDIC systems) is used 
  7940. o Zero otherwise. 
  7941.  
  7942. If string is not NULL, the mblen function returns: 
  7943.  
  7944. o Zero if string points to the null character 
  7945. o The number of bytes comprising the multibyte character 
  7946. o -1 if string does not point to a valid multibyte character. 
  7947.  
  7948. Example of mblen 
  7949.  
  7950. Related Information 
  7951.  
  7952. o mbtowc  - Convert Multibyte Character to wchar_t 
  7953. o mbstowcs  - Convert Multibyte Characters to wchar_t Characters 
  7954. o strlen  - String Length 
  7955. o wcslen  - Calculates Length of wchar_t String 
  7956. o wctomb  - Converts wchar_t Character to Multibyte Character 
  7957. o stdlib.h 
  7958.  
  7959.  
  7960. ΓòÉΓòÉΓòÉ 2.147. mbstowcs  - Convert Multibyte Characters to wchar_t Characters ΓòÉΓòÉΓòÉ
  7961.  
  7962. #include <stdlib.h>
  7963.  
  7964. size_t mbstowcs(wchar_t *pwc, const char *string, size_t n);
  7965.  
  7966. Language Level: ANSI, SAA 
  7967.  
  7968. Description 
  7969.  
  7970. The mbstowcs function determines the length of the sequence of the multibyte 
  7971. characters pointed to by string.  It then stores the code for the sequence of 
  7972. multibyte characters in the wchar_t object pointed to by pwc.  A maximum of n 
  7973. wchar_t characters is examined. 
  7974.  
  7975. The mbstowcs function returns the number of wchar_t characters generated not 
  7976. including any terminating zero codes.  If an invalid multibyte character is 
  7977. encountered, the function returns (size_t)-1. 
  7978.  
  7979. Example of mbstowcs 
  7980.  
  7981. Related Information 
  7982.  
  7983. o mblen  - Multibyte String Length 
  7984. o mbtowc  - Convert Multibyte Character to wchar_t 
  7985. o wcslen  - Calculates Length of wchar_t String 
  7986. o wcstombs  - Converts wchar_t String to Multibyte Character String 
  7987. o stdlib.h 
  7988.  
  7989.  
  7990. ΓòÉΓòÉΓòÉ 2.148. mbtowc  - Convert Multibyte Character to wchar_t ΓòÉΓòÉΓòÉ
  7991.  
  7992. #include <stdlib.h>
  7993.  
  7994. int mbtowc(wchar_t *pwc, const char *string, size_t n);
  7995.  
  7996. Language Level: ANSI, SAA 
  7997.  
  7998. Description 
  7999.  
  8000. The mbtowc function first determines the length of the multibyte character 
  8001. pointed to by string.  It then stores the code for the multibyte character in 
  8002. the wchar_t object pointed to by pwc.  A maximum of n bytes is examined. 
  8003.  
  8004. If string is NULL, the mbtowc function returns: 
  8005.  
  8006. o Nonzero when DBCS-host code (EBCDIC systems) is used 
  8007. o Zero otherwise. 
  8008.  
  8009. If string is not NULL, the mbtowc function returns: 
  8010.  
  8011. o Zero if string points to the null character 
  8012. o The number of bytes comprising the converted multibyte character 
  8013. o -1 if string does not point to a valid multibyte character. 
  8014.  
  8015. Example of mbtowc 
  8016.  
  8017. Related Information 
  8018.  
  8019. o mblen  - Multibyte String Length 
  8020. o mbstowcs  - Convert Multibyte Characters to wchar_t Characters 
  8021. o wcslen  - Calculates Length of wchar_t String 
  8022. o wctomb  - Converts wchar_t Character to Multibyte Character 
  8023. o stdlib.h 
  8024.  
  8025.  
  8026. ΓòÉΓòÉΓòÉ 2.149. memccpy - Copy Bytes ΓòÉΓòÉΓòÉ
  8027.  
  8028. #include <string.h>     /* also defined in <memory.h> */
  8029.  
  8030. void *memccpy(void *dest, void *src, int c, unsigned cnt);
  8031.  
  8032. Language Level: Extension 
  8033.  
  8034. Description 
  8035.  
  8036. The memccpy function copies bytes from src to dest up to and including the 
  8037. first occurrence of the character c or until cnt bytes have been copied, 
  8038. whichever comes first. 
  8039.  
  8040. If the character c is copied, memccpy returns a pointer to the byte in dest 
  8041. that immediately follows the character. If c is not copied, memccpy returns 
  8042. NULL. <memory.h>) 
  8043.  
  8044. Example of memccpy 
  8045.  
  8046. Related Information 
  8047.  
  8048. o memchr  - Search Buffer 
  8049. o memcmp  - Compare Buffers 
  8050. o memcpy  - Copy Bytes 
  8051. o memmove  - Copy Bytes 
  8052. o memset  - Set Bytes to Value 
  8053. o memory.h 
  8054. o string.h 
  8055.  
  8056.  
  8057. ΓòÉΓòÉΓòÉ 2.150. memchr  - Search Buffer ΓòÉΓòÉΓòÉ
  8058.  
  8059. #include <string.h>
  8060.  
  8061. void *memchr(const void *buf, int c, size_t count);
  8062.  
  8063. Language Level: ANSI, SAA, Extension 
  8064.  
  8065. Description 
  8066.  
  8067. The memchr function searches the first count bytes of buf for the first 
  8068. occurrence of c converted to an unsigned character.  The search continues until 
  8069. it finds c or examines count bytes. 
  8070.  
  8071. The memchr function returns a pointer to the location of c in buf.  It returns 
  8072. NULL if c is not within the first count bytes of buf. 
  8073.  
  8074. Example of memchr 
  8075.  
  8076. Related Information 
  8077.  
  8078. o memccpy - Copy Bytes 
  8079. o memcmp  - Compare Buffers 
  8080. o memcpy  - Copy Bytes 
  8081. o memicmp - Compare Bytes 
  8082. o memmove  - Copy Bytes 
  8083. o memset  - Set Bytes to Value 
  8084. o strchr  - Search for Character 
  8085. o memory.h 
  8086. o string.h 
  8087.  
  8088.  
  8089. ΓòÉΓòÉΓòÉ 2.151. memcmp  - Compare Buffers ΓòÉΓòÉΓòÉ
  8090.  
  8091. #include <string.h>
  8092.  
  8093. int memcmp(const void *buf1, const void *buf2, size_t count);
  8094.  
  8095. Language Level: ANSI, SAA, Extension 
  8096.  
  8097. Description 
  8098.  
  8099. The memcmp function compares the first count bytes of buf1 and buf2 and returns 
  8100. a value indicating their relationship as follows: 
  8101.  
  8102. Value               Meaning 
  8103. Less than 0         buf1 less than buf2 
  8104. 0                   buf1 identical to buf2 
  8105. Greater than 0      buf1 greater than buf2 
  8106.  
  8107. Example of memcmp 
  8108.  
  8109. Related Information 
  8110.  
  8111. o memccpy - Copy Bytes 
  8112. o memchr  - Search Buffer 
  8113. o memcpy  - Copy Bytes 
  8114. o memicmp - Compare Bytes 
  8115. o memmove  - Copy Bytes 
  8116. o memset  - Set Bytes to Value 
  8117. o strcmp  - Compare Strings 
  8118. o memory.h 
  8119. o string.h 
  8120.  
  8121.  
  8122. ΓòÉΓòÉΓòÉ 2.152. memcpy  - Copy Bytes ΓòÉΓòÉΓòÉ
  8123.  
  8124. #include <string.h>
  8125.  
  8126. void *memcpy(void *dest, const void *src, size_t count);
  8127.  
  8128. Language Level: ANSI, SAA, Extension 
  8129.  
  8130. Description 
  8131.  
  8132. The memcpy function copies count bytes of src to dest.  For memcpy, the 
  8133. behavior is undefined if copying takes place between objects that overlap. 
  8134. (The memmove function allows copying between objects that may overlap.) 
  8135.  
  8136. memcpy returns a pointer to dest. 
  8137.  
  8138. Example of memcpy 
  8139.  
  8140. Related Information 
  8141.  
  8142. o memccpy - Copy Bytes 
  8143. o memchr  - Search Buffer 
  8144. o memcmp  - Compare Buffers 
  8145. o memicmp - Compare Bytes 
  8146. o memmove  - Copy Bytes 
  8147. o memset  - Set Bytes to Value 
  8148. o strcpy  - Copy Strings 
  8149. o memory.h 
  8150. o string.h 
  8151.  
  8152.  
  8153. ΓòÉΓòÉΓòÉ 2.153. memicmp - Compare Bytes ΓòÉΓòÉΓòÉ
  8154.  
  8155. #include <string.h>    /* Also defined in <memory.h> */
  8156.  
  8157. int memicmp (void *buf1, void *buf2, unsigned int cnt);
  8158.  
  8159. Language Level: Extension 
  8160.  
  8161. Description 
  8162.  
  8163. The memicmp function compares the first cnt bytes of buf1 and buf2 without 
  8164. regard to the case of letters in the two buffers.  The function converts all 
  8165. uppercase characters into lowercase and then performs the comparison. 
  8166.  
  8167. The return value of memicmp indicates the result as follows: 
  8168.  
  8169. Value                 Meaning 
  8170. Less than 0           buf1 less than buf2 
  8171. 0                     buf1 identical to buf2 
  8172. Greater than 0        buf1 greater than buf2. 
  8173.  
  8174. Example of memicmp 
  8175.  
  8176. Related Information 
  8177.  
  8178. o memchr  - Search Buffer 
  8179. o memcmp  - Compare Buffers 
  8180. o memcpy  - Copy Bytes 
  8181. o memmove  - Copy Bytes 
  8182. o memset  - Set Bytes to Value 
  8183. o memory.h 
  8184. o string.h 
  8185.  
  8186.  
  8187. ΓòÉΓòÉΓòÉ 2.154. memmove  - Copy Bytes ΓòÉΓòÉΓòÉ
  8188.  
  8189. #include <string.h>
  8190.  
  8191. void *memmove(void *dest, const void *src, size_t count);
  8192.  
  8193. Language Level: ANSI, SAA, Extension 
  8194.  
  8195. Description 
  8196.  
  8197. The memmove function copies count bytes of src to dest. The memmove function 
  8198. allows copying between objects that may overlap as if src is first copied into 
  8199. a temporary array. 
  8200.  
  8201. memmove returns a pointer to dest. 
  8202.  
  8203. Example of memmove 
  8204.  
  8205. Related Information 
  8206.  
  8207. o memccpy - Copy Bytes 
  8208. o memchr  - Search Buffer 
  8209. o memcmp  - Compare Buffers 
  8210. o memcpy  - Copy Bytes 
  8211. o memicmp - Compare Bytes 
  8212. o memset  - Set Bytes to Value 
  8213. o strcpy  - Copy Strings 
  8214. o memory.h 
  8215. o string.h 
  8216.  
  8217.  
  8218. ΓòÉΓòÉΓòÉ 2.155. memset  - Set Bytes to Value ΓòÉΓòÉΓòÉ
  8219.  
  8220. #include <string.h>
  8221.  
  8222. void *memset(void *dest, int c, size_t count);
  8223.  
  8224. Language Level: ANSI, SAA, Extension 
  8225.  
  8226. Description 
  8227.  
  8228. The memset function sets the first count bytes of dest to the value c.  The 
  8229. value of c is converted to an unsigned character. 
  8230.  
  8231. The memset function returns a pointer to dest. 
  8232.  
  8233. Example of memset 
  8234.  
  8235. Related Information 
  8236.  
  8237. o memccpy - Copy Bytes 
  8238. o memchr  - Search Buffer 
  8239. o memcmp  - Compare Buffers 
  8240. o memcpy  - Copy Bytes 
  8241. o memicmp - Compare Bytes 
  8242. o memmove  - Copy Bytes 
  8243. o memory.h 
  8244. o string.h 
  8245.  
  8246.  
  8247. ΓòÉΓòÉΓòÉ 2.156. min - Return Lesser of Two Values ΓòÉΓòÉΓòÉ
  8248.  
  8249. #include <stdlib.h>
  8250.  
  8251. type min(type a, type b);
  8252.  
  8253. Language Level: Extension 
  8254.  
  8255. Description 
  8256.  
  8257. The min macro compares two values and returns the smaller of the two. The data 
  8258. type can be any arithmetic data type, signed or unsigned. The type must be the 
  8259. same for both arguments to min. 
  8260.  
  8261. Note:  Because min is a macro, if the evaluation of the arguments contains side 
  8262. effects (post-increment operators, for example), the results of both the side 
  8263. effects and the macro will be undefined. 
  8264.  
  8265. Example of min 
  8266.  
  8267. Related Information 
  8268.  
  8269. o max - Return Larger of Two Values 
  8270. o stdlib.h 
  8271.  
  8272.  
  8273. ΓòÉΓòÉΓòÉ 2.157. _mkdir - Create New Directory ΓòÉΓòÉΓòÉ
  8274.  
  8275. #include <direct.h>
  8276.  
  8277. int _mkdir(char *pathname);
  8278.  
  8279. Language Level: Extension 
  8280.  
  8281. Description 
  8282.  
  8283. The _mkdir function creates a new directory with the specified pathname. 
  8284. Because only one directory can be created at a time, only the last component of 
  8285. pathname can name a new directory. 
  8286.  
  8287. An alternative to this function is the DosCreateDir API call. 
  8288.  
  8289. The _mkdir function returns the value 0 if the directory was created.  A return 
  8290. value of -1 indicates an error, and errno is set to one of the following 
  8291. values: 
  8292.  
  8293. Value          Meaning 
  8294. EACCESS        The directory was not created;  the given name is the name of an 
  8295.                existing file, directory, or device. 
  8296. ENOENT         The pathname was not found. 
  8297.  
  8298. Example of _mkdir 
  8299.  
  8300. Related Information 
  8301.  
  8302. o _chdir - Change Current Working Directory 
  8303. o _getcwd - Get Path Name of Current Directory 
  8304. o _getdcwd - Get Full Path Name of Current Directory 
  8305. o _rmdir - Remove Directory 
  8306. o direct.h 
  8307.  
  8308.  
  8309. ΓòÉΓòÉΓòÉ 2.158. mktime  - Convert Local Time ΓòÉΓòÉΓòÉ
  8310.  
  8311. #include <time.h>
  8312.  
  8313. time_t mktime(struct tm *time);
  8314.  
  8315. Language Level: ANSI, SAA 
  8316.  
  8317. Description 
  8318.  
  8319. The mktime function converts local time, stored as a structure pointed to by 
  8320. time, into a time_t structure suitable for use with other time functions. The 
  8321. values of some structure elements pointed to by time are not restricted to the 
  8322. ranges shown on gmtime. 
  8323.  
  8324. The values of tm_wday and tm_yday passed to mktime are ignored and are assigned 
  8325. their correct values on return. 
  8326.  
  8327. The mktime function returns the calendar time having type time_t.  The value 
  8328. (time_t)(-1) is returned if the calendar time cannot be represented. 
  8329.  
  8330. Note:  The time and date functions begin at 00:00:00 Universal Time, January 1, 
  8331. 1970. :enote. 
  8332.  
  8333. Example of mktime 
  8334.  
  8335. Related Information 
  8336.  
  8337. o ctime  - Convert Time 
  8338. o gmtime  - Convert Time 
  8339. o localtime  - Convert Time 
  8340. o time  - Determine Current Time 
  8341. o time.h 
  8342.  
  8343.  
  8344. ΓòÉΓòÉΓòÉ 2.159. modf  - Separate Floating-Point Value ΓòÉΓòÉΓòÉ
  8345.  
  8346. #include <math.h>
  8347.  
  8348. double modf(double x, double *intptr);
  8349.  
  8350. Language Level: ANSI, SAA 
  8351.  
  8352. Description 
  8353.  
  8354. The modf function breaks down the floating-point value x into fractional and 
  8355. integral parts.  The signed fractional portion of x is returned.  The integer 
  8356. portion is stored as a double value pointed to by intptr.  Both the fractional 
  8357. and integral parts are given the same sign as x. 
  8358.  
  8359. Example of modf 
  8360.  
  8361. Related Information 
  8362.  
  8363. o frexp  - Separate Floating-Point Value 
  8364. o ldexp  - Multiply by a Power of Two 
  8365. o math.h 
  8366.  
  8367.  
  8368. ΓòÉΓòÉΓòÉ 2.160. _onexit - Record Termination Function ΓòÉΓòÉΓòÉ
  8369.  
  8370. #include <stdlib.h>
  8371.  
  8372. onexit_t _onexit(onexit_t func);
  8373.  
  8374. Language Level: Extension 
  8375.  
  8376. Description 
  8377.  
  8378. The _onexit function records the address of a function func to call when the 
  8379. program ends normally.  Successive calls to _onexit create a stack of functions 
  8380. that run in a last-in, first-out order. The functions passed to _onexit cannot 
  8381. take parameters. 
  8382.  
  8383. You can record up to 32 termination functions with calls to _onexit and atexit. 
  8384. If you exceed 32 functions, _onexit returns the value NULL. 
  8385.  
  8386. Note:  For portability, use the ANSI-standard atexit function, which is 
  8387. equivalent to _onexit. 
  8388.  
  8389. If successful, _onexit returns a pointer to the function; otherwise, it returns 
  8390. a NULL value. 
  8391.  
  8392. Example of _onexit 
  8393.  
  8394. Related Information 
  8395.  
  8396. o abort  - Stop a Program 
  8397. o atexit  - Record Program Termination Function 
  8398. o exit  - End Program 
  8399. o _exit - End Process 
  8400. o stdlib.h 
  8401.  
  8402.  
  8403. ΓòÉΓòÉΓòÉ 2.161. _open - Open File ΓòÉΓòÉΓòÉ
  8404.  
  8405. #include <io.h>
  8406. #include <fcntl.h>
  8407. #include <sys\stat.h>
  8408.  
  8409. int _open(char *pathname, int oflag, int pmode);
  8410.  
  8411. Language Level: Extension 
  8412.  
  8413. Description 
  8414.  
  8415. The _open function opens the file specified by pathname and prepares the file 
  8416. for subsequent reading or writing as defined by oflag. The _open function can 
  8417. also prepare the file for reading and writing. The oflag is an integer 
  8418. expression formed by combining one or more of the following constants, defined 
  8419. in <fcntl.h>. When more than one constant is given, the constants are joined 
  8420. with the bitwise OR operator (|). 
  8421.  
  8422. Oflag         Meaning 
  8423. O_APPEND      Reposition the file pointer to the end of the file before every 
  8424.               write operation. 
  8425. O_CREAT       Create and open a new file.  This flag has no effect if the file 
  8426.               specified by pathname exists. 
  8427. O_EXCL        Return an error value if the file specified by pathname exists. 
  8428.               This flag applies only when used with O_CREAT. 
  8429. O_RDONLY      Open the file for reading only.  If this flag is given, neither 
  8430.               O_RDWR nor O_WRONLY can be given. 
  8431. O_RDWR        Open the file for reading and writing.  If this flag is given, 
  8432.               neither O_RDONLY nor O_WRONLY can be given. 
  8433. O_TRUNC       Open and truncate an existing file to 0 length. The file must 
  8434.               have write permission. The contents of the file are destroyed, 
  8435.               and O_TRUNC cannot be specified with O_RDONLY. 
  8436. O_WRONLY      Open the file for writing only.  If this flag is given, neither 
  8437.               O_RDONLY nor O_RDWR can be given. 
  8438. O_BINARY      Open the file in binary (untranslated) mode. (See fopen) 
  8439. O_TEXT        Open the file in text (translated) mode. (See fopen) 
  8440.  
  8441. If neither O_BINARY or O_TEXT is specified, the default will be O_TEXT; it is 
  8442. an error to specify both O_BINARY and O_TEXT. 
  8443.  
  8444. You must specify one of the access mode flags, O_RDONLY, O_WRONLY, or O_RDWR. 
  8445. There is no default. 
  8446.  
  8447. Warning: O_TRUNC destroys the complete contents of an existing file. Use it 
  8448. with care. 
  8449.  
  8450. The pmode argument is required only when O_CREAT is specified. 
  8451.  
  8452. If the file exists, pmode is ignored. Otherwise, pmode specifies the permission 
  8453. settings for the file.  These are set when the new file is closed for the first 
  8454. time. The pmode is an integer expression containing one or both of the 
  8455. constants S_IWRITE and S_IREAD, defined in <sys\stat.h> The meaning of the 
  8456. pmode argument is as follows. 
  8457.  
  8458. Value                   Meaning 
  8459. S_IWRITE                Writing permitted 
  8460. S_IREAD                 Reading permitted 
  8461. S_IREAD | S_IWRITE      Reading and writing permitted. 
  8462.  
  8463. If write permission is not given, the file is read-only.  On the OS/2 operating 
  8464. system, all files are readable; you cannot give write-only permission.  The 
  8465. modes S_IWRITE and S_IREAD | S_IWRITE are equivalent. 
  8466.  
  8467. The _open function applies the current file permission mask to pmode before 
  8468. setting the permissions.  (See _umask - Sets File Mask of Current Process). 
  8469.  
  8470. The _open function returns a file handle for the opened file. A return value of 
  8471. -1 indicates an error, and errno is set to one of the following values: 
  8472.  
  8473. Value          Meaning 
  8474. EACCESS        The given pathname is a directory; or the file is read-only but 
  8475.                an open for writing was attempted; or a sharing violation 
  8476.                occurred. 
  8477. EEXIST         The O_CREAT and O_EXCL flags are specified, but the named file 
  8478.                already exists. 
  8479. EMFILE         No more file handles are available. 
  8480. EINVAL         An incorrect argument was passed. 
  8481. ENOENT         The file or pathname were not found. 
  8482. EOS2ERR        The call to the operating system was not successful. 
  8483.  
  8484. Example of _open 
  8485.  
  8486. Related Information 
  8487.  
  8488. o _close - Closes File Associated with Handle 
  8489. o _creat - Create New File 
  8490. o _fdopen - Associates Input Or Output With File 
  8491. o _sopen - Open Shared File 
  8492. o _umask - Sets File Mask of Current Process 
  8493. o fcntl.h 
  8494. o io.h 
  8495. o sys\stat.h 
  8496.  
  8497.  
  8498. ΓòÉΓòÉΓòÉ 2.162. _outp - Write Byte to Output Port ΓòÉΓòÉΓòÉ
  8499.  
  8500. #include <conio.h>
  8501.      OR
  8502. #include <builtin.h>
  8503.  
  8504. int _outp( const unsigned int port, const int value );
  8505.  
  8506. Language Level: Extension 
  8507.  
  8508. Description 
  8509.  
  8510. The _outp function writes a byte value to the specified port. The port number 
  8511. must be an unsigned int value within the range 0 to 65,535 inclusive. The byte 
  8512. value must be within the range 0 to 255 inclusive. 
  8513.  
  8514. Because it is a built-in function and has no backing code in the library: 
  8515.  
  8516. o You cannot take the address of _outp. 
  8517. o You cannot parenthesize an _outp function call, because parentheses specify a 
  8518.   call to the backing code for the function in the library, and _outp has no 
  8519.   backing code. 
  8520.  
  8521. You can run code containing this function only at ring zero. Otherwise, an 
  8522. invalid instruction exception will be received. 
  8523.  
  8524. This function returns the byte value as an integer that was output to the 
  8525. specified port. There is no error return value and this function does not set 
  8526. errno. 
  8527.  
  8528. Example of _outp 
  8529.  
  8530. Related Information 
  8531.  
  8532. o _inp - Read Byte from Input Port 
  8533. o _inpw - Read Unsigned Short from Input Port 
  8534. o _inpd - Read Double Word from Input Port 
  8535. o _outpw - Write Word to Output Port 
  8536. o _outpd - Write Double Word to Output Port 
  8537.  
  8538.  
  8539. ΓòÉΓòÉΓòÉ 2.163. _outpd - Write Double Word to Output Port ΓòÉΓòÉΓòÉ
  8540.  
  8541. #include <conio.h>
  8542.      OR
  8543. #include <builtin.h>
  8544.  
  8545. int _outpd( const unsigned int port,
  8546.            const unsigned long value );
  8547.  
  8548. Language Level: Extension 
  8549.  
  8550. Description 
  8551.  
  8552. The _outpd function writes an unsigned long value to the specified port. The 
  8553. port number must be a value within the range 0 to 65535 inclusive. The unsigned 
  8554. long value must be within the range 0 to 4 294 967 295 inclusive. 
  8555.  
  8556. Because it is a built-in function and has no backing code in the library: 
  8557.  
  8558. o You cannot take the address of _outpd. :li,You cannot parenthesize an _outpd 
  8559.   function call, because parentheses specify a call to the backing code for the 
  8560.   function in the library, and _outpd has no backing code. 
  8561.  
  8562. You can run code containing this function only at ring zero. Otherwise, an 
  8563. invalid instruction exception will be received. 
  8564.  
  8565. This function returns the unsigned long value that was output to the specified 
  8566. port.  There is no error return value and this function does not set errno. 
  8567.  
  8568. Example of _outpd 
  8569.  
  8570. Related Information 
  8571.  
  8572. o _inp - Read Byte from Input Port 
  8573. o _inpw - Read Unsigned Short from Input Port 
  8574. o _inpd - Read Double Word from Input Port 
  8575. o _outp - Write Byte to Output Port 
  8576. o _outpw - Write Word to Output Port 
  8577.  
  8578.  
  8579. ΓòÉΓòÉΓòÉ 2.164. _outpw - Write Word to Output Port ΓòÉΓòÉΓòÉ
  8580.  
  8581. #include <conio.h>
  8582.      OR
  8583. #include <builtin.h>
  8584.  
  8585. unsigned short _outpw( const unsigned int port,
  8586.                        const unsigned short word );
  8587.  
  8588. Language Level: Extension 
  8589.  
  8590. Description 
  8591.  
  8592. The _outpw function writes an unsigned short word to the specified port. The 
  8593. port number must be an unsigned int value within the range 0 to 65,535 
  8594. inclusive. The unsigned short word must be in the range 0 to 65,535. 
  8595.  
  8596. Because it is a built-in function and has no backing code in the library: 
  8597.  
  8598. o You cannot take the address of _outpw. 
  8599. o You cannot parenthesize a _outpw function call, because parentheses specify a 
  8600.   call to the backing code for the function in the library, and &ouptw. has no 
  8601.   backing code. 
  8602.  
  8603. You can run code containing this function only at ring zero. Otherwise, an 
  8604. invalid instruction exception will be received. 
  8605.  
  8606. This function returns the unsigned short value that was output to the specified 
  8607. port. There is no error return value and this function does not set errno. 
  8608.  
  8609. Example of _outpw 
  8610.  
  8611. Related Information 
  8612.  
  8613. o _inp - Read Byte from Input Port 
  8614. o _inpw - Read Unsigned Short from Input Port 
  8615. o _inpd - Read Double Word from Input Port 
  8616. o _outp - Write Byte to Output Port 
  8617. o _outpd - Write Double Word to Output Port 
  8618.  
  8619.  
  8620. ΓòÉΓòÉΓòÉ 2.165. __parmdwords - Get Number of dwords in Parameter List ΓòÉΓòÉΓòÉ
  8621.  
  8622. #include <stdlib.h>
  8623.  
  8624. unsigned char __parmdwords(void);
  8625.  
  8626. Language Level: Extension 
  8627.  
  8628. Description 
  8629.  
  8630. The __parmdwords function returns the hidden parameter passed in the AL 
  8631. register for system linkage calls. The hidden parameter contains the size of 
  8632. the parameter list that is passed to the function containing the call to 
  8633. __parmdwords.  The size is in doublewords (dwords), and can be between 0 and 
  8634. 255. If the parameter list is larger than 255 dwords, the hidden parameter 
  8635. contains the 8 least significant bits of the value. 
  8636.  
  8637. This function allows the implementer of a function to increase the number of 
  8638. parameters the function takes without changing the name of the function. The 
  8639. new version of the function can call __parmdwords to check the size of the 
  8640. parameter list and determine whether the call was written for the earlier 
  8641. version of the function or for the extended version. 
  8642.  
  8643. Warning: The __parmdwords function has several limitations: 
  8644.  
  8645.  1. Because it is a built-in function and has no backing code in the library: 
  8646.  
  8647.    o You cannot take the address of __parmdwords. 
  8648.    o You cannot parenthesize a __parmdwords function call because parentheses 
  8649.      specify a call to the backing code for the function in the library, and 
  8650.      __parmdwords has no backing code. 
  8651.  
  8652.  2. The __parmdwords function can only be used for functions with the system 
  8653.     linkage type. If you use it with other linkage types, an error message is 
  8654.     generated, and your program will not compile correctly. 
  8655.  
  8656. The __parmdwords function returns the size of the parameter list passed to the 
  8657. function in units of dwords. 
  8658.  
  8659. Example of __parmdwords 
  8660.  
  8661. Related Information 
  8662.  
  8663. o stdlib.h 
  8664.  
  8665.  
  8666. ΓòÉΓòÉΓòÉ 2.166. perror  - Print Error Message ΓòÉΓòÉΓòÉ
  8667.  
  8668. #include <stdio.h>
  8669.  
  8670. void perror(const char *string);
  8671.  
  8672. Language Level: ANSI, SAA 
  8673.  
  8674. Description 
  8675.  
  8676. The perror function prints an error message to stderr.  If string is not NULL 
  8677. and string does not point to a null character, the string pointed to by string 
  8678. is printed to the standard error stream, followed by a colon and a space.  The 
  8679. message associated with the value in errno is then printed followed by a 
  8680. newline character. 
  8681.  
  8682. To produce accurate results, perror should be called immediately after a 
  8683. library function returns with an error;  otherwise, subsequent calls may alter 
  8684. the errno value. 
  8685.  
  8686. The perror function returns no value. 
  8687.  
  8688. Example of perror 
  8689.  
  8690. Related Information 
  8691.  
  8692. o clearerr  - Reset Error Indicators 
  8693. o ferror  - Test for Read/Write Errors 
  8694. o strerror  - Set Pointer to Runtime Error Message 
  8695. o Runtime Error Messages 
  8696. o stdio.h 
  8697.  
  8698.  
  8699. ΓòÉΓòÉΓòÉ 2.167. pow  - Compute Power ΓòÉΓòÉΓòÉ
  8700.  
  8701. #include <math.h>
  8702.  
  8703. double pow(double x, double y);
  8704.  
  8705. Language Level: ANSI, SAA 
  8706.  
  8707. Description 
  8708.  
  8709. The pow function returns the value of x**y (x to the power of y). If y is 0, 
  8710. pow returns the value 1.  If x is 0 and y is negative, pow sets errno to EDOM 
  8711. and returns 0.  If both x and y are 0, or if x is negative and y is not an 
  8712. integer, pow sets errno to EDOM, and returns 0. 
  8713.  
  8714. If an overflow results, pow sets errno to ERANGE and returns +HUGE_VAL for a 
  8715. large result or -HUGE_VAL for a small result. 
  8716.  
  8717. Example of pow 
  8718.  
  8719. Related Information 
  8720.  
  8721. o exp  - Exponential Function 
  8722. o log  - Calculate Natural Logarithm 
  8723. o log10  - Calculate Base 10 Logarithm 
  8724. o sqrt  - Calculate Square Root 
  8725. o math.h 
  8726.  
  8727.  
  8728. ΓòÉΓòÉΓòÉ 2.168. printf  - Formatted Print ΓòÉΓòÉΓòÉ
  8729.  
  8730. #include <stdio.h>
  8731.  
  8732. int printf(const char *format-string, argument-list);
  8733.  
  8734. Language Level: ANSI, SAA, Extension 
  8735.  
  8736. Description 
  8737.  
  8738. The printf function formats and prints a series of characters and values to the 
  8739. standard output stream stdout.  The format-string consists of ordinary 
  8740. characters, escape sequences, and format specifications.  The ordinary 
  8741. characters are copied in order of their appearance to stdout.  Format 
  8742. specifications, beginning with a percent sign (%), determine the output format 
  8743. for any argument-list following the format-string.  The format-string is a 
  8744. multibyte character string beginning and ending in its initial shift state. 
  8745.  
  8746. The format-string is read left to right.  When the first format specification 
  8747. is found, the value of the first argument after the format-string is converted 
  8748. and output according to the format specification.  The second format 
  8749. specification causes the second argument after the format-string to be 
  8750. converted and output, and so on through the end of the format-string.  If there 
  8751. are more arguments than there are format specifications, the extra arguments 
  8752. are evaluated and ignored.  The results are undefined if there are not enough 
  8753. arguments for all the format specifications.  A format specification has the 
  8754. following form: 
  8755.  
  8756. ΓöÇΓöÇ%ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇtypeΓöÇΓöÇ
  8757.        Γöé         Γöé  Γöé         Γöé  Γöé                Γöé  Γöé     Γöé
  8758.        ΓööΓöÇΓöÇflagsΓöÇΓöÇΓöÿ  ΓööΓöÇΓöÇwidthΓöÇΓöÇΓöÿ  ΓööΓöÇΓöÇ.ΓöÇΓöÇprecisionΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇhΓöÇΓöÇΓöñ
  8759.                                                      Γöé     Γöé
  8760.                                                      Γö£ΓöÇΓöÇLΓöÇΓöÇΓöñ
  8761.                                                      Γöé     Γöé
  8762.                                                      ΓööΓöÇΓöÇlΓöÇΓöÇΓöÿ
  8763. Each field of the format specification is a single character or number 
  8764. signifying a particular format option.  The type character, which appears after 
  8765. the last optional format field, determines whether the associated argument is 
  8766. interpreted as a character, a string, a number, or pointer.  The simplest 
  8767. format specification contains only the percent sign and a type character (for 
  8768. example, %s). 
  8769.  
  8770. The following optional fields control other aspects of the formatting: 
  8771.  
  8772. Field       Description 
  8773.  
  8774. flags       Justification of output and printing of signs, blanks, decimal 
  8775.             points, octal, and hexadecimal prefixes, and the semantics for 
  8776.             wchar_t precision unit. 
  8777.  
  8778. width       Minimum number of characters (bytes) output. 
  8779.  
  8780. precision   Maximum number of characters (bytes) printed for all or part of the 
  8781.             output field, or minimum number of digits printed for integer 
  8782.             values. 
  8783.  
  8784. h,l,L       Size of argument expected. 
  8785.  
  8786. If a percent sign (%) is followed by a character that has no meaning as a 
  8787. format field, the character is simply copied to stdout.  For example, to print 
  8788. a percent sign character, use %%. 
  8789.  
  8790. In extended mode, printf also converts floating-point values of NaN and 
  8791. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  8792. and sign of the string is determined by the format specifiers.  See Infinity 
  8793. and NaN Support for more information on infinity and NaN values. 
  8794.  
  8795. The printf function returns the number of characters (bytes) printed. 
  8796.  
  8797. Example of printf 
  8798.  
  8799. Related Information 
  8800.  
  8801. o fprintf  - Formatted Write 
  8802. o fscanf  - Read Formatted Data 
  8803. o scanf  - Read Data 
  8804. o sprintf  - Formatted Print to Buffer 
  8805. o sscanf  - Read Data 
  8806. o Infinity and NaN Support 
  8807. o stdio.h 
  8808.  
  8809.  
  8810. ΓòÉΓòÉΓòÉ 2.168.1. Format Specification - Types ΓòÉΓòÉΓòÉ
  8811.  
  8812. The type characters and their meanings are given in the following table: 
  8813.  
  8814. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  8815. Γöé CHAR- Γöé ARGUMENT   Γöé OUTPUT FORMAT                             Γöé
  8816. Γöé ACTER Γöé            Γöé                                           Γöé
  8817. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8818. Γöé d, i  Γöé Integer    Γöé Signed decimal integer.                   Γöé
  8819. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8820. Γöé u     Γöé Integer    Γöé Unsigned decimal integer.                 Γöé
  8821. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8822. Γöé o     Γöé Integer    Γöé Unsigned octal integer.                   Γöé
  8823. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8824. Γöé x     Γöé Integer    Γöé Unsigned hexadecimal integer, using       Γöé
  8825. Γöé       Γöé            Γöé abcdef.                                   Γöé
  8826. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8827. Γöé X     Γöé Integer    Γöé Unsigned hexadecimal integer, using       Γöé
  8828. Γöé       Γöé            Γöé ABCDEF.                                   Γöé
  8829. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8830. Γöé f     Γöé Double     Γöé Signed value having the form              Γöé
  8831. Γöé       Γöé            Γöé [-]dddd.dddd, where dddd is one or more   Γöé
  8832. Γöé       Γöé            Γöé decimal digits.  The number of digits     Γöé
  8833. Γöé       Γöé            Γöé before the decimal point depends on the   Γöé
  8834. Γöé       Γöé            Γöé magnitude of the number.  The number of   Γöé
  8835. Γöé       Γöé            Γöé digits after the decimal point is equal   Γöé
  8836. Γöé       Γöé            Γöé to the requested precision.               Γöé
  8837. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8838. Γöé e     Γöé Double     Γöé Signed value having the form              Γöé
  8839. Γöé       Γöé            Γöé [-]d.dddd"e"[sign]ddd, where d is a       Γöé
  8840. Γöé       Γöé            Γöé single-decimal digit, dddd is one or more Γöé
  8841. Γöé       Γöé            Γöé decimal digits, ddd is 2 or more decimal  Γöé
  8842. Γöé       Γöé            Γöé digits, and sign is + or -.               Γöé
  8843. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8844. Γöé E     Γöé Double     Γöé Identical to the "e" format except that   Γöé
  8845. Γöé       Γöé            Γöé "E" introduces the exponent instead of    Γöé
  8846. Γöé       Γöé            Γöé "e".                                      Γöé
  8847. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8848. Γöé g     Γöé Double     Γöé Signed value printed in "f" or "e"        Γöé
  8849. Γöé       Γöé            Γöé format.  The "e" format is used only when Γöé
  8850. Γöé       Γöé            Γöé the exponent of the value is less than -4 Γöé
  8851. Γöé       Γöé            Γöé or greater than precision.  Trailing      Γöé
  8852. Γöé       Γöé            Γöé zeros are truncated, and the decimal      Γöé
  8853. Γöé       Γöé            Γöé point appears only if one or more digits  Γöé
  8854. Γöé       Γöé            Γöé follow it.                                Γöé
  8855. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8856. Γöé G     Γöé Double     Γöé Identical to the "g" format except that   Γöé
  8857. Γöé       Γöé            Γöé "E" introduces the exponent (where appro- Γöé
  8858. Γöé       Γöé            Γöé priate) instead of "e".                   Γöé
  8859. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8860. Γöé c     Γöé Character  Γöé Single character.                         Γöé
  8861. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8862. Γöé s     Γöé String     Γöé Characters printed up to the first null   Γöé
  8863. Γöé       Γöé            Γöé character (\"0") or until precision is    Γöé
  8864. Γöé       Γöé            Γöé reached.                                  Γöé
  8865. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8866. Γöé n     Γöé Pointer to Γöé Number of characters successfully written Γöé
  8867. Γöé       Γöé integer    Γöé so far to the stream or buffer; this      Γöé
  8868. Γöé       Γöé            Γöé value is stored in the integer whose      Γöé
  8869. Γöé       Γöé            Γöé address is given as the argument.         Γöé
  8870. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8871. Γöé p     Γöé Pointer    Γöé Pointer to void converted to a sequence   Γöé
  8872. Γöé       Γöé            Γöé of printable characters.                  Γöé
  8873. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8874. Γöé "lc"  Γöé Wide char- Γöé Multibyte character.                      Γöé
  8875. Γöé       Γöé acter      Γöé                                           Γöé
  8876. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8877. Γöé "ls"  Γöé Wide       Γöé Multibyte characters printed up to the    Γöé
  8878. Γöé       Γöé string     Γöé first "wchar_t" null character ("L'\0'")  Γöé
  8879. Γöé       Γöé            Γöé or until precision is reached.            Γöé
  8880. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  8881.  
  8882. Related Information 
  8883.  
  8884. o printf  - Formatted Print 
  8885. o Format Specification - Flags 
  8886. o Format Specification - Width 
  8887. o Format Specification - Precision 
  8888. o Format Specification - h, l, L 
  8889.  
  8890.  
  8891. ΓòÉΓòÉΓòÉ 2.168.2. Format Specification - Flags ΓòÉΓòÉΓòÉ
  8892.  
  8893. The flag characters and their meanings are as follows (notice that more than 
  8894. one flag can appear in a format specification): 
  8895.  
  8896. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  8897. Γöé FLAG      Γöé MEANING                     Γöé DEFAULT              Γöé
  8898. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8899. Γöé -         Γöé Left-justify the result     Γöé Right-justify.       Γöé
  8900. Γöé           Γöé within the field width.     Γöé                      Γöé
  8901. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8902. Γöé +         Γöé Prefix the output value     Γöé Sign appears only    Γöé
  8903. Γöé           Γöé with a sign (+ or -) if the Γöé for negative signed  Γöé
  8904. Γöé           Γöé output value is of a signed Γöé values (-).          Γöé
  8905. Γöé           Γöé type.                       Γöé                      Γöé
  8906. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8907. Γöé blank(' ')Γöé Prefix the output value     Γöé No blank.            Γöé
  8908. Γöé           Γöé with a blank if the output  Γöé                      Γöé
  8909. Γöé           Γöé value is signed and posi-   Γöé                      Γöé
  8910. Γöé           Γöé tive.  The "Γö╝" flag over-   Γöé                      Γöé
  8911. Γöé           Γöé rides the blank flag if     Γöé                      Γöé
  8912. Γöé           Γöé both appear, and a positive Γöé                      Γöé
  8913. Γöé           Γöé signed value will be output Γöé                      Γöé
  8914. Γöé           Γöé with a sign.                Γöé                      Γöé
  8915. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8916. Γöé #         Γöé When used with the "o",     Γöé No prefix.           Γöé
  8917. Γöé           Γöé "x", or "X" formats, the    Γöé                      Γöé
  8918. Γöé           Γöé "#" flag prefixes any       Γöé                      Γöé
  8919. Γöé           Γöé nonzero output value with   Γöé                      Γöé
  8920. Γöé           Γöé "0", "0"x, or "0"X, respec- Γöé                      Γöé
  8921. Γöé           Γöé tively.                     Γöé                      Γöé
  8922. Γöé           Γö╝-----------------------------Γö╝----------------------Γöñ
  8923. Γöé           Γöé When used with the "f",     Γöé Decimal point        Γöé
  8924. Γöé           Γöé "e", or "E" formats, the    Γöé appears only if      Γöé
  8925. Γöé           Γöé "#" flag forces the output  Γöé digits follow it.    Γöé
  8926. Γöé           Γöé value to contain a decimal  Γöé                      Γöé
  8927. Γöé           Γöé point in all cases.         Γöé                      Γöé
  8928. Γöé           Γö╝-----------------------------Γö╝----------------------Γöñ
  8929. Γöé           Γöé When used with the "g" or   Γöé Decimal point        Γöé
  8930. Γöé           Γöé "G" formats, the "#" flag   Γöé appears only if      Γöé
  8931. Γöé           Γöé forces the output value to  Γöé digits follow it;    Γöé
  8932. Γöé           Γöé contain a decimal point in  Γöé trailing zeros are   Γöé
  8933. Γöé           Γöé all cases and prevents the  Γöé truncated.           Γöé
  8934. Γöé           Γöé truncation of trailing      Γöé                      Γöé
  8935. Γöé           Γöé zeros.                      Γöé                      Γöé
  8936. Γöé           Γö╝-----------------------------Γö╝----------------------Γöñ
  8937. Γöé           Γöé When used with the "ls"     Γöé Precision indicates  Γöé
  8938. Γöé           Γöé format, the "#" flag causes Γöé the maximum number   Γöé
  8939. Γöé           Γöé precision to be measured in Γöé of bytes to be       Γöé
  8940. Γöé           Γöé "wchar_t" characters.       Γöé output.              Γöé
  8941. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  8942. Γöé "0"       Γöé When used with the "d",     Γöé Space padding.       Γöé
  8943. Γöé           Γöé "i", "o", "u", "x", "X",    Γöé                      Γöé
  8944. Γöé           Γöé "e", "E", "f", "g", or "G"  Γöé                      Γöé
  8945. Γöé           Γöé formats, the "0" flag       Γöé                      Γöé
  8946. Γöé           Γöé causes leading "0"'s to pad Γöé                      Γöé
  8947. Γöé           Γöé the output to the field     Γöé                      Γöé
  8948. Γöé           Γöé width.  The "0" flag is     Γöé                      Γöé
  8949. Γöé           Γöé ignored if precision is     Γöé                      Γöé
  8950. Γöé           Γöé specified for an integer or Γöé                      Γöé
  8951. Γöé           Γöé if the "-" flag is speci-   Γöé                      Γöé
  8952. Γöé           Γöé fied.                       Γöé                      Γöé
  8953. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  8954.  
  8955. The # flag should not be used with c, lc, d, i, u, s, or p types. 
  8956.  
  8957. Related Information 
  8958.  
  8959. o printf  - Formatted Print 
  8960. o Format Specification - Types 
  8961. o Format Specification - Width 
  8962. o Format Specification - Precision 
  8963. o Format Specification - h, l, L 
  8964.  
  8965.  
  8966. ΓòÉΓòÉΓòÉ 2.168.3. Format Specification - Width ΓòÉΓòÉΓòÉ
  8967.  
  8968. Width is a nonnegative decimal integer controlling the minimum number of 
  8969. characters printed.  If the number of characters in the output value is less 
  8970. than the specified width, blanks are added on the left or the right (depending 
  8971. on whether the - flag is specified) until the minimum width is reached. 
  8972.  
  8973. Width never causes a value to be truncated;  if the number of characters in the 
  8974. output value is greater than the specified width, or width is not given, all 
  8975. characters of the value are printed (subject to the precision specification). 
  8976.  
  8977. For ls type, width is specified in bytes. If the number of bytes in the output 
  8978. value is less than the specified width, single byte blanks are added on the 
  8979. left or the right (depending on whether the "-" flag is specified) until the 
  8980. minimum width is reached. 
  8981.  
  8982. The width specification can be an asterisk (*), in which case an argument from 
  8983. the argument list supplies the value.  The width argument must precede the 
  8984. value being formatted in the argument list. 
  8985.  
  8986. Related Information 
  8987.  
  8988. o printf  - Formatted Print 
  8989. o Format Specification - Types 
  8990. o Format Specification - Flags 
  8991. o Format Specification - Precision 
  8992. o Format Specification - h, l, L 
  8993.  
  8994.  
  8995. ΓòÉΓòÉΓòÉ 2.168.4. Format Specification - Precision ΓòÉΓòÉΓòÉ
  8996.  
  8997. Precision is a nonnegative decimal integer preceded by a period, which 
  8998. specifies the number of characters to be printed or the number of decimal 
  8999. places.  Unlike the width specification, the precision can cause truncation of 
  9000. the output value or rounding of a floating-point value. 
  9001.  
  9002. The precision specification can be an asterisk (*), in which case an argument 
  9003. from the argument list supplies the value.  The precision argument must precede 
  9004. the value being formatted in the argument list. 
  9005.  
  9006. The interpretation of the precision value and the default when the precision is 
  9007. omitted depend upon the type, as shown in the following table. 
  9008.  
  9009. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  9010. Γöé TYPE  Γöé MEANING                         Γöé DEFAULT              Γöé
  9011. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9012. Γöé    i  Γöé Precision specifies the minimum Γöé If precision is 0 or Γöé
  9013. Γöé    d  Γöé number of digits to be printed. Γöé omitted entirely, or Γöé
  9014. Γöé    u  Γöé If the number of digits in the  Γöé if the period (.)    Γöé
  9015. Γöé    o  Γöé argument is less than           Γöé appears without a    Γöé
  9016. Γöé    x  Γöé precision, the output value is  Γöé number following it, Γöé
  9017. Γöé    X  Γöé padded on the left with zeros.  Γöé the precision is set Γöé
  9018. Γöé       Γöé The value is not truncated when Γöé to 1.                Γöé
  9019. Γöé       Γöé the number of digits exceeds    Γöé                      Γöé
  9020. Γöé       Γöé precision.                      Γöé                      Γöé
  9021. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9022. Γöé    f  Γöé Precision specifies the number  Γöé Default precision is Γöé
  9023. Γöé    e  Γöé of digits to be printed after   Γöé six.  If precision   Γöé
  9024. Γöé    E  Γöé the decimal point.  The last    Γöé is zero or the       Γöé
  9025. Γöé       Γöé digit printed is rounded.       Γöé period appears       Γöé
  9026. Γöé       Γöé                                 Γöé without a number     Γöé
  9027. Γöé       Γöé                                 Γöé following it, no     Γöé
  9028. Γöé       Γöé                                 Γöé decimal point is     Γöé
  9029. Γöé       Γöé                                 Γöé printed.             Γöé
  9030. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9031. Γöé    g  Γöé Precision specifies the maximum Γöé All significant      Γöé
  9032. Γöé    G  Γöé number of significant digits    Γöé digits are printed.  Γöé
  9033. Γöé       Γöé printed.                        Γöé                      Γöé
  9034. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9035. Γöé    c  Γöé No effect.                      Γöé Character printed.   Γöé
  9036. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9037. Γöé    lc Γöé No effect.                      Γöé "wchar_t" character  Γöé
  9038. Γöé       Γöé                                 Γöé printed.             Γöé
  9039. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9040. Γöé    s  Γöé Precision specifies the maximum Γöé Characters are       Γöé
  9041. Γöé       Γöé number of characters to be      Γöé printed until a null Γöé
  9042. Γöé       Γöé printed.  Characters in excess  Γöé character is         Γöé
  9043. Γöé       Γöé of precision are not printed.   Γöé encountered.         Γöé
  9044. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9045. Γöé    ls Γöé Precision specifies the maximum Γöé "wchar_t" characters Γöé
  9046. Γöé       Γöé number of bytes to be printed.  Γöé are printed until a  Γöé
  9047. Γöé       Γöé Bytes in excess of precision    Γöé null character is    Γöé
  9048. Γöé       Γöé are not printed, however multi- Γöé encountered.         Γöé
  9049. Γöé       Γöé byte integrity is always pre-   Γöé                      Γöé
  9050. Γöé       Γöé served.                         Γöé                      Γöé
  9051. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  9052.  
  9053. Related Information 
  9054.  
  9055. o printf  - Formatted Print 
  9056. o Format Specification - Types 
  9057. o Format Specification - Flags 
  9058. o Format Specification - Width 
  9059. o Format Specification - h, l, L 
  9060.  
  9061.  
  9062. ΓòÉΓòÉΓòÉ 2.168.5. Format Specification - h, l, L ΓòÉΓòÉΓòÉ
  9063.  
  9064. The h, l, and L characters specify the size of the expected argument.  Their 
  9065. meanings are as follows: 
  9066.  
  9067. h    A prefix with the integer types d, i, o, u, x, X, and n that specifies 
  9068.      that the argument is short int or unsigned short int. 
  9069.  
  9070. l    A prefix with d, i, o, u, x, X, and n types that specifies that the 
  9071.      argument is a long int or unsigned long int. 
  9072.  
  9073. L    A prefix with e, E, f, g, or G types that specifies that the argument is 
  9074.      long double. 
  9075.  
  9076. Related Information 
  9077.  
  9078. o printf  - Formatted Print 
  9079. o Format Specification - Types 
  9080. o Format Specification - Flags 
  9081. o Format Specification - Width 
  9082. o Format Specification - Precision 
  9083.  
  9084.  
  9085. ΓòÉΓòÉΓòÉ 2.169. putc - putchar  - Write a Character ΓòÉΓòÉΓòÉ
  9086.  
  9087. Language Level: ANSI, SAA 
  9088.  
  9089. Description 
  9090.  
  9091. The putc function converts c to unsigned char and then writes c to the output 
  9092. stream at the current position.  The putchar function is identical to 
  9093. putc(c, stdout). 
  9094.  
  9095. The putc and putchar functions return the character written.  A return value of 
  9096. EOF indicates an error. 
  9097.  
  9098. The putc function can be implemented as a macro so the argument may be 
  9099. evaluated multiple times. 
  9100.  
  9101. Example of putc - putchar 
  9102.  
  9103. Related Information 
  9104.  
  9105. o fputc  - Write a Character 
  9106. o _fputchar - Write Character 
  9107. o fwrite  - Write Items 
  9108. o getc - getchar  - Read a Character 
  9109. o _putch - Write Character to Screen 
  9110. o puts  - Write a String 
  9111. o stdio.h 
  9112.  
  9113.  
  9114. ΓòÉΓòÉΓòÉ 2.170. _putch - Write Character to Screen ΓòÉΓòÉΓòÉ
  9115.  
  9116. #include <conio.h>
  9117.  
  9118. int _putch(int c);
  9119.  
  9120. Language Level: Extension 
  9121.  
  9122. Description 
  9123.  
  9124. The _putch function writes the character c directly to the screen. 
  9125.  
  9126. If successful, _putch returns c. If an error occurs, _putch returns EOF. 
  9127.  
  9128. Example of _putch 
  9129.  
  9130. Related Information 
  9131.  
  9132. o _cputs - Write String to Screen 
  9133. o _cprintf - Print Characters to Screen 
  9134. o putc - putchar  - Write a Character 
  9135. o _getch - _getche - Read Character from Keyboard 
  9136. o conio.h 
  9137.  
  9138.  
  9139. ΓòÉΓòÉΓòÉ 2.171. _putenv - Modify Environment Variables ΓòÉΓòÉΓòÉ
  9140.  
  9141. #include <stdlib.h>
  9142.  
  9143. int _putenv(char *envstring);
  9144.  
  9145. Language Level: Extension 
  9146.  
  9147. Description 
  9148.  
  9149. The _putenv function adds new environment variables or modifies the values of 
  9150. existing environment variables. Environment variables define the environment in 
  9151. which a process runs (for example, the default search path for libraries to be 
  9152. linked with a program). 
  9153.  
  9154. The envstring argument must be a pointer to a string with the form: 
  9155.  
  9156.    varname=string
  9157.  
  9158. where varname is the name of the environment variable to be added or modified 
  9159. and string is the value of the variable. See the Notes below. 
  9160.  
  9161. If varname is already part of the environment, string replaces its current 
  9162. value; if not, the new varname is added to the environment with the value 
  9163. string. To set a variable to an empty value, specify an empty string. A 
  9164. variable can be removed from the environment by specifying varname only, for 
  9165. example, 
  9166.  
  9167.    _putenv("PATH");
  9168.  
  9169. Do not free a pointer to an environment entry while the environment entry is 
  9170. still in use.  The environment variable will point into freed space. A similar 
  9171. problem can occur if you pass a pointer to a local variable to _putenv and then 
  9172. exit from the function in which the variable is declared. 
  9173.  
  9174. The environment manipulated by _putenv is local to the process currently 
  9175. running. You cannot enter new items in your command level environment using 
  9176. _putenv. When the program ends, the environment reverts to the parent process 
  9177. environment. This environment is passed on to some child processes created by 
  9178. spawn or exec and to system, and they get any new environment variables added 
  9179. using _putenv. 
  9180.  
  9181. DosScanEnv will not reflect any changes made using the _putenv function, but 
  9182. getenv will reflect any changes made by _putenv. 
  9183.  
  9184. Notes 
  9185.  
  9186.  1. The _putenv function can change the value of _environ, thus invalidating 
  9187.     the envp argument to the main function. 
  9188.  
  9189.  2. %envvar%, where envvar is any OS/2 environment variable, cannot be used 
  9190.     with _putenv to concatenate new envstring and old envstring. 
  9191.  
  9192. The _putenv function returns 0 if it is successful.  A return value of -1 
  9193. indicates an error. 
  9194.  
  9195. Example of _putenv 
  9196.  
  9197. Related Information 
  9198.  
  9199. o _execl - _execvp - Load and Run Child Process 
  9200. o getenv  - Search for Environment Variables 
  9201. o _spawnl - _spawnvpe - Start and Run Child Processes 
  9202. o system - Invoke the Command Processor 
  9203. o envp Argument to main 
  9204. o stdlib.h 
  9205.  
  9206.  
  9207. ΓòÉΓòÉΓòÉ 2.172. puts  - Write a String ΓòÉΓòÉΓòÉ
  9208.  
  9209. #include <stdio.h>
  9210.  
  9211. int puts(const char *string);
  9212.  
  9213. Language Level: ANSI, SAA 
  9214.  
  9215. Description 
  9216.  
  9217. The puts function writes the given string to the standard output stream stdout; 
  9218. it also appends a new line character to the output.  The terminating null 
  9219. character is not written. 
  9220.  
  9221. The puts function returns EOF if an error occurs.  A non-negative return value 
  9222. indicates that no error has occurred. 
  9223.  
  9224. Example of puts 
  9225.  
  9226. Related Information 
  9227.  
  9228. o fputs  - Print Strings 
  9229. o gets  - Read a Line 
  9230. o putc - putchar  - Write a Character 
  9231. o stdio.h 
  9232.  
  9233.  
  9234. ΓòÉΓòÉΓòÉ 2.173. qsort  - Sort Array ΓòÉΓòÉΓòÉ
  9235.  
  9236. #include <stdlib.h>
  9237.  
  9238. void qsort(void *base, size_t num, size_t width,
  9239.            int(*compare)(const void *element1, const void *element2));
  9240.  
  9241. Language Level: ANSI, SAA, Extension 
  9242.  
  9243. Description 
  9244.  
  9245. The qsort function sorts an array of num elements, each of width bytes in size. 
  9246. The base pointer is a pointer to the array to be sorted.  The qsort function 
  9247. overwrites this array with the sorted elements. 
  9248.  
  9249. The compare pointer points to a function, which you supply, that compares two 
  9250. array elements and returns an integer value specifying their relationship.  The 
  9251. qsort function calls the compare function one or more times during the sort, 
  9252. passing pointers to two array elements on each call.  The function must compare 
  9253. the elements, then return one of the following values: 
  9254.  
  9255. Value               Meaning 
  9256. Less than 0         element1 less than element2 
  9257. 0                   element1 equal to element2 
  9258. Greater than 0      element1 greater than element2 
  9259.  
  9260. The sorted array elements are stored in increasing order, as defined by your 
  9261. comparison function.  You can sort in reverse order by reversing the sense of 
  9262. "greater than" and "less than" in the comparison function.  The order of the 
  9263. elements is unspecified when two elements compare equally. 
  9264.  
  9265. There is no return value. 
  9266.  
  9267. Example of qsort 
  9268.  
  9269. Related Information 
  9270.  
  9271. o bsearch  - Search Arrays 
  9272. o search.h 
  9273. o stdlib.h 
  9274.  
  9275.  
  9276. ΓòÉΓòÉΓòÉ 2.174. raise  - Send Signal ΓòÉΓòÉΓòÉ
  9277.  
  9278. #include <signal.h>
  9279.  
  9280. int raise(int sig);
  9281.  
  9282. Language Level: ANSI, SAA 
  9283.  
  9284. Description 
  9285.  
  9286. The raise function sends the signal sig to the running program.  The return 
  9287. value is zero if successful, nonzero if unsuccessful. 
  9288.  
  9289. Example of raise 
  9290.  
  9291. Related Information 
  9292.  
  9293. o signal - Install Interrupt Handlers 
  9294. o signal.h 
  9295.  
  9296.  
  9297. ΓòÉΓòÉΓòÉ 2.175. rand  - Generate Random Number ΓòÉΓòÉΓòÉ
  9298.  
  9299. #include <stdlib.h>
  9300.  
  9301. int rand(void);
  9302.  
  9303. Language Level: ANSI, SAA 
  9304.  
  9305. Description 
  9306.  
  9307. The rand function returns a pseudo-random integer in the range 0 to RAND_MAX 
  9308. (macro defined in <stdlib.h>).  Use the srand function before calling rand to 
  9309. set a starting point for the random number generator. If you do not make a call 
  9310. to srand, the default seed is 1. 
  9311.  
  9312. Example of rand 
  9313.  
  9314. Related Information 
  9315.  
  9316. o srand  - Set Seed for rand Function 
  9317. o stdlib.h 
  9318.  
  9319.  
  9320. ΓòÉΓòÉΓòÉ 2.176. _read - Read Into Buffer ΓòÉΓòÉΓòÉ
  9321.  
  9322. #include <io.h>
  9323.  
  9324. int _read(int handle, char *buffer, unsigned int count);
  9325.  
  9326. Language Level: Extension 
  9327.  
  9328. Description 
  9329.  
  9330. The _read function tries to read count bytes from the file associated with 
  9331. handle into buffer. The read operation begins at the current position of the 
  9332. file pointer associated with the given file. After the read operation, the file 
  9333. pointer points to the next unread character. 
  9334.  
  9335. The _read function returns the number of bytes placed in buffer. This number 
  9336. can be less than count if there are fewer than count  bytes left in the file or 
  9337. if the file was opened in text mode (see the note below). The return value 0 
  9338. indicates an attempt to read at end-of-file. A return value -1 indicates an 
  9339. error. If -1 is returned, the current file position is undefined, and errno is 
  9340. set to the following values: 
  9341.  
  9342. Value          Meaning 
  9343. EBADF          The given handle is incorrect, or the file is not open for 
  9344.                reading, or the file is locked. 
  9345. EOS2ERR        The call to the operating system was not successful. 
  9346.  
  9347. Note:  If the file was opened in text mode, the return value might not 
  9348. correspond to the number of bytes actually read. When text mode is in effect, 
  9349. carriage return characters are deleted from the input stream, without affecting 
  9350. the file pointer. 
  9351.  
  9352. Example of _read 
  9353.  
  9354. Related Information 
  9355.  
  9356. o _creat - Create New File 
  9357. o _open - Open File 
  9358. o _sopen - Open Shared File 
  9359. o _write - Writes from Buffer to File 
  9360. o io.h 
  9361.  
  9362.  
  9363. ΓòÉΓòÉΓòÉ 2.177. realloc  - Change Reserved Storage Block Size ΓòÉΓòÉΓòÉ
  9364.  
  9365. #include <stdlib.h>
  9366.  
  9367. void *realloc(void *ptr, size_t size);
  9368.  
  9369. Language Level: ANSI, SAA, Extension 
  9370.  
  9371. Description 
  9372.  
  9373. The realloc function changes the size of a previously-reserved storage block. 
  9374. The ptr argument points to the beginning of the block.  The size argument gives 
  9375. the new size of the block, in bytes.  The contents of the block are unchanged 
  9376. up to the shorter of the new and old sizes. 
  9377.  
  9378. If the ptr is NULL, realloc reserves a block of storage of size bytes. It does 
  9379. not necessarily give all bits of each element an initial value of zero (0). 
  9380.  
  9381. If size is zero and the ptr is not NULL, the storage allocated to ptr is freed 
  9382. and NULL is returned. 
  9383.  
  9384. The realloc function returns a pointer to the reallocated storage block.  The 
  9385. storage location of the block might be moved by the realloc function.  Thus, 
  9386. the ptr argument to realloc is not necessarily the same as the return value. 
  9387.  
  9388. The return value is NULL if size is 0. If there is not enough storage to expand 
  9389. the block to the given size, the original block is unchanged and NULL is 
  9390. returned. 
  9391.  
  9392. The storage to which the return value points is guaranteed to be aligned for 
  9393. storage of any type of object. 
  9394.  
  9395. Example of realloc 
  9396.  
  9397. Related Information 
  9398.  
  9399. o calloc  - Reserve and Initialize Storage 
  9400. o _debug_realloc - Change Reserved Storage Block Size 
  9401. o free  - Release Storage Blocks 
  9402. o malloc  - Reserve Storage Block 
  9403. o malloc.h 
  9404. o stdlib.h 
  9405.  
  9406.  
  9407. ΓòÉΓòÉΓòÉ 2.178. remove  - Delete File ΓòÉΓòÉΓòÉ
  9408.  
  9409. #include <stdio.h>
  9410.  
  9411. int remove(const char *filename);
  9412.  
  9413. Language Level: ANSI, SAA 
  9414.  
  9415. Description 
  9416.  
  9417. The remove function deletes the file specified by filename.  The remove 
  9418. function returns the value 0 if it successfully deletes the file. A return 
  9419. value of nonzero indicates an error. 
  9420.  
  9421. Note:  You cannot remove a non-existent file or a file that is open. 
  9422.  
  9423. Example of remove 
  9424.  
  9425. Related Information 
  9426.  
  9427. o fopen  - Open Files 
  9428. o rename  - Rename File 
  9429. o _unlink - Delete File 
  9430. o stdio.h 
  9431.  
  9432.  
  9433. ΓòÉΓòÉΓòÉ 2.179. rename  - Rename File ΓòÉΓòÉΓòÉ
  9434.  
  9435. #include <stdio.h>
  9436.  
  9437. int rename(const char *oldname, const char *newname);
  9438.  
  9439. Language Level: ANSI, SAA 
  9440.  
  9441. Description 
  9442.  
  9443. The rename function renames the file specified by oldname to the name given by 
  9444. newname.  The oldname pointer must specify the name of an existing file.  The 
  9445. newname pointer must not specify the name of an existing file. You cannot 
  9446. rename a file with the name of an existing file. You also cannot rename an open 
  9447. file. 
  9448.  
  9449. The rename function returns 0 if it is successful.  On an error, it returns a 
  9450. nonzero value. 
  9451.  
  9452. Example of rename 
  9453.  
  9454. Related Information 
  9455.  
  9456. o fopen  - Open Files 
  9457. o remove  - Delete File 
  9458. o stdio.h 
  9459.  
  9460.  
  9461. ΓòÉΓòÉΓòÉ 2.180. rewind  - Adjust Current File Position ΓòÉΓòÉΓòÉ
  9462.  
  9463. #include <stdio.h>
  9464.  
  9465. void rewind(FILE *stream);
  9466.  
  9467. Language Level: ANSI, SAA 
  9468.  
  9469. Description 
  9470.  
  9471. The rewind function repositions the file pointer associated with stream to the 
  9472. beginning of the file.  A call to rewind is the same as: 
  9473.  
  9474.    (void) fseek(stream, 0L, SEEK_SET);
  9475. except that rewind also clears the error indicator for the stream. 
  9476.  
  9477. There is no return value. 
  9478.  
  9479. Example of rewind 
  9480.  
  9481. Related Information 
  9482.  
  9483. o fgetpos  - Get File Position 
  9484. o fseek  - Reposition File Position 
  9485. o fsetpos  - Set File Position 
  9486. o ftell  - Get Current Position 
  9487. o stdio.h 
  9488.  
  9489.  
  9490. ΓòÉΓòÉΓòÉ 2.181. _rmdir - Remove Directory ΓòÉΓòÉΓòÉ
  9491.  
  9492. #include <direct.h>
  9493.  
  9494. int _rmdir(char *pathname);
  9495.  
  9496. Language Level: Extension 
  9497.  
  9498. Description 
  9499.  
  9500. The _rmdir function deletes the directory specified by pathname.  The directory 
  9501. must be empty, and it must not be the current working directory or the root 
  9502. directory. 
  9503.  
  9504. The _rmdir function returns the value 0 if the directory is successfully 
  9505. deleted.  A return value of -1 indicates an error, and errno is set to one of 
  9506. the following values: 
  9507.  
  9508. Value          Meaning 
  9509.  
  9510. EACCESS        One of the following has occurred: 
  9511.  
  9512.    o The given path name is not a directory. 
  9513.    o The directory is not empty. 
  9514.    o The directory is read only. 
  9515.    o The directory is the current working directory or root directory being 
  9516.      used by a process. 
  9517.  
  9518. ENOENT         The path name was not found. 
  9519.  
  9520. An alternative to this function is the DosDeleteDir API call. 
  9521.  
  9522. Example of _rmdir 
  9523.  
  9524. Related Information 
  9525.  
  9526. o _chdir - Change Current Working Directory 
  9527. o _getdcwd - Get Full Path Name of Current Directory 
  9528. o _getcwd - Get Path Name of Current Directory 
  9529. o _mkdir - Create New Directory 
  9530. o direct.h 
  9531.  
  9532.  
  9533. ΓòÉΓòÉΓòÉ 2.182. _rmtmp - Remove Temporary Files ΓòÉΓòÉΓòÉ
  9534.  
  9535. #include <stdio.h>
  9536.  
  9537. int _rmtmp(void);
  9538.  
  9539. Language Level: Extension 
  9540.  
  9541. Description 
  9542.  
  9543. The _rmtmp function closes and deletes all temporary files in all directories 
  9544. that are held open by the calling process. 
  9545.  
  9546. The _rmtmp function returns the number of temporary files removed and deleted. 
  9547.  
  9548. Example of _rmtmp 
  9549.  
  9550. Related Information 
  9551.  
  9552. o _flushall - Write Buffers to Files 
  9553. o tmpfile  - Create Temporary File 
  9554. o tmpnam  - Produce Temporary File Name 
  9555. o stdio.h 
  9556.  
  9557.  
  9558. ΓòÉΓòÉΓòÉ 2.183. _rotl - _rotr - Bit Rotation ΓòÉΓòÉΓòÉ
  9559.  
  9560. #include <stdlib.h>
  9561.  
  9562. unsigned int _rotl(unsigned int value, int shift);
  9563.  
  9564. unsigned int _rotr(unsigned int value, int shift);
  9565.  
  9566. Language Level: Extension 
  9567.  
  9568. Description 
  9569.  
  9570. These functions take a 4-byte integer value and rotate it by shift bits. 
  9571.  
  9572. Note:  Because the size of an int is only 2 bytes in the C/2 compiler, some 
  9573. parts of your programs may have to be rewritten if they use this function. 
  9574.  
  9575. Both functions return the rotated value.  There is no error return. 
  9576.  
  9577. Example of _rotl - _rotr 
  9578.  
  9579. Related Information 
  9580.  
  9581. o _lrotl - _lrotr - Rotate Bits 
  9582. o stdlib.h 
  9583.  
  9584.  
  9585. ΓòÉΓòÉΓòÉ 2.184. scanf  - Read Data ΓòÉΓòÉΓòÉ
  9586.  
  9587. #include <stdio.h>
  9588.  
  9589. int scanf(const char *format-string, argument-list);
  9590.  
  9591. Language Level: ANSI, SAA, Extension 
  9592.  
  9593. Description 
  9594.  
  9595. The scanf function reads data from the standard input stream stdin into the 
  9596. locations given by each entry in argument-list.  Each argument must be a 
  9597. pointer to a variable with a type that corresponds to a type specifier in 
  9598. format-string.  The format-string controls the interpretation of the input 
  9599. fields, and is a multibyte character string beginning and ending in its initial 
  9600. shift state. 
  9601.  
  9602. The format-string can contain one or more of the following: 
  9603.  
  9604. o White-space characters, as specified by isspace (such as blanks and new 
  9605.   lines).  A white-space character causes scanf to read, but not to store, all 
  9606.   consecutive white-space characters in the input up to the next character that 
  9607.   is not white space.  One white-space character in format-string matches any 
  9608.   combination of white-space characters in the input. 
  9609.  
  9610. o Characters that are not white space, except for the percent sign character 
  9611.   (%).  A non-white-space character causes scanf to read, but not to store, a 
  9612.   matching non-white-space character.  If the next character in stdin does not 
  9613.   match, scanf ends. 
  9614.  
  9615. o Format specifications, introduced by the percent sign (%).  A format 
  9616.   specification causes scanf to read and convert characters in the input into 
  9617.   values of a specified type.  The value is assigned to an argument in the 
  9618.   argument list. 
  9619.  
  9620. The scanf function reads format-string from left to right.  Characters outside 
  9621. of format specifications are expected to match the sequence of characters in 
  9622. stdin;  the matched characters in stdin are scanned but not stored.  If a 
  9623. character in stdin conflicts with format-string, scanf ends.  The conflicting 
  9624. character is left in stdin as if it had not been read. 
  9625.  
  9626. When the first format specification is found, the value of the first input 
  9627. field is converted according to the format specification and stored in the 
  9628. location specified by the first entry in argument-list.  The second format 
  9629. specification converts the second input field and stores it in the second entry 
  9630. in argument-list, and so on through the end of format-string. 
  9631.  
  9632. An input field is defined as all characters up to the first white-space 
  9633. character (space, tab, or new line), up to the first character that cannot be 
  9634. converted according to the format specification, or until the field width is 
  9635. reached, whichever comes first.  If there are too many arguments for the format 
  9636. specifications, the extra arguments are ignored.  The results are undefined if 
  9637. there are not enough arguments for the format specifications. 
  9638.  
  9639. A format specification has the following form: 
  9640.  
  9641. ΓöÇΓöÇ%ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇtypeΓöÇΓöÇ
  9642.        Γöé     Γöé  Γöé         Γöé  Γöé     Γöé
  9643.        ΓööΓöÇΓöÇ*ΓöÇΓöÇΓöÿ  ΓööΓöÇΓöÇwidthΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇhΓöÇΓöÇΓöñ
  9644.                              Γöé     Γöé
  9645.                              Γö£ΓöÇΓöÇlΓöÇΓöÇΓöñ
  9646.                              Γöé     Γöé
  9647.                              ΓööΓöÇΓöÇLΓöÇΓöÇΓöÿ
  9648.  
  9649. Each field of the format specification is a single character or a number 
  9650. signifying a particular format option.  The type character, which appears after 
  9651. the last optional format field, determines whether the input field is 
  9652. interpreted as a character, a string, or a number.  The simplest format 
  9653. specification contains only the percent sign and a type character (for example, 
  9654. %s). 
  9655.  
  9656. Each field of the format specification is discussed in Format Specification 
  9657. Fields. If a percent sign (%) is followed by a character that has no meaning as 
  9658. a format control character, that character and following characters up to the 
  9659. next percent sign are treated as an ordinary sequence of characters;  that is, 
  9660. a sequence of characters that must match the input.  For example, to specify a 
  9661. percent-sign character, use %%. 
  9662.  
  9663. The scanf function scans each input field character by character.  It might 
  9664. stop reading a particular input field either before it reaches a space 
  9665. character, when the specified width is reached, or when the next character 
  9666. cannot be converted as specified.  When a conflict occurs between the 
  9667. specification and the input character, the next input field begins at the first 
  9668. unread character.  The conflicting character, if there was one, is considered 
  9669. unread and is the first character of the next input field or the first 
  9670. character in subsequent read operations on stdin. 
  9671.  
  9672. In extended mode, scanf also reads in the strings the strings "INFINITY", 
  9673. "INF", and "NAN" (in upper or lowercase) and converts them to the corresponding 
  9674. floating-point value.  The sign of the value is determined by the format 
  9675. specification. See Infinity and NaN Support for more information on infinity 
  9676. and NaN values. 
  9677.  
  9678. The scanf function returns the number of fields that were successfully 
  9679. converted and assigned.  The return value does not include fields that were 
  9680. read but not assigned. 
  9681.  
  9682. The return value is EOF for an attempt to read at end-of-file if no conversion 
  9683. was performed. A return value of 0 means that no fields were assigned. 
  9684.  
  9685. Example of scanf 
  9686.  
  9687. Related Information 
  9688.  
  9689. o fscanf  - Read Formatted Data 
  9690. o printf  - Formatted Print 
  9691. o sscanf  - Read Data 
  9692. o Infinity and NaN Support 
  9693. o stdio.h 
  9694.  
  9695.  
  9696. ΓòÉΓòÉΓòÉ 2.184.1. Format Specification Fields ΓòÉΓòÉΓòÉ
  9697.  
  9698. The scanf format specification fields are described below. 
  9699.  
  9700.  
  9701. An asterisk (*) following the percent sign suppresses assignment of the next 
  9702. input field, which is interpreted as a field of the specified type.  The field 
  9703. is scanned but not stored. 
  9704.  
  9705. width 
  9706.  
  9707. The width is a positive decimal integer controlling the maximum number of 
  9708. characters to be read from stdin.  No more than width characters are converted 
  9709. and stored at the corresponding argument.  Fewer than width characters are read 
  9710. if a white-space character (space, tab, or new line), or a character that 
  9711. cannot be converted according to the given format occurs before width is 
  9712. reached. 
  9713.  
  9714. h, l, L 
  9715.  
  9716. The optional prefix l shows that you use the long version of the following 
  9717. type, while the prefix h indicates that the short version is to be used.  The 
  9718. corresponding argument should point to a long or double object (for the l 
  9719. character), a long double object (for the L character), or a short object (with 
  9720. the h character).  The l and h modifiers can be used with the d, i, o, x, and u 
  9721. type characters. The l modifier can also be used with the e, f, and g type 
  9722. characters.  The L modifier can be used with the e, f and g type characters. 
  9723. The l and h modifiers are ignored if specified for any other type. Note that 
  9724. the l modifier is also used with the c and s characters to indicate a multibyte 
  9725. character or string. 
  9726.  
  9727. type 
  9728.  
  9729. The type characters and their meanings are in the following table: 
  9730.  
  9731. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  9732. Γöé CHAR-  Γöé TYPE OF INPUT EXPECTED    Γöé TYPE OF ARGUMENT          Γöé
  9733. Γöé ACTER  Γöé                           Γöé                           Γöé
  9734. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9735. Γöé "d"    Γöé Decimal integer           Γöé Pointer to "int"          Γöé
  9736. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9737. Γöé "o"    Γöé Octal integer             Γöé Pointer to "unsigned int" Γöé
  9738. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9739. Γöé "x",   Γöé Hexadecimal integer       Γöé Pointer to "unsigned int" Γöé
  9740. Γöé "X"    Γöé                           Γöé                           Γöé
  9741. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9742. Γöé "i"    Γöé Decimal, hexadecimal, or  Γöé Pointer to "int"          Γöé
  9743. Γöé        Γöé octal integer             Γöé                           Γöé
  9744. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9745. Γöé "u"    Γöé Unsigned decimal integer  Γöé Pointer to "unsigned int" Γöé
  9746. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9747. Γöé "e, f, Γöé Floating-point value con- Γöé Pointer to "float"        Γöé
  9748. Γöé g"     Γöé sisting of an optional    Γöé                           Γöé
  9749. Γöé        Γöé sign (+ or -);  a series  Γöé                           Γöé
  9750. Γöé "E, G" Γöé of one or more decimal    Γöé                           Γöé
  9751. Γöé        Γöé digits possibly con-      Γöé                           Γöé
  9752. Γöé        Γöé taining a decimal point;  Γöé                           Γöé
  9753. Γöé        Γöé and an optional exponent  Γöé                           Γöé
  9754. Γöé        Γöé (e or E) followed by a    Γöé                           Γöé
  9755. Γöé        Γöé possibly signed integer   Γöé                           Γöé
  9756. Γöé        Γöé value                     Γöé                           Γöé
  9757. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9758. Γöé "c"    Γöé Character;  white-space   Γöé Pointer to "char" large   Γöé
  9759. Γöé        Γöé characters that are ordi- Γöé enough for input field    Γöé
  9760. Γöé        Γöé narily skipped are read   Γöé                           Γöé
  9761. Γöé        Γöé when "c" is specified     Γöé                           Γöé
  9762. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9763. Γöé "s"    Γöé String                    Γöé Pointer to character      Γöé
  9764. Γöé        Γöé                           Γöé array large enough for    Γöé
  9765. Γöé        Γöé                           Γöé input field plus a termi- Γöé
  9766. Γöé        Γöé                           Γöé nating null character     Γöé
  9767. Γöé        Γöé                           Γöé (\0), which is automat-   Γöé
  9768. Γöé        Γöé                           Γöé ically appended           Γöé
  9769. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9770. Γöé "n"    Γöé No input read from stream Γöé Pointer to "int", into    Γöé
  9771. Γöé        Γöé or buffer                 Γöé which is stored the       Γöé
  9772. Γöé        Γöé                           Γöé number of characters suc- Γöé
  9773. Γöé        Γöé                           Γöé cessfully read from the   Γöé
  9774. Γöé        Γöé                           Γöé stream or buffer up to    Γöé
  9775. Γöé        Γöé                           Γöé that point in the call to Γöé
  9776. Γöé        Γöé                           Γöé "scanf"                   Γöé
  9777. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9778. Γöé "p"    Γöé Pointer to void converted Γöé Pointer to void           Γöé
  9779. Γöé        Γöé to series of characters.  Γöé                           Γöé
  9780. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9781. Γöé "lc"   Γöé Multibyte character con-  Γöé Pointer to "wchar_t"      Γöé
  9782. Γöé        Γöé stant                     Γöé                           Γöé
  9783. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9784. Γöé "ls"   Γöé Multibyte string constant Γöé Pointer to "wchar_t"      Γöé
  9785. Γöé        Γöé                           Γöé string                    Γöé
  9786. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  9787.  
  9788. To read strings not delimited by space characters, substitute a set of 
  9789. characters in brackets ([ ]) for the s (string) type character.  The 
  9790. corresponding input field is read up to the first character that does not 
  9791. appear in the bracketed character set.  If the first character in the set is a 
  9792. caret (^), the effect is reversed:  the input field is read up to the first 
  9793. character that does appear in the rest of the character set. 
  9794.  
  9795. To store a string without storing an ending null character (\0), use the 
  9796. specification %ac, where a is a decimal integer.  In this instance, the c type 
  9797. character means that the argument is a pointer to a character array.  The next 
  9798. a characters are read from the input stream into the specified location, and no 
  9799. null character (\0) is added. 
  9800.  
  9801. The input for a %x format specifier is interpreted as a hexadecimal number. 
  9802.  
  9803.  
  9804. ΓòÉΓòÉΓòÉ 2.185. _searchenv - Search for File ΓòÉΓòÉΓòÉ
  9805.  
  9806. #include <stdlib.h>
  9807.  
  9808. void _searchenv(char *name, char *env_var, char *path);
  9809.  
  9810. Language Level: Extension 
  9811.  
  9812. Description 
  9813.  
  9814. The _searchenv function searches for the target file in the specified domain. 
  9815. The env_var variable can be any environment variable that specifies a list of 
  9816. directory paths, such as PATH, LIB, INCLUDE, or other user-defined variables. 
  9817. Most often, it is PATH, causing a search for name in all directories specified 
  9818. in the PATH variable. 
  9819.  
  9820. The routine first searches for the file in the current working directory.  If 
  9821. it does not find the file, it next looks through the directories specified by 
  9822. the environment variable. 
  9823.  
  9824. If the target file is found in one of the directories, the newly created path 
  9825. is copied into the buffer that path points to.  You must ensure sufficient 
  9826. space for the constructed path name.  If the target file is not found, path 
  9827. contains an empty null-terminated string. 
  9828.  
  9829. An alternative to this function is the DosSearchPath API call. 
  9830.  
  9831. There is no return value. 
  9832.  
  9833. Example of _searchenv 
  9834.  
  9835. Related Information 
  9836.  
  9837. o getenv  - Search for Environment Variables 
  9838. o _putenv - Modify Environment Variables 
  9839. o stdlib.h 
  9840.  
  9841.  
  9842. ΓòÉΓòÉΓòÉ 2.186. setbuf  - Control Buffering ΓòÉΓòÉΓòÉ
  9843.  
  9844. #include <stdio.h>
  9845.  
  9846. void setbuf(FILE *stream, char *buffer);
  9847.  
  9848. Language Level: ANSI, SAA 
  9849.  
  9850. Description 
  9851.  
  9852. If the operating system supports user-defined buffers, the setbuf function 
  9853. allows you to control buffering for the specified stream.  The stream pointer 
  9854. must refer to an open file before any I/O or repositioning has been done. 
  9855.  
  9856. If the buffer argument is NULL, the stream is unbuffered.  If not, the buffer 
  9857. must point to a character array of length BUFSIZ, which is the buffer size 
  9858. defined in the stdio.h header file.  The system uses the buffer, which you 
  9859. specify, for input/output buffering instead of the default system-allocated 
  9860. buffer for the given stream. 
  9861.  
  9862. There is no return value. 
  9863.  
  9864. The setvbuf function is more flexible than setbuf. 
  9865.  
  9866. Example of setbuf 
  9867.  
  9868. Related Information 
  9869.  
  9870. o fclose  - Close Stream 
  9871. o fflush  - Write Buffer to File 
  9872. o fopen  - Open Files 
  9873. o setvbuf  - Control Buffering 
  9874. o stdio.h 
  9875.  
  9876.  
  9877. ΓòÉΓòÉΓòÉ 2.187. setjmp  - Preserve Environment ΓòÉΓòÉΓòÉ
  9878.  
  9879. #include <setjmp.h>
  9880.  
  9881. int setjmp(jmp_buf env);
  9882.  
  9883. Language Level: ANSI, SAA 
  9884.  
  9885. Description 
  9886.  
  9887. The setjmp function saves a stack environment that can subsequently be restored 
  9888. by longjmp.  The setjmp and longjmp functions provide a way to perform a 
  9889. nonlocal goto. 
  9890.  
  9891. A call to setjmp causes it to save the current stack environment in env.  A 
  9892. subsequent call to longjmp restores the saved environment and returns control 
  9893. to a point corresponding to the setjmp call.  The values of all variables 
  9894. (except register variables) accessible to the function receiving control 
  9895. contain the values they had when longjmp was called.  The values of register 
  9896. variables are unpredictable.  Nonvolatile auto variables that are changed 
  9897. between calls to setjmp and longjmp are also unpredictable. 
  9898.  
  9899. The setjmp function returns the value 0 after saving the stack environment.  If 
  9900. setjmp returns as a result of a longjmp call, it returns the value argument of 
  9901. longjmp, or 1 if the value argument of longjmp is 0.  There is no error-return 
  9902. value. 
  9903.  
  9904. Example of setjmp 
  9905.  
  9906. Related Information 
  9907.  
  9908. o longjmp  - Restore Stack Environment 
  9909. o goto 
  9910. o volatile and const Qualifiers 
  9911. o auto Storage Class Specifier 
  9912. o setjmp.h 
  9913.  
  9914.  
  9915. ΓòÉΓòÉΓòÉ 2.188. setlocale  - Sets Locale ΓòÉΓòÉΓòÉ
  9916.  
  9917. #include <locale.h>
  9918.  
  9919. char *setlocale(int category, const char *locale);
  9920.  
  9921. Language Level: ANSI, SAA 
  9922.  
  9923. Description 
  9924.  
  9925. The setlocale function changes or queries variables, defined in the locale.h 
  9926. header file, that indicate location.  The values for category are listed below. 
  9927.  
  9928. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  9929. Γöé CATEGORY     Γöé PURPOSE                                         Γöé
  9930. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9931. Γöé "LC_ALL"     Γöé Names program's entire locale.                  Γöé
  9932. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9933. Γöé "LC_COLLATE" Γöé Affects behavior of "strcoll" and "strxfrm"     Γöé
  9934. Γöé              Γöé functions.                                      Γöé
  9935. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9936. Γöé "LC_CTYPE"   Γöé Affects behavior of character handling func-    Γöé
  9937. Γöé              Γöé tions.                                          Γöé
  9938. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9939. Γöé "LC_MONETARY"Γöé Affects monetary information returned by        Γöé
  9940. Γöé              Γöé "localeconv".                                   Γöé
  9941. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9942. Γöé "LC_NUMERIC" Γöé Affects the decimal-point character for the     Γöé
  9943. Γöé              Γöé formatted input/output and string conversion    Γöé
  9944. Γöé              Γöé functions, and the nonmonetary formatting       Γöé
  9945. Γöé              Γöé information returned by the "localeconv" func-  Γöé
  9946. Γöé              Γöé tion.                                           Γöé
  9947. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9948. Γöé "LC_TIME"    Γöé Affects behavior of "strftime" function.        Γöé
  9949. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  9950. Γöé "LC_TOD"     Γöé Affects the behavior of the "time" functions.   Γöé
  9951. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  9952.  
  9953. You can set the value of locale to "C", "",LC_C, LC_C_GERMANY, LC_C_FRANCE, 
  9954. LC_C_SPAIN, LC_C_ITALY, LC_C_JAPN, LC_C_USA or LC_C_UK. A locale value of "C" 
  9955. indicates the default C environment.  A locale value of "" tells setlocale to 
  9956. use the default locale for the implementation. 
  9957.  
  9958. The setlocale function returns a pointer to the string associated with the 
  9959. specified category for the new locale.  The string can be used on a subsequent 
  9960. call to restore that part of the program's locale. 
  9961.  
  9962. Note:  Because the string to which a successful call to setlocale points may be 
  9963. overwritten by subsequent calls to the setlocale function, you should copy the 
  9964. string if you plan to use it later. 
  9965.  
  9966. On error, the setlocale function returns NULL and the program's locale is not 
  9967. changed. 
  9968.  
  9969. To query the locale, give a NULL as the second parameter.  For example, if you 
  9970. wish to query all the categories of your locale, enter the following statement: 
  9971.  
  9972.     char *string = setlocale(LC_ALL, NULL);
  9973.  
  9974. Example of setlocale 
  9975.  
  9976. Related Information 
  9977.  
  9978. o getenv  - Search for Environment Variables 
  9979. o localeconv  - Query Locale Conventions 
  9980. o locale.h 
  9981.  
  9982.  
  9983. ΓòÉΓòÉΓòÉ 2.189. _setmode - Set File Translation Mode ΓòÉΓòÉΓòÉ
  9984.  
  9985. #include <fcntl.h>
  9986. #include <io.h>
  9987.  
  9988. int _setmode(int handle, int mode);
  9989.  
  9990. Language Level: Extension 
  9991.  
  9992. Description 
  9993.  
  9994. The _setmode function sets the translation mode of the file given by handle to 
  9995. mode. The mode must be one of the Oflags in the following table: 
  9996.  
  9997. Oflag          Meaning 
  9998. O_TEXT         Will set the translated text mode. Carriage-return line-feed 
  9999.                combinations are translated into a single line feed on input. 
  10000.                Line-feed characters are translated into carriage-return 
  10001.                line-feed combinations on output. 
  10002. O_BINARY       Will set the binary (untranslated) mode. The above translations 
  10003.                are suppressed. 
  10004.  
  10005. Use the _setmode function to change the translation mode of a file handle. The 
  10006. translation mode only affects functions _read and _write. This function does 
  10007. not affect the translation mode of streams. 
  10008.  
  10009. If a file handle is acquired other than by a call to _open, _creat, _sopen or 
  10010. _fileno, _setmode should be called for that file handle before using it within 
  10011. the read or write functions. 
  10012.  
  10013. The _setmode function returns a the previous translation mode if successful. A 
  10014. return value of -1 indicates an error, and errno is set to one of the following 
  10015. values: 
  10016.  
  10017. Value          Meaning 
  10018. EBADF          The file handle is not a handle for an open file. 
  10019. EINVAL         Incorrect mode (neither O_TEXT nor O_BINARY) 
  10020.  
  10021. Example of _setmode 
  10022.  
  10023. Related Information 
  10024.  
  10025. o _creat - Create New File 
  10026. o _open - Open File 
  10027. o _sopen - Open Shared File 
  10028. o _read - Read Into Buffer 
  10029. o _write - Writes from Buffer to File 
  10030. o fcntl.h 
  10031. o io.h 
  10032. o share.h 
  10033. o sys\stat.h 
  10034.  
  10035.  
  10036. ΓòÉΓòÉΓòÉ 2.190. setvbuf  - Control Buffering ΓòÉΓòÉΓòÉ
  10037.  
  10038. #include <stdio.h>
  10039.  
  10040. int setvbuf(FILE *stream, char *buf, int type, size_t size);
  10041.  
  10042. Language Level: ANSI, SAA 
  10043.  
  10044. Description 
  10045.  
  10046. The setvbuf function allows control over the buffering strategy and buffer size 
  10047. for a specified stream.  The stream must refer to a file which has been opened, 
  10048. but not read or written to. 
  10049.  
  10050. The array pointed to by buf designates an area that you provide which the C 
  10051. library may choose to use as a buffer for the stream.  A buf value of NULL 
  10052. indicates that no such area is being supplied and that the C library is to 
  10053. assume responsibility for managing its own buffers for the stream.  If you 
  10054. supply a buffer, it must exist until the stream is closed. 
  10055.  
  10056. If type is _IOFBF or _IOLBF, size is the size of the supplied buffer.  If buf 
  10057. is NULL, the C library will take size as the suggested size for its own buffer. 
  10058. If type is _IONBF, both buf and size are ignored. 
  10059.  
  10060. Value         Meaning 
  10061. _IONBF        No buffer is used. 
  10062. _IOFBF        Full buffering is used for input and output.  You should use buf 
  10063.               as the buffer and size as the size of the buffer. 
  10064. _IOLBF        Line buffering is used.  The buffer is flushed when a new-line 
  10065.               character is written, when the buffer is full, or when input is 
  10066.               requested. 
  10067.  
  10068. The value for size must be greater than 0. 
  10069.  
  10070. The setvbuf function returns a 0 if successful and nonzero if an invalid value 
  10071. was specified in the parameter list, or if the request cannot be performed. 
  10072.  
  10073. Warning: The array used as the buffer must still exist when the specified 
  10074. stream is closed. For example, if the buffer is declared within the scope of a 
  10075. function block, the stream must be closed before the function terminates and 
  10076. frees the storage allocated to the buffer. 
  10077.  
  10078. Example of setvbuf 
  10079.  
  10080. Related Information 
  10081.  
  10082. o fclose  - Close Stream 
  10083. o fflush  - Write Buffer to File 
  10084. o fopen  - Open Files 
  10085. o setbuf  - Control Buffering 
  10086. o stdio.h 
  10087.  
  10088.  
  10089. ΓòÉΓòÉΓòÉ 2.191. signal - Install Interrupt Handlers ΓòÉΓòÉΓòÉ
  10090.  
  10091. #include <signal.h>
  10092.  
  10093. void (*signal(int sig, void (*sig_handler)(int)))(int);
  10094.  
  10095. Language Level: ANSI, SAA, Extension 
  10096.  
  10097. Description 
  10098.  
  10099. The signal function assigns the interrupt signal sig to the signal handler 
  10100. sig_handler. The sig argument must be one of the signal constants defined in 
  10101. <signal.h>. 
  10102.  
  10103. The meanings of the values of sig are as follows: 
  10104.  
  10105. Value             Meaning 
  10106. SIGABRT           Abnormal termination signal sent by the abort function. 
  10107.                   Default action is to end the program with exit code 3. 
  10108. SIGBREAK          Ctrl-Break signal. Default action is to end the program with 
  10109.                   exit code 99. 
  10110. SIGFPE            Floating-point exceptions that are not masked, such as 
  10111.                   overflow, division by zero, and invalid operation.  Default 
  10112.                   action is to end the program with exit code 99 and provide a 
  10113.                   machine-state dump. 
  10114. SIGILL            Instruction not allowed.  Default action is to end the 
  10115.                   program with exit code 99 and provide a machine-state dump. 
  10116. SIGINT            Ctrl-C signal. Default action is to end the program with exit 
  10117.                   code 99. 
  10118. SIGSEGV           Access to memory not valid. Default action is to end the 
  10119.                   program with exit code 99 and provide a machine-state dump. 
  10120. SIGTERM           Program termination signal sent by the user.  Default action 
  10121.                   is to end the program with exit code 99. 
  10122. SIGUSR1           Defined by the user. Default action is to ignore the signal. 
  10123. SIGUSR2           Defined by the user. Default action is to ignore the signal. 
  10124. SIGUSR3           Defined by the user. Default action is to ignore the signal. 
  10125.  
  10126. Signals can be reported as a result of a machine interrupt (for example, 
  10127. division by zero) or by an explicit request to report a signal by using the 
  10128. raise function. 
  10129.  
  10130. The sig_handler argument must be either the SIG_DFL or SIG_IGN constant, also 
  10131. defined in <signal.h>, or the address of a function that takes an integer 
  10132. argument (the signal). 
  10133.  
  10134. The action taken when the interrupt signal is received depends on the value of 
  10135. sig_handler: 
  10136.  
  10137. Value           Meaning 
  10138.  
  10139. SIG_DFL         This is the initial setting for all signals. For most signals, 
  10140.                 the system default is to end the program. All files controlled 
  10141.                 by the process are closed, but buffers are not flushed.  A 
  10142.                 machine-state dump is provided for SIGFPE, SIGILL, and SIGSEGV. 
  10143.                 The default response for the user-defined signals (SIGUSR1, 
  10144.                 SIGUSR2, and SIGUSR3) is to ignore them. 
  10145.  
  10146. SIG_IGN         The interrupt signal is ignored. 
  10147.  
  10148. SIG_HANDLER     Installs the specified function as the signal handler for the 
  10149.                 given signal. 
  10150.  
  10151. For all signals, the function is passed two arguments. The first argument is 
  10152. the signal number and the second is 0, unless the signal is SIG_FPE. For 
  10153. SIG_FPE signals, the second argument passed is a floating-point error signal as 
  10154. defined in <float.h>. If the signal handling function returns, the calling 
  10155. process resumes running immediately following the point at which it received 
  10156. the interrupt signal. 
  10157.  
  10158. When a signal is reported and the sig_handler called, signal handling for that 
  10159. signal is reset to the default. Depending on the purpose of the signal handler, 
  10160. it can be desirable to reestablish the signal handling from within the 
  10161. sig_handler function. You can also reset the default handling with an explicit 
  10162. call to signal. 
  10163.  
  10164. Signals and signal handlers are not shared between threads. If you do not 
  10165. establish a signal handler within a thread, the default signal handling will be 
  10166. used regardless of what handlers you may have established in other concurrent 
  10167. threads. 
  10168.  
  10169. Note:  If an exception occurs in a math or critical library function, it is 
  10170. handled by the Giverny exception handler.  Your sig_handler will not be called. 
  10171.  
  10172. All calls to the signal function return the address of the previous handler for 
  10173. the re-assigned signal. 
  10174.  
  10175. A return value of SIG_ERR, defined in <signal.h>, indicates an error, and errno 
  10176. is set to EINVAL. The possible causes of the error are an incorrect sig value 
  10177. or an undefined value for func. 
  10178.  
  10179. Example of signal 
  10180.  
  10181. Related Information 
  10182.  
  10183. o abort  - Stop a Program 
  10184. o atexit  - Record Program Termination Function 
  10185. o exit  - End Program 
  10186. o _exit - End Process 
  10187. o _fpreset - Reset Floating-Point Unit 
  10188. o raise  - Send Signal 
  10189. o _spawnl - _spawnvpe - Start and Run Child Processes 
  10190. o signal.h 
  10191.  
  10192.  
  10193. ΓòÉΓòÉΓòÉ 2.192. sin  - Sine ΓòÉΓòÉΓòÉ
  10194.  
  10195. #include <math.h>
  10196.  
  10197. double sin(double x);     /* Calculate sine of x */
  10198.  
  10199. Language Level: ANSI, SAA 
  10200.  
  10201. Description 
  10202.  
  10203. The sin function returns the sine of x, with x expressed in radians. 
  10204.  
  10205. Example of sin 
  10206.  
  10207. Related Information 
  10208.  
  10209. o acos  - Arc Cosine 
  10210. o asin  - Arc Sine 
  10211. o atan - atan2  - Arc Tangent 
  10212. o cos  - Cosine 
  10213. o cosh  - Hyperbolic Cosine 
  10214. o sinh  - Hyperbolic Sine 
  10215. o tan  - Tangent 
  10216. o tanh  - Hyperbolic Tangent 
  10217. o math.h 
  10218.  
  10219.  
  10220. ΓòÉΓòÉΓòÉ 2.193. sinh  - Hyperbolic Sine ΓòÉΓòÉΓòÉ
  10221.  
  10222. #include <math.h>
  10223.  
  10224. double sinh(double x);     /* Calculate hyperbolic sine of x */
  10225.  
  10226. Language Level: ANSI, SAA 
  10227.  
  10228. Description 
  10229.  
  10230. The sinh function returns the hyperbolic sine of x, with x expressed in 
  10231. radians. If the result is too large, sinh sets errno to ERANGE and returns the 
  10232. value HUGE_VAL (positive or negative, depending on the value of x). 
  10233.  
  10234. Example of sinh 
  10235.  
  10236. Related Information 
  10237.  
  10238. o acos  - Arc Cosine 
  10239. o asin  - Arc Sine 
  10240. o atan - atan2  - Arc Tangent 
  10241. o cos  - Cosine 
  10242. o cosh  - Hyperbolic Cosine 
  10243. o sin  - Sine 
  10244. o tan  - Tangent 
  10245. o tanh  - Hyperbolic Tangent 
  10246. o math.h 
  10247.  
  10248.  
  10249. ΓòÉΓòÉΓòÉ 2.194. _sopen - Open Shared File ΓòÉΓòÉΓòÉ
  10250.  
  10251. #include <fcntl.h>
  10252. #include <sys\stat.h>
  10253. #include <share.h>
  10254. #include <io.h>
  10255.  
  10256. int _sopen(char *pathname, int oflag, int shflag , int pmode);
  10257.  
  10258. Language Level: Extension 
  10259.  
  10260. Description 
  10261.  
  10262. The _sopen function opens the file specified by pathname and prepares the file 
  10263. for subsequent shared reading or writing as defined by oflag and shflag. The 
  10264. oflag is an integer expression formed by combining one or more of the constants 
  10265. defined in <fcntl.h>. When more than one constant is given, the constants are 
  10266. joined with the OR operator (|). 
  10267.  
  10268. Oflag          Meaning 
  10269. O_APPEND       Reposition the file pointer to the end of the file before every 
  10270.                write operation. 
  10271. O_CREAT        Create and open a new file.  This flag has no effect if the file 
  10272.                specified by pathname exists. 
  10273. O_EXCL         Return an error value if the file specified by pathname exists. 
  10274.                This flag applies only when used with O_CREAT. 
  10275. O_RDONLY       Open the file for reading only.  If this flag is given, neither 
  10276.                O_RDWR nor O_WRONLY can be given. 
  10277. O_RDWR         Open the file for both reading and writing.  If this flag is 
  10278.                given, neither O_RDONLY nor O_WRONLY can be given. 
  10279. O_TRUNC        Open and truncate an existing file to 0 length. The file must 
  10280.                have write permission. The contents of the file are destroyed. 
  10281.                On the OS/2 operating system, you must not specify O_TRUNC with 
  10282.                O_RDONLY. 
  10283. O_WRONLY       Open the file for writing only.  If this flag is given, neither 
  10284.                O_RDONLY nor O_RDWR can be given. 
  10285. O_BINARY       Open the file in binary (untranslated) mode. (See fopen for a 
  10286.                description of binary mode.) 
  10287. O_TEXT         Open the file in text (translated) mode. (See fopen for a 
  10288.                description of text mode.) 
  10289.  
  10290. The shflag argument is one of the following constants, defined in <share.h>. 
  10291.  
  10292. Shflag          Meaning 
  10293. SH_DENYRW       Deny read and write access to file 
  10294. SH_DENYWR       Deny write access to file 
  10295. SH_DENYRD       Deny read access to file 
  10296. SH_DENYNO       Permit read and write access. 
  10297.  
  10298. There is no default value for the shflag. 
  10299.  
  10300. The pmode argument is required only when O_CREAT is specified. If the file does 
  10301. not exist, pmode specifies the permission settings of the file.  These are set 
  10302. when the new file is closed for the first time.  Otherwise, the pmode argument 
  10303. is ignored. The pmode argument is an integer expression containing one or both 
  10304. of the constants S_IWRITE and S_IREAD. The meanings of the pmode argument are 
  10305. in the following table. 
  10306.  
  10307. Value                   Meaning 
  10308. S_IWRITE                Writing permitted 
  10309. S_IREAD                 Reading permitted 
  10310. S_IREAD | S_IWRITE      Reading and writing permitted. 
  10311.  
  10312. If write permission is not given, the file is read only.  On the OS/2 operating 
  10313. system, all files are readable; you cannot give write-only permission.  Thus, 
  10314. the modes S_IWRITE and S_IREAD | S_IWRITE are equivalent. 
  10315.  
  10316. Specifying a pmode of S_IREAD is similar to making a file read-only with the 
  10317. ATTRIB system command. 
  10318.  
  10319. The _sopen function applies the current file permission mask to pmode before 
  10320. setting the permissions. (See _umask - Sets File Mask of Current Process for 
  10321. information on file permission masks.) 
  10322.  
  10323. The _sopen function returns a file handle for the opened file. A return value 
  10324. of -1 indicates an error, and errno is set to one of the following values: 
  10325.  
  10326. Value          Meaning 
  10327. EACCESS        The given path name is a directory, but the file is read-only 
  10328.                and an open for writing was attempted, or a sharing violation 
  10329.                occurred. 
  10330. EEXIST         The O_CREAT and O_EXCL flags are specified, but the named file 
  10331.                already exists. 
  10332. EMFILE         No more file handles are available. 
  10333. ENOENT         The file or path name was not found. 
  10334. EINVAL         An incorrect argument was passed. 
  10335. EOS2ERR        The call to the operating system was not successful. 
  10336.  
  10337. Example of _sopen 
  10338.  
  10339. Related Information 
  10340.  
  10341. o _close - Closes File Associated with Handle 
  10342. o _creat - Create New File 
  10343. o _open - Open File 
  10344. o _fdopen - Associates Input Or Output With File 
  10345. o Subword(headers.uparm,2) 
  10346. o _umask - Sets File Mask of Current Process 
  10347. o fcntl.h 
  10348. o io.h 
  10349. o share.h 
  10350. o sys\stat.h 
  10351.  
  10352.  
  10353. ΓòÉΓòÉΓòÉ 2.195. _spawnl - _spawnvpe - Start and Run Child Processes ΓòÉΓòÉΓòÉ
  10354.  
  10355. #include <process.h>
  10356.  
  10357. int _spawnl(int modeflag, char *pathname, char *arg0, char *arg1, ...,  char *argn,
  10358.            NULL);
  10359.  
  10360. int _spawnlp(int modeflag, char *pathname, char *arg0, char *arg1, ..., char *argn,
  10361.            NULL);
  10362.  
  10363. int _spawnle(int modeflag, char *pathname, char *arg0, char *arg1, ..., char *argn,
  10364.            NULL, char *envp[ ]);
  10365.  
  10366. int _spawnlpe(int modeflag, char *pathname, char *arg0, char *arg1, ..., char *argn,
  10367.            NULL, char *envp[ ]);
  10368.  
  10369. int _spawnv(int modeflag, char *pathname, char *argv[ ]);
  10370.  
  10371. int _spawnvp(int modeflag, char *pathname, char *argv[ ]);
  10372.  
  10373. int _spawnve(int modeflag, char *pathname, char *argv[ ], char *envp[ ]);
  10374.  
  10375. int _spawnvpe(int modeflag, char *pathname, char *argv[ ], char *envp[ ])
  10376.  
  10377. Language Level: Extension 
  10378.  
  10379. Description 
  10380.  
  10381. Each of the _spawn functions creates and runs a new child process. Enough 
  10382. storage must be available for loading and running the child process. All of the 
  10383. _spawn functions are versions of the same routine; the letters at the end 
  10384. determine the specific variation: 
  10385.  
  10386. Letter   Variation 
  10387.  p       Uses PATH environment variable to find the file to be run 
  10388.  l       Lists command-line arguments separately 
  10389.  v       Passes to the child process an array of pointers to command-line 
  10390.          arguments 
  10391.  e       Passes to the child process an array of pointers to environment 
  10392.          strings. 
  10393.  
  10394. The modeflag argument determines the action taken by the parent process before 
  10395. and during the _spawn. The following values for modeflag are defined in 
  10396. <process.h>. 
  10397.  
  10398. Value          Meaning 
  10399. P_WAIT         Suspend the parent process until the child process is complete. 
  10400. P_NOWAIT       Continue to run the parent process concurrently. 
  10401. P_OVERLAY      Start the child process, and then if successful, end the parent 
  10402.                process.  (This has the same effect as _exec calls.) 
  10403.  
  10404. The pathname argument specifies the file to run as the child process.  The 
  10405. pathname can specify a full path (from the root), a partial path (from the 
  10406. current working directory), or just a file name.  If pathname does not have a 
  10407. file name extension or end with a period, the _spawn functions add the 
  10408. extension .EXE and search for the file. If pathname has an extension, only that 
  10409. extension is used.  If pathname ends with a period, the _spawn functions search 
  10410. for pathname with no extension. The _spawnlp, _spawnlpe, _spawnvp, and 
  10411. _spawnvpe functions search for pathname (using the same procedures) in the 
  10412. directories specified by the PATH environment variable. 
  10413.  
  10414. You pass arguments to the child process by giving one or more pointers to 
  10415. character strings as arguments in the _spawn routine.  These character strings 
  10416. form the argument list for the child process. 
  10417.  
  10418. The argument pointers can be passed as separate arguments (_spawnl, _spawnle, 
  10419. _spawnlp, and _spawnlpe) or as an array of pointers (_spawnv, _spawnve, 
  10420. _spawnvp, and _spawnvpe).  At least one argument, either arg0 or argv[0], must 
  10421. be passed to the child process.  By convention, this argument is a copy of the 
  10422. pathname argument.  However, a different value will not produce an error. 
  10423.  
  10424. Use the _spawnl, _spawnle, _spawnlp, and _spawnlpe routines in cases where you 
  10425. know the number of arguments.  The arg0 is usually a pointer to pathname.  The 
  10426. arg1 through argn arguments are pointers to the character strings forming the 
  10427. new argument list.  Following argn, there must be a NULL pointer to mark the 
  10428. end of the argument list. 
  10429.  
  10430. The _spawnv, _spawnve, _spawnvp, and _spawnvpe functions are useful when the 
  10431. number of arguments to the child process is variable.  Pointers to the 
  10432. arguments are passed as an array, argv.  The argv[0] argument is usually a 
  10433. pointer to the pathname.  The argv[1] through argv[n] arguments are pointers to 
  10434. the character strings forming the new argument list.  The argv[n+1] argument 
  10435. must be a NULL pointer to mark the end of the argument list. 
  10436.  
  10437. Files that are open when a _spawn call is made remain open in the child 
  10438. process.  In the _spawnl, _spawnlp, _spawnv, and _spawnvp calls, the child 
  10439. process inherits the environment of the parent. The _spawnle, _spawnlpe, 
  10440. _spawnve, and _spawnvpe functions let you alter the environment for the child 
  10441. process by passing a list of environment settings through the envp argument. 
  10442. The envp argument is an array of character pointers, each element of which 
  10443. points to a string, ended by a null, that defines an environment variable. 
  10444. Such a string has the form: 
  10445.  
  10446.    NAME=value
  10447.  
  10448. where NAME is the name of an environment variable, and value is the string 
  10449. value to which that variable is set.  (Notice that value is not enclosed in 
  10450. double quotation marks.) The final element of the envp array should be NULL. 
  10451. When envp itself is NULL, the child process inherits the environment settings 
  10452. of the parent process. 
  10453.  
  10454. Note:  Signal settings are not preserved in child processes created by calls to 
  10455.        spawn functions. The signal settings are reset to the default in the 
  10456.        child process. 
  10457.  
  10458. An alternative to this function is the DosExecPgm API call. 
  10459.  
  10460. The return from a spawn has one of two different meanings.  The return value of 
  10461. a synchronous spawn is the exit status of the child process.  The return value 
  10462. of an asynchronous spawn is the process identification of the child process. 
  10463. You can use the _wait or _cwait functions to get the child process exit code if 
  10464. an asynchronous spawn was done. 
  10465.  
  10466. A return value of -1 indicates an error (the child process is not started), and 
  10467. errno is set to one of the following values: 
  10468.  
  10469. Value       Meaning 
  10470. EAGAIN      You attempted to create more processes than the OS/2 operating 
  10471.             system permits. 
  10472. EINVAL      The modeflag argument is incorrect. 
  10473. ENOENT      The file or path name was not found or was not specified correctly. 
  10474. ENOEXEC     The specified file is not executable or has an incorrect executable 
  10475.             file format. 
  10476. ENOMEM      Not enough storage is available to run the child process. 
  10477.  
  10478. Example of _spawnl - _spawnvp 
  10479.  
  10480. Related Information 
  10481.  
  10482. o abort  - Stop a Program 
  10483. o _cwait - Wait for Child Process 
  10484. o _execl - _execvp - Load and Run Child Process 
  10485. o exit  - End Program 
  10486. o _exit - End Process 
  10487. o _wait - Wait for Child Process 
  10488. o process.h 
  10489.  
  10490.  
  10491. ΓòÉΓòÉΓòÉ 2.196. _splitpath - Decompose Path Name ΓòÉΓòÉΓòÉ
  10492.  
  10493. #include <stdlib.h>
  10494.  
  10495. void _splitpath(char *path, char *drive, char *dir, char *fname, char *ext);
  10496.  
  10497. Language Level: Extension 
  10498.  
  10499. Description 
  10500.  
  10501. The _splitpath function decomposes an existing path name path into its four 
  10502. components. The path should point to a buffer containing the complete path 
  10503. name. 
  10504.  
  10505. The maximum size necessary for each buffer is specified by the _MAX_DRIVE, 
  10506. _MAX_DIR, _MAX_FNAME, and _MAX_EXT constants defined in <stdlib.h>.  The other 
  10507. arguments point to the following buffers used to store the path name elements: 
  10508.  
  10509. Buffer      Description 
  10510.  
  10511. drive       Contains the drive letter followed by a colon (:) if a drive is 
  10512.             specified in path. 
  10513.  
  10514. dir         Contains the path of subdirectories, if any, including the trailing 
  10515.             slash.  Slashes (/), backslashes (\), or both may be present in 
  10516.             path. 
  10517.  
  10518. fname       Contains the base file name without any extensions. 
  10519.  
  10520. ext         Contains the file name extension, if any, including the leading 
  10521.             period (.). 
  10522.  
  10523. The return parameters contain empty strings for any path name components not 
  10524. found in path. 
  10525.  
  10526. There is no return value. 
  10527.  
  10528. Example of _splitpath 
  10529.  
  10530. Related Information 
  10531.  
  10532. o _fullpath - Get Full Path Name of Partial Path 
  10533. o _getcwd - Get Path Name of Current Directory 
  10534. o _getdcwd - Get Full Path Name of Current Directory 
  10535. o _makepath - Create Path 
  10536. o stdlib.h 
  10537.  
  10538.  
  10539. ΓòÉΓòÉΓòÉ 2.197. sprintf  - Formatted Print to Buffer ΓòÉΓòÉΓòÉ
  10540.  
  10541. #include <stdio.h>
  10542.  
  10543. int sprintf(char *buffer, const char *format-string, argument-list);
  10544.  
  10545. Language Level: ANSI, SAA, Extension 
  10546.  
  10547. Description 
  10548.  
  10549. The sprintf function formats and stores a series of characters and values in 
  10550. buffer, which is an array. Any argument-list is converted and put out according 
  10551. to the corresponding format specification in the format-string. 
  10552.  
  10553. The format-string consists of ordinary characters and has the same form and 
  10554. function as the format-string argument for the printf function.  See printf for 
  10555. a description of the format-string and arguments. 
  10556.  
  10557. In extended mode, sprintf also converts floating-point values of NaN and 
  10558. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  10559. and sign of the string is determined by the format specifiers.  See Infinity 
  10560. and NaN Support for more information on infinity and NaN values. 
  10561.  
  10562. The sprintf function returns the number of characters written in the array, not 
  10563. counting the ending null character. 
  10564.  
  10565. Example of sprintf 
  10566.  
  10567. Related Information 
  10568.  
  10569. o fprintf  - Formatted Write 
  10570. o printf  - Formatted Print 
  10571. o sscanf  - Read Data 
  10572. o Infinity and NaN Support 
  10573. o vfprintf  - Print Argument Data 
  10574. o vprintf  - Print Argument Data 
  10575. o vsprintf  - Print Argument Data 
  10576. o stdio.h 
  10577.  
  10578.  
  10579. ΓòÉΓòÉΓòÉ 2.198. sqrt  - Calculate Square Root ΓòÉΓòÉΓòÉ
  10580.  
  10581. #include <math.h>
  10582.  
  10583. double sqrt(double x);
  10584.  
  10585. Language Level: ANSI, SAA 
  10586.  
  10587. Description 
  10588.  
  10589. The sqrt function calculates the nonnegative value of the square root of x. 
  10590.  
  10591. The sqrt function returns the square root result.  If x is negative, the 
  10592. function sets errno to EDOM, and returns 0. 
  10593.  
  10594. Example of sqrt 
  10595.  
  10596. Related Information 
  10597.  
  10598. o exp  - Exponential Function 
  10599. o hypot  - Calculate Hypotenuse 
  10600. o log  - Calculate Natural Logarithm 
  10601. o log10  - Calculate Base 10 Logarithm 
  10602. o pow  - Compute Power 
  10603. o math.h 
  10604.  
  10605.  
  10606. ΓòÉΓòÉΓòÉ 2.199. srand  - Set Seed for rand Function ΓòÉΓòÉΓòÉ
  10607.  
  10608. #include <stdlib.h>
  10609.  
  10610. void srand(unsigned int seed);
  10611.  
  10612. Language Level: ANSI, SAA 
  10613.  
  10614. Description 
  10615.  
  10616. The srand function sets the starting point for producing a series of 
  10617. pseudo-random integers.  If srand is not called, the rand seed defaults as if 
  10618. srand(1) was called at program start.  Any other value for seed sets the 
  10619. generator to a different starting point. 
  10620.  
  10621. The rand function generates the pseudo-random numbers. 
  10622.  
  10623. There is no return value. 
  10624.  
  10625. Example of srand 
  10626.  
  10627. Related Information 
  10628.  
  10629. o rand  - Generate Random Number 
  10630. o stdlib.h 
  10631.  
  10632.  
  10633. ΓòÉΓòÉΓòÉ 2.200. sscanf  - Read Data ΓòÉΓòÉΓòÉ
  10634.  
  10635. #include <stdio.h>
  10636.  
  10637. int sscanf(const char *buffer, const char *format, argument-list);
  10638.  
  10639. Language Level: ANSI, SAA, Extension 
  10640.  
  10641. Description 
  10642.  
  10643. The sscanf function reads data from buffer into the locations given by 
  10644. argument-list.  Each argument must be a pointer to a variable with a type that 
  10645. corresponds to a type specifier in the format-string. See scanf for a 
  10646. description of the format-string. 
  10647.  
  10648. The sscanf function returns the number of fields that were successfully 
  10649. converted and assigned.  The return value does not include fields that were 
  10650. read but not assigned. 
  10651.  
  10652. In extended mode, sscanf also reads in the strings the strings "INFINITY", 
  10653. "INF", and "NAN" (in upper or lowercase) and converts them to the corresponding 
  10654. floating-point value.  The sign of the value is determined by the format 
  10655. specification. See Infinity and NaN Support for more information on infinity 
  10656. and NaN values. 
  10657.  
  10658. The return value is EOF when the end of the string is encountered before 
  10659. anything is converted. 
  10660.  
  10661. Example of sscanf 
  10662.  
  10663. Related Information 
  10664.  
  10665. o fscanf  - Read Formatted Data 
  10666. o scanf  - Read Data 
  10667. o sprintf  - Formatted Print to Buffer 
  10668. o Infinity and NaN Support 
  10669. o stdio.h 
  10670.  
  10671.  
  10672. ΓòÉΓòÉΓòÉ 2.201. _stat - Get Information about File or Directory ΓòÉΓòÉΓòÉ
  10673.  
  10674. #include <sys\types.h>
  10675. #include <sys\stat.h>
  10676.  
  10677. int _stat(char *pathname, struct stat *buffer);
  10678.  
  10679. Language Level: Extension 
  10680.  
  10681. Description 
  10682.  
  10683. The _stat function stores information about the file or directory specified by 
  10684. pathname in the structure to which buffer points.  The _stat structure, defined 
  10685. in <sys\stat.h>, contains the following fields: 
  10686.  
  10687. Field          Value 
  10688.  
  10689. st_mode        Bit mask for file-mode information. The _stat function sets the 
  10690.                S_IFCHR bit if handle refers to a device. The S_IFDIR bit is set 
  10691.                if pathname specifies a directory. The S_IFREG bit is set if 
  10692.                pathname specifies an ordinary file.  User read/write bits are 
  10693.                set according to the permission mode of the file. The S_IEXEC 
  10694.                bit is set using the file name extension. The other bits are 
  10695.                undefined. 
  10696.  
  10697.                                                   F E D C B A 9 8 7 6 5 4 3 2 1 0
  10698.                                                  Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé
  10699.                                                  ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
  10700.                                                                
  10701.                                      S_IFREGΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ Γöé Γöé         Γöé Γöé ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇexecute/search permission,
  10702.                               (regular file)        Γöé Γöé         Γöé Γöé        owner (S_IEXEC)
  10703.                                      S_IFDIRΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ Γöé         Γöé ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇwrite permission, owner
  10704.                                      S_IFCHRΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ         ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇread permission, owner
  10705.  
  10706. st_dev         Drive number of the disk containing the file. 
  10707.  
  10708. st_rdev        Drive number of the disk containing the file (same as st_dev). 
  10709.  
  10710. st_nlink       Always 1. 
  10711.  
  10712. st_size        Size of the file in bytes. 
  10713.  
  10714. st_atime       Time of last modification of file. 
  10715.  
  10716. st_mtime       Same as st_atime if not provided by the file system. 
  10717.  
  10718. st_ctime       Same as st_atime if not provided by the file system. 
  10719.  
  10720. Note:  If the given pathname specifies only a device (for example C:\), _stat 
  10721. returns an error; fields in the _stat structure are not meaningful. 
  10722.  
  10723. The _stat function returns the value 0 if the file status information is 
  10724. obtained.  A return value of -1 indicates an error, and errno is set to ENOENT, 
  10725. indicating that the file name or path name could not be found. 
  10726.  
  10727. Example of _stat 
  10728.  
  10729. Related Information 
  10730.  
  10731. o _fstat - Information about Open File 
  10732. o sys\stat.h 
  10733. o sys\types.h 
  10734.  
  10735.  
  10736. ΓòÉΓòÉΓòÉ 2.202. _status87 - Get Floating-Point Status Word ΓòÉΓòÉΓòÉ
  10737.  
  10738. #include <float.h>
  10739.  
  10740. unsigned int _status87(void);
  10741.  
  10742. Language Level: Extension 
  10743.  
  10744. Description 
  10745.  
  10746. The _status87 function gets the current floating-point status word. The 
  10747. floating-point status word is a combination of the numeric coprocessor status 
  10748. word and other conditions detected by the numeric exception handler, such as 
  10749. floating-point stack underflow and overflow. 
  10750.  
  10751. The bits in the value returned reflect the floating-point status for the 
  10752. current thread only before the call was made. The _status87 function does not 
  10753. affect any other threads that may be processing. 
  10754.  
  10755. Example of _status87 
  10756.  
  10757. Related Information 
  10758.  
  10759. o _clear87 - Clear Floating-Point Statu         s Word 
  10760. o _control87 - Set Floating-Point Status         Word 
  10761. o _fpreset - Reset Floating-Point Unit 
  10762. o float.h 
  10763.  
  10764.  
  10765. ΓòÉΓòÉΓòÉ 2.203. strcat  - Concatenate Strings ΓòÉΓòÉΓòÉ
  10766.  
  10767. #include <string.h>
  10768.  
  10769. char *strcat(char *string1, const char *string2);
  10770.  
  10771. Language Level: ANSI, SAA 
  10772.  
  10773. Description 
  10774.  
  10775. The strcat function concatenates string2 to string1 and ends the resulting 
  10776. string with the null character.  The strcat function returns a pointer to the 
  10777. concatenated string (string1). 
  10778.  
  10779. The strcat function operates on null-terminated strings.  No length checking is 
  10780. performed. You should not use a literal string for a string1 value, although 
  10781. string2 may be a literal string. 
  10782.  
  10783. If the storage of string1 overlaps the storage of string2, the behavior is 
  10784. undefined. 
  10785.  
  10786. Example of strcat 
  10787.  
  10788. Related Information 
  10789.  
  10790. o strchr  - Search for Character 
  10791. o strcmp  - Compare Strings 
  10792. o strcpy  - Copy Strings 
  10793. o strcspn  - Compare Strings 
  10794. o strncat  - Concatenate Strings 
  10795. o string.h 
  10796.  
  10797.  
  10798. ΓòÉΓòÉΓòÉ 2.204. strchr  - Search for Character ΓòÉΓòÉΓòÉ
  10799.  
  10800. #include <string.h>
  10801.  
  10802. char *strchr(const char *string, int c);
  10803.  
  10804. Language Level: ANSI, SAA 
  10805.  
  10806. Description 
  10807.  
  10808. The strchr function returns a pointer to the first occurrence of c converted to 
  10809. a character in string.  The character c can be the null character (\0);  the 
  10810. ending null character of string is included in the search.  The function 
  10811. returns NULL if the character is not found. 
  10812.  
  10813. The strchr function operates on null-terminated strings. 
  10814.  
  10815. Example of strchr 
  10816.  
  10817. Related Information 
  10818.  
  10819. o strcat  - Concatenate Strings 
  10820. o strcmp  - Compare Strings 
  10821. o strcpy  - Copy Strings 
  10822. o strcspn  - Compare Strings 
  10823. o strncmp  - Compare Strings 
  10824. o strpbrk  - Find Characters in String 
  10825. o strrchr  - Find Last Occurrence of Character in String 
  10826. o strspn  - Search Strings 
  10827. o string.h 
  10828.  
  10829.  
  10830. ΓòÉΓòÉΓòÉ 2.205. strcmp  - Compare Strings ΓòÉΓòÉΓòÉ
  10831.  
  10832. #include <string.h>
  10833.  
  10834. int strcmp(const char *string1, const char *string2);
  10835.  
  10836. Language Level: ANSI, SAA 
  10837.  
  10838. Description 
  10839.  
  10840. The strcmp function compares string1 and string2 and returns a value indicating 
  10841. their relationship as follows: 
  10842.  
  10843. Value               Meaning 
  10844. Less than 0         string1 less than string2 
  10845. 0                   string1 identical to string2 
  10846. Greater than 0      string1 greater than string2. 
  10847.  
  10848. The strcmp function operates on null-terminated strings. 
  10849.  
  10850. Example of strcmp 
  10851.  
  10852. Related Information 
  10853.  
  10854. o strcat  - Concatenate Strings 
  10855. o strchr  - Search for Character 
  10856. o strcmpi - Compare Strings 
  10857. o strcpy  - Copy Strings 
  10858. o strcspn  - Compare Strings 
  10859. o stricmp - Compare Strings 
  10860. o strncmp  - Compare Strings 
  10861. o strnicmp - Compare Strings 
  10862. o strpbrk  - Find Characters in String 
  10863. o strrchr  - Find Last Occurrence of Character in String 
  10864. o strspn  - Search Strings 
  10865. o string.h 
  10866.  
  10867.  
  10868. ΓòÉΓòÉΓòÉ 2.206. strcmpi - Compare Strings ΓòÉΓòÉΓòÉ
  10869.  
  10870. #include <string.h>
  10871.  
  10872. int strcmpi(const char *string1, const char *string2);
  10873.  
  10874. Language Level: Extension 
  10875.  
  10876. Description 
  10877.  
  10878. The strcmpi function compares string1 and string2 without sensitivity to case. 
  10879. All alphabetic characters in the two arguments string1 and string2 are 
  10880. converted to lowercase before the comparison. 
  10881.  
  10882. The function operates on null-ended strings. The string arguments to the 
  10883. function are expected to contain a null character (\0) marking the end of the 
  10884. string. 
  10885.  
  10886. The strcmpi function returns a value indicating the relationship between the 
  10887. two strings, as follows: 
  10888.  
  10889. Value             Meaning 
  10890. Less than 0       string1 less than string2 
  10891. 0                 string1 equivalent to string2 
  10892. Greater than 0    string1 greater than string2. 
  10893.  
  10894. Example of strcmpi 
  10895.  
  10896. Related Information 
  10897.  
  10898. o strcat  - Concatenate Strings 
  10899. o strcmp  - Compare Strings 
  10900. o strcpy  - Copy Strings 
  10901. o strdup - Duplicate String 
  10902. o stricmp - Compare Strings 
  10903. o strncmp  - Compare Strings 
  10904. o strnicmp - Compare Strings 
  10905. o strnset - strset - Set Characters in String 
  10906. o string.h 
  10907.  
  10908.  
  10909. ΓòÉΓòÉΓòÉ 2.207. strcoll  - Compares Strings ΓòÉΓòÉΓòÉ
  10910.  
  10911. #include <string.h>
  10912.  
  10913. int strcoll(const char *string1, const char *string2);
  10914.  
  10915. Language Level: ANSI, SAA 
  10916.  
  10917. Description 
  10918.  
  10919. The strcoll function compares two strings using the collating sequence 
  10920. specified by the program's locale. 
  10921.  
  10922. The strcoll function returns a value indicating the relationship between the 
  10923. strings, as listed below. 
  10924.  
  10925. Value               Meaning 
  10926. Less than 0         string1 less than string2 
  10927. 0                   string1 equivalent to string2 
  10928. Greater than 0      string1 greater than string2 
  10929.  
  10930. Example of strcoll 
  10931.  
  10932. Related Information 
  10933.  
  10934. o setlocale  - Sets Locale 
  10935. o strcmp  - Compare Strings 
  10936. o strcmpi - Compare Strings 
  10937. o strncmp  - Compare Strings 
  10938. o strnicmp - Compare Strings 
  10939. o string.h 
  10940.  
  10941.  
  10942. ΓòÉΓòÉΓòÉ 2.208. strcpy  - Copy Strings ΓòÉΓòÉΓòÉ
  10943.  
  10944. #include <string.h>
  10945.  
  10946. char *strcpy(char *string1, const char *string2);
  10947.  
  10948. Language Level: ANSI, SAA 
  10949.  
  10950. Description 
  10951.  
  10952. The strcpy function copies string2, including the ending null character, to the 
  10953. location specified by string1 and returns string1. 
  10954.  
  10955. The strcpy function operates on null-terminated strings.  No length checking is 
  10956. performed. You should not use a literal string for a string1 value, although 
  10957. string2 may be a literal string. 
  10958.  
  10959. Example of strcpy 
  10960.  
  10961. Related Information 
  10962.  
  10963. o strcat  - Concatenate Strings 
  10964. o strchr  - Search for Character 
  10965. o strcmp  - Compare Strings 
  10966. o strcspn  - Compare Strings 
  10967. o strdup - Duplicate String 
  10968. o strncpy  - Copy Strings 
  10969. o strpbrk  - Find Characters in String 
  10970. o strrchr  - Find Last Occurrence of Character in String 
  10971. o strspn  - Search Strings 
  10972. o string.h 
  10973.  
  10974.  
  10975. ΓòÉΓòÉΓòÉ 2.209. strcspn  - Compare Strings ΓòÉΓòÉΓòÉ
  10976.  
  10977. #include <string.h>
  10978.  
  10979. size_t strcspn(const char *string1, const char *string2);
  10980.  
  10981. Language Level: ANSI, SAA 
  10982.  
  10983. Description 
  10984.  
  10985. The strcspn function returns the index of the first character in string1 that 
  10986. belongs to the set of characters specified by string2.  This value is 
  10987. equivalent to the length of the initial substring of string1 that consists 
  10988. entirely of characters not in string2.  Ending null characters are not 
  10989. considered in the search. 
  10990.  
  10991. The strcspn function operates on null-terminated strings. 
  10992.  
  10993. Example of strcspn 
  10994.  
  10995. Related Information 
  10996.  
  10997. o strcat  - Concatenate Strings 
  10998. o strchr  - Search for Character 
  10999. o strcmp  - Compare Strings 
  11000. o strcmpi - Compare Strings 
  11001. o strcpy  - Copy Strings 
  11002. o stricmp - Compare Strings 
  11003. o strncmp  - Compare Strings 
  11004. o strnicmp - Compare Strings 
  11005. o strpbrk  - Find Characters in String 
  11006. o strrchr  - Find Last Occurrence of Character in String 
  11007. o strspn  - Search Strings 
  11008. o string.h 
  11009.  
  11010.  
  11011. ΓòÉΓòÉΓòÉ 2.210. _strdate - Copy Current Date ΓòÉΓòÉΓòÉ
  11012.  
  11013. #include <time.h>
  11014.  
  11015. char *_strdate(char *date);
  11016.  
  11017. Language Level: Extension 
  11018.  
  11019. Description 
  11020.  
  11021. The _strdate function stores the current date as a string in the buffer pointed 
  11022. to by date in the following format: 
  11023.  
  11024.    mm/dd/yy
  11025.  
  11026. The two digits mm represent the month, the digits dd represent the day of the 
  11027. month, and the digits yy represent the year.  For example, the string 10/08/91 
  11028. represents October 8, 1991. The buffer must be at least 9 bytes. 
  11029.  
  11030. Note:  The time and date functions begin at 00:00 Universal Time, January 1, 
  11031. 1970. :enote. 
  11032.  
  11033. The _strdate function returns a pointer to the buffer containing the date 
  11034. string.  There is no error return. 
  11035.  
  11036. Example of _strdate 
  11037.  
  11038. Related Information 
  11039.  
  11040. o asctime  - Convert Time 
  11041. o ctime  - Convert Time 
  11042. o gmtime  - Convert Time 
  11043. o localtime  - Convert Time 
  11044. o mktime  - Convert Local Time 
  11045. o time  - Determine Current Time 
  11046. o _tzset - Assign Values to Locale Information 
  11047. o time.h 
  11048.  
  11049.  
  11050. ΓòÉΓòÉΓòÉ 2.211. strdup - Duplicate String ΓòÉΓòÉΓòÉ
  11051.  
  11052. #include <string.h>
  11053.  
  11054. char *strdup(const char *string);
  11055.  
  11056. Language Level: Extension 
  11057.  
  11058. Description &ipfisyn. root=copy.copy copying duplicate duplicating 
  11059.  
  11060. The strdup function reserves storage space for a copy of string by calling 
  11061. malloc. The string argument to this function is expected to contain a null 
  11062. character (\0) marking the end of the string. 
  11063.  
  11064. The strdup function returns a pointer to the storage space containing the 
  11065. copied string. If it cannot reserve storage strdup returns NULL. 
  11066.  
  11067. Example of strdup 
  11068.  
  11069. Related Information 
  11070.  
  11071. o strcpy  - Copy Strings 
  11072. o strncpy  - Copy Strings 
  11073. o string.h 
  11074.  
  11075.  
  11076. ΓòÉΓòÉΓòÉ 2.212. strerror  - Set Pointer to Runtime Error Message ΓòÉΓòÉΓòÉ
  11077.  
  11078. #include <string.h>
  11079.  
  11080. char *strerror(int errnum);
  11081.  
  11082. Language Level: ANSI, SAA 
  11083.  
  11084. Description 
  11085.  
  11086. The strerror function maps the error number in errnum to an error message 
  11087. string.  The function returns a pointer to the string.  strerror does not use 
  11088. the program locale in any way. 
  11089.  
  11090. Example of strerror 
  11091.  
  11092. Related Information 
  11093.  
  11094. o clearerr  - Reset Error Indicators 
  11095. o ferror  - Test for Read/Write Errors 
  11096. o perror  - Print Error Message 
  11097. o _strerror - Point to System Error String 
  11098. o string.h 
  11099.  
  11100.  
  11101. ΓòÉΓòÉΓòÉ 2.213. _strerror - Point to System Error String ΓòÉΓòÉΓòÉ
  11102.  
  11103. #include <string.h>
  11104.  
  11105. char *_strerror(char *string);
  11106.  
  11107. Language Level: Extension 
  11108.  
  11109. Description 
  11110.  
  11111. The _strerror function tests for system error. It gets the system error message 
  11112. for the last library call that produced an error and prefaces it with your 
  11113. string message. 
  11114.  
  11115. Your string message can be a maximum of 94 bytes. 
  11116.  
  11117. Unlike perror, _strerror by itself does not print a message.  To print the 
  11118. message returned by _strerror to stdout, use a printf statement similar to the 
  11119. following: 
  11120.  
  11121.    if ((access("datafile",2)) == -1)
  11122.       printf(stderr,_strerror(NULL));
  11123.  
  11124. You could also print the message to stderr with an fprintf statement. 
  11125.  
  11126. To produce accurate results, call _strerror immediately after a library 
  11127. function returns with an error.  Otherwise, subsequent calls might write over 
  11128. the errno value. 
  11129.  
  11130. If string is equal to NULL, _strerror returns a pointer to a string containing 
  11131. the system error message for the last library call that produced an error, 
  11132. ended by a new-line character ('\n'). 
  11133.  
  11134. If string is not equal to NULL, _strerror returns a pointer to a string 
  11135. containing: 
  11136.  
  11137. o Your string message 
  11138. o A colon 
  11139. o A space 
  11140. o The system error message for the last library call producing an error 
  11141. o A new-line character ('\n'). 
  11142.  
  11143. Example of _strerror 
  11144.  
  11145. Related Information 
  11146.  
  11147. o clearerr  - Reset Error Indicators 
  11148. o ferror  - Test for Read/Write Errors 
  11149. o perror  - Print Error Message 
  11150. o strerror  - Set Pointer to Runtime Error Message 
  11151. o string.h 
  11152.  
  11153.  
  11154. ΓòÉΓòÉΓòÉ 2.214. strftime  - Formatted Time Conversion ΓòÉΓòÉΓòÉ
  11155.  
  11156. #include <time.h>
  11157.  
  11158. size_t strftime(char *dest, size_t maxsize, const char *format,
  11159.                    const struct tm *timeptr);
  11160.  
  11161. Language Level: ANSI, SAA 
  11162.  
  11163. Description 
  11164.  
  11165. The strftime function places characters into the array pointed to by dest 
  11166. according to the string pointed to by format.  The format string is a multibyte 
  11167. character string. This function uses the current locale. 
  11168.  
  11169. The format string contains: 
  11170.  
  11171. o Conversion specification characters 
  11172. o Multibyte characters that are placed unchanged into the array. 
  11173.  
  11174. The characters that are converted are determined by the locale and by the 
  11175. values in the time structure pointed to by timeptr.  The conversion specifiers 
  11176. and their meanings are listed below: 
  11177.  
  11178. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  11179. Γöé SPECIFIERΓöé MEANING                                             Γöé
  11180. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11181. Γöé "%a"     Γöé Insert locale's abbreviated weekday name.           Γöé
  11182. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11183. Γöé "%A"     Γöé Insert locale's full weekday name.                  Γöé
  11184. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11185. Γöé "%b"     Γöé Insert locale's abbreviated month name.             Γöé
  11186. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11187. Γöé "%B"     Γöé Insert locale's full month name.                    Γöé
  11188. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11189. Γöé "%c"     Γöé Insert locale's date and time.                      Γöé
  11190. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11191. Γöé "%d"     Γöé Insert day of the month (01-31).                    Γöé
  11192. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11193. Γöé "%H"     Γöé Insert hour (24-hour clock) as a decimal number     Γöé
  11194. Γöé          Γöé (00-23).                                            Γöé
  11195. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11196. Γöé "%I"     Γöé Insert hour (12-hour clock) as a decimal number     Γöé
  11197. Γöé          Γöé (01-12).                                            Γöé
  11198. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11199. Γöé "%j"     Γöé Insert day of the year (001-366).                   Γöé
  11200. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11201. Γöé "%m"     Γöé Insert month (01-12).                               Γöé
  11202. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11203. Γöé "%M"     Γöé Insert minute (00-59).                              Γöé
  11204. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11205. Γöé "%p"     Γöé Insert locale's equivalent of either AM or PM.      Γöé
  11206. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11207. Γöé "%S"     Γöé Insert second (00-61).                              Γöé
  11208. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11209. Γöé "%U"     Γöé Insert week number of the year (00-53) where Sunday Γöé
  11210. Γöé          Γöé is the first day of the week.                       Γöé
  11211. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11212. Γöé "%w"     Γöé Insert weekday (0-6) where Sunday is 0.             Γöé
  11213. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11214. Γöé "%W"     Γöé Insert week number of the year (00-53) where Monday Γöé
  11215. Γöé          Γöé is the first day of the week.                       Γöé
  11216. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11217. Γöé "%x"     Γöé Insert locale's date representation.                Γöé
  11218. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11219. Γöé "%X"     Γöé Insert locale's time representation.                Γöé
  11220. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11221. Γöé "%y"     Γöé Insert year without the century (00-99).            Γöé
  11222. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11223. Γöé "%Y"     Γöé Insert year.                                        Γöé
  11224. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11225. Γöé "%Z"     Γöé Insert name of time zone, or no characters if time  Γöé
  11226. Γöé          Γöé zone is not available.                              Γöé
  11227. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  11228. Γöé "%%"     Γöé Insert %.                                           Γöé
  11229. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  11230.  
  11231. The behavior is undefined when objects being copied overlap.  The maximum 
  11232. number of characters that can be copied into the array is specified by maxsize. 
  11233.  
  11234. The strftime function returns the number of characters (bytes) placed into the 
  11235. array, not including the terminating null character.  On error, zero is 
  11236. returned. 
  11237.  
  11238. Note:  The time and date functions begin at 00:00 Universal Time, January 1, 
  11239. 1970. :enote. 
  11240.  
  11241. Example of strftime 
  11242.  
  11243. Related Information 
  11244.  
  11245. o asctime  - Convert Time 
  11246. o ctime  - Convert Time 
  11247. o gmtime  - Convert Time 
  11248. o localtime  - Convert Time 
  11249. o setlocale  - Sets Locale 
  11250. o time  - Determine Current Time 
  11251. o time.h 
  11252.  
  11253.  
  11254. ΓòÉΓòÉΓòÉ 2.215. stricmp - Compare Strings ΓòÉΓòÉΓòÉ
  11255.  
  11256. #include <string.h>
  11257.  
  11258. int stricmp(const char *string1, const char *string2);
  11259.  
  11260. Language Level: Extension 
  11261.  
  11262. Description 
  11263.  
  11264. The stricmp function compares string1 and string2 without sensitivity for case. 
  11265. All alphabetic characters in the arguments string1 and string2 are converted to 
  11266. lowercase before the comparison. The stricmp function operates on 
  11267. null-terminated strings. 
  11268.  
  11269. The function returns a value that indicates the following relationship between 
  11270. the two strings : 
  11271.  
  11272. Value             Meaning 
  11273. Less than 0       string1 less than string2 
  11274. 0                 string1 identical to string2 
  11275. Greater than 0    string1 greater than string2. 
  11276.  
  11277. Example of stricmp 
  11278.  
  11279. Related Information 
  11280.  
  11281. o strcmp  - Compare Strings 
  11282. o strcmpi - Compare Strings 
  11283. o strcspn  - Compare Strings 
  11284. o strncmp  - Compare Strings 
  11285. o string.h 
  11286. o strnicmp - Compare Strings 
  11287.  
  11288.  
  11289. ΓòÉΓòÉΓòÉ 2.216. strlen  - String Length ΓòÉΓòÉΓòÉ
  11290.  
  11291. #include <string.h>
  11292.  
  11293. size_t strlen(const char *string);
  11294.  
  11295. Language Level: ANSI, SAA 
  11296.  
  11297. Description 
  11298.  
  11299. The strlen function returns the length of string excluding the terminating null 
  11300. character. 
  11301.  
  11302. Example of strlen 
  11303.  
  11304. Related Information 
  11305.  
  11306. o mblen  - Multibyte String Length 
  11307. o strncat  - Concatenate Strings 
  11308. o strncmp  - Compare Strings 
  11309. o strncpy  - Copy Strings 
  11310. o strrev - Reverse String 
  11311. o wcslen  - Calculates Length of wchar_t String 
  11312. o string.h 
  11313.  
  11314.  
  11315. ΓòÉΓòÉΓòÉ 2.217. strlwr - Convert Uppercase to Lowercase ΓòÉΓòÉΓòÉ
  11316.  
  11317. #include <string.h>
  11318.  
  11319. char *strlwr(char *string);
  11320.  
  11321. Language Level: Extension 
  11322.  
  11323. Description 
  11324.  
  11325. The strlwr function converts any uppercase letters in the given null-terminated 
  11326. string to lowercase.  Other characters are not affected. 
  11327.  
  11328. The strlwr function returns a pointer to the converted string. There is no 
  11329. error return. 
  11330.  
  11331. Example of strlwr 
  11332.  
  11333. Related Information 
  11334.  
  11335. o strupr - Convert Lowercase to Uppercase 
  11336. o toascii - _tolower - _toupper - Convert Character 
  11337. o tolower - toupper  - Convert Character Case 
  11338. o string.h 
  11339.  
  11340.  
  11341. ΓòÉΓòÉΓòÉ 2.218. strncat  - Concatenate Strings ΓòÉΓòÉΓòÉ
  11342.  
  11343. #include <string.h>
  11344.  
  11345. char *strncat(char *string1, const char *string2, size_t count);
  11346.  
  11347. Language Level: ANSI, SAA 
  11348.  
  11349. Description 
  11350.  
  11351. The strncat function operates on, at most, the first count characters of 
  11352. null-terminated strings. 
  11353.  
  11354. The strncat function appends, at most, the first count characters of string2 to 
  11355. string1, ends the resulting string with a null character (\0), and returns a 
  11356. pointer to the joined string (string1).  If count is greater than the length of 
  11357. string2, the length of string2 is used in place of count. 
  11358.  
  11359. Example of strncat 
  11360.  
  11361. Related Information 
  11362.  
  11363. o strcat  - Concatenate Strings 
  11364. o strncmp  - Compare Strings 
  11365. o strncpy  - Copy Strings 
  11366. o strnicmp - Compare Strings 
  11367. o strpbrk  - Find Characters in String 
  11368. o strrchr  - Find Last Occurrence of Character in String 
  11369. o strspn  - Search Strings 
  11370. o string.h 
  11371.  
  11372.  
  11373. ΓòÉΓòÉΓòÉ 2.219. strncmp  - Compare Strings ΓòÉΓòÉΓòÉ
  11374.  
  11375. #include <string.h>
  11376.  
  11377. int strncmp(const char *string1, const char *string2, size_t count);
  11378.  
  11379. Language Level: ANSI, SAA 
  11380.  
  11381. Description 
  11382.  
  11383. The strncmp function compares, at most, the first count characters of string1 
  11384. and string2 and returns a value indicating the relationship between the 
  11385. substrings, as listed below. 
  11386.  
  11387. Value               Meaning 
  11388. Less than 0         substring1 less than substring2 
  11389. 0                   substring1 equivalent to substring2 
  11390. Greater than 0      substring1 greater than substring2 
  11391.  
  11392. Example of strncmp 
  11393.  
  11394. Related Information 
  11395.  
  11396. o strcmp  - Compare Strings 
  11397. o strcmpi - Compare Strings 
  11398. o strcspn  - Compare Strings 
  11399. o stricmp - Compare Strings 
  11400. o strncat  - Concatenate Strings 
  11401. o strncpy  - Copy Strings 
  11402. o strnicmp - Compare Strings 
  11403. o strpbrk  - Find Characters in String 
  11404. o strrchr  - Find Last Occurrence of Character in String 
  11405. o strspn  - Search Strings 
  11406. o string.h 
  11407.  
  11408.  
  11409. ΓòÉΓòÉΓòÉ 2.220. strncpy  - Copy Strings ΓòÉΓòÉΓòÉ
  11410.  
  11411. #include <string.h>
  11412.  
  11413. char *strncpy(char *string1, const char *string2, size_t count);
  11414.  
  11415. Language Level: ANSI, SAA 
  11416.  
  11417. Description 
  11418.  
  11419. The strncpy function copies exactly count characters of string2 to string1 and 
  11420. returns string1.  If count is less than or equal to the length of string2, a 
  11421. null character (\0) is not appended to the copied string.  If count is greater 
  11422. than the length of string2, the string1 result is padded with null characters 
  11423. (\0) up to length count. 
  11424.  
  11425. Example of strncpy 
  11426.  
  11427. Related Information 
  11428.  
  11429. o strcpy  - Copy Strings 
  11430. o strcspn  - Compare Strings 
  11431. o strdup - Duplicate String 
  11432. o strncat  - Concatenate Strings 
  11433. o strncmp  - Compare Strings 
  11434. o strnicmp - Compare Strings 
  11435. o strpbrk  - Find Characters in String 
  11436. o strrchr  - Find Last Occurrence of Character in String 
  11437. o strspn  - Search Strings 
  11438. o string.h 
  11439.  
  11440.  
  11441. ΓòÉΓòÉΓòÉ 2.221. strnicmp - Compare Strings ΓòÉΓòÉΓòÉ
  11442.  
  11443. #include <string.h>
  11444.  
  11445. int strnicmp(const char *string1, const char *string2, int n);
  11446.  
  11447. Language Level: Extension 
  11448.  
  11449. Description 
  11450.  
  11451. The strnicmp function operates on, at most, the first n characters of 
  11452. null-terminated strings. This function compares, at most, the first n 
  11453. characters of string1 and string2. 
  11454.  
  11455. The strnicmp function is case insensitive; the uppercase and lowercase forms of 
  11456. a letter are considered equivalent. 
  11457.  
  11458. The strnicmp returns a value indicating the relationship between the 
  11459. substrings, as listed below. 
  11460.  
  11461. Value             Meaning 
  11462. Less than 0       substring1 less than substring2 
  11463. 0                 substring1 equivalent to substring2 
  11464. Greater than 0    substring1 greater than substring2. 
  11465.  
  11466. Example of strnicmp 
  11467.  
  11468. Related Information 
  11469.  
  11470. o strcmp  - Compare Strings 
  11471. o strcmpi - Compare Strings 
  11472. o stricmp - Compare Strings 
  11473. o strncmp  - Compare Strings 
  11474. o string.h 
  11475.  
  11476.  
  11477. ΓòÉΓòÉΓòÉ 2.222. strnset - strset - Set Characters in String ΓòÉΓòÉΓòÉ
  11478.  
  11479. #include <string.h>
  11480.  
  11481. char *strnset(char *string, int c, size_t n);
  11482.  
  11483. char *strset(char *string, int c);
  11484.  
  11485. Language Level: Extension 
  11486.  
  11487. Description 
  11488.  
  11489. The strnset function sets all characters of string except the ending null 
  11490. character (\0) to c (converted to a char). The strnset function sets at most 
  11491. the first n characters of string to c (converted to a char). If n is greater 
  11492. than the length of string, the length of string is used in place of n. 
  11493.  
  11494. For both functions, the string must be initialized and must end with a null 
  11495. character (\0). 
  11496.  
  11497. Both strset and strnset return a pointer to the altered string. There is no 
  11498. error return value. 
  11499.  
  11500. Example of strnset and strset 
  11501.  
  11502. Related Information 
  11503.  
  11504. o strcat  - Concatenate Strings 
  11505. o strcmp  - Compare Strings 
  11506. o strcmpi - Compare Strings 
  11507. o strcpy  - Copy Strings 
  11508. o stricmp - Compare Strings 
  11509. o strncat  - Concatenate Strings 
  11510. o strncmp  - Compare Strings 
  11511. o strncpy  - Copy Strings 
  11512. o strnicmp - Compare Strings 
  11513. o string.h 
  11514.  
  11515.  
  11516. ΓòÉΓòÉΓòÉ 2.223. strpbrk  - Find Characters in String ΓòÉΓòÉΓòÉ
  11517.  
  11518. #include <string.h>
  11519.  
  11520. char *strpbrk(const char *string1, const char *string2);
  11521.  
  11522. Language Level: ANSI, SAA 
  11523.  
  11524. Description 
  11525.  
  11526. The strpbrk function finds in string1 the first occurrence of any character 
  11527. from string2. 
  11528.  
  11529. The strpbrk function returns a pointer to the first occurrence of any character 
  11530. from string2 in string1.  A NULL pointer indicates that string1 and string2 
  11531. have no characters in common. 
  11532.  
  11533. Example of strpbrk 
  11534.  
  11535. Related Information 
  11536.  
  11537. o strchr  - Search for Character 
  11538. o strcmp  - Compare Strings 
  11539. o strcspn  - Compare Strings 
  11540. o strncmp  - Compare Strings 
  11541. o strrchr  - Find Last Occurrence of Character in String 
  11542. o strspn  - Search Strings 
  11543. o string.h 
  11544.  
  11545.  
  11546. ΓòÉΓòÉΓòÉ 2.224. strrchr  - Find Last Occurrence of Character in String ΓòÉΓòÉΓòÉ
  11547.  
  11548. #include <string.h>
  11549.  
  11550. char *strrchr(const char *string, int c);
  11551.  
  11552. Language Level: ANSI, SAA 
  11553.  
  11554. Description Description 
  11555.  
  11556. The strrchr function finds the last occurrence of c (converted to a character) 
  11557. in string.  The ending null character is considered part of the string. 
  11558.  
  11559. The strrchr function returns a pointer to the last occurrence of c in string. 
  11560. A NULL pointer indicates that the given character is not found. 
  11561.  
  11562. Example of strrchr 
  11563.  
  11564. Related Information 
  11565.  
  11566. o strchr  - Search for Character 
  11567. o strcmp  - Compare Strings 
  11568. o strcspn  - Compare Strings 
  11569. o strncmp  - Compare Strings 
  11570. o strpbrk  - Find Characters in String 
  11571. o strspn  - Search Strings 
  11572. o string.h 
  11573.  
  11574.  
  11575. ΓòÉΓòÉΓòÉ 2.225. strrev - Reverse String ΓòÉΓòÉΓòÉ
  11576.  
  11577. #include <string.h>
  11578.  
  11579. char *strrev(char *string);
  11580.  
  11581. Language Level: Extension 
  11582.  
  11583. Description 
  11584.  
  11585. The strrev function reverses the order of the characters in the given string. 
  11586. The ending null character (\0) remains in place. 
  11587.  
  11588. The strrev function returns a pointer to the altered string.  There is no error 
  11589. return value. 
  11590.  
  11591. Example of strrev 
  11592.  
  11593. Related Information 
  11594.  
  11595. o strcat  - Concatenate Strings 
  11596. o strcmp  - Compare Strings 
  11597. o strcpy  - Copy Strings 
  11598. o strdup - Duplicate String 
  11599. o strnset - strset - Set Characters in String 
  11600. o string.h 
  11601.  
  11602.  
  11603. ΓòÉΓòÉΓòÉ 2.226. strspn  - Search Strings ΓòÉΓòÉΓòÉ
  11604.  
  11605. #include <string.h>
  11606.  
  11607. size_t strspn(const char *string1, const char *string2);
  11608.  
  11609. Language Level: ANSI, SAA 
  11610.  
  11611. Description 
  11612.  
  11613. The strspn function returns the index of the first character in string1 that is 
  11614. not contained in the set of characters specified by string2.  This value is 
  11615. equal to the length of the initial substring of string1 that consists entirely 
  11616. of characters from string2.  The null character (\0) that ends string2 is not 
  11617. considered in the matching process.  If string1 begins with a character not in 
  11618. string2, strspn returns 0. 
  11619.  
  11620. If all the characters in string1 are found in string2, the length of string1 is 
  11621. returned. 
  11622.  
  11623. Example of strspn 
  11624.  
  11625. Related Information 
  11626.  
  11627. o strcat  - Concatenate Strings 
  11628. o strchr  - Search for Character 
  11629. o strcmp  - Compare Strings 
  11630. o strcpy  - Copy Strings 
  11631. o strcspn  - Compare Strings 
  11632. o strpbrk  - Find Characters in String 
  11633. o strrchr  - Find Last Occurrence of Character in String 
  11634. o string.h 
  11635.  
  11636.  
  11637. ΓòÉΓòÉΓòÉ 2.227. strstr  - Locate Substring ΓòÉΓòÉΓòÉ
  11638.  
  11639. #include <string.h>
  11640.  
  11641. char *strstr(const char *string1, const char *string2);
  11642.  
  11643. Language Level: ANSI, SAA 
  11644.  
  11645. Description 
  11646.  
  11647. The strstr function returns a pointer to the beginning of the first occurrence 
  11648. of string2 in string1.  The strstr function ignores the null character (\0) 
  11649. that ends string2 in the matching process. 
  11650.  
  11651. If string2 does not appear in string1, strstr returns NULL. 
  11652.  
  11653. If string2 points to a string with zero length, the function returns string1. 
  11654.  
  11655. Example of strstr 
  11656.  
  11657. Related Information 
  11658.  
  11659. o strchr  - Search for Character 
  11660. o strcmp  - Compare Strings 
  11661. o strcspn  - Compare Strings 
  11662. o strncmp  - Compare Strings 
  11663. o strpbrk  - Find Characters in String 
  11664. o strrchr  - Find Last Occurrence of Character in String 
  11665. o strspn  - Search Strings 
  11666. o string.h 
  11667.  
  11668.  
  11669. ΓòÉΓòÉΓòÉ 2.228. _strtime - Copy Time ΓòÉΓòÉΓòÉ
  11670.  
  11671. #include <time.h>
  11672.  
  11673. char *_strtime(char *time);
  11674.  
  11675. Language Level: Extension 
  11676.  
  11677. Description 
  11678.  
  11679. The _strtime function copies the current time into the buffer to which time 
  11680. points.  The format is: 
  11681.  
  11682.    hh:mm:ss
  11683.  
  11684. where 
  11685.  
  11686. hh represents the hour in 24-hour notation 
  11687.  
  11688. mm represents the minutes past the hour, 
  11689.  
  11690. ss represents the number of seconds. 
  11691.  
  11692. For example, the string 18:23:44 represents 23 minutes and 44 seconds past 6 
  11693. p.m. 
  11694.  
  11695. The buffer must be at least 9 bytes. 
  11696.  
  11697. Note:  The time and date functions begin at 00:00 Universal Time, January 1, 
  11698. 1970. :enote. 
  11699.  
  11700. The value returned is a pointer to the buffer.  There is no error return. 
  11701.  
  11702. Example of _strtime 
  11703.  
  11704. Related Information 
  11705.  
  11706. o asctime  - Convert Time 
  11707. o ctime  - Convert Time 
  11708. o gmtime  - Convert Time 
  11709. o localtime  - Convert Time 
  11710. o mktime  - Convert Local Time 
  11711. o time  - Determine Current Time 
  11712. o _tzset - Assign Values to Locale Information 
  11713. o time.h 
  11714.  
  11715.  
  11716. ΓòÉΓòÉΓòÉ 2.229. strtod  - Convert Character String to Numeric ΓòÉΓòÉΓòÉ
  11717.  
  11718. #include <stdlib.h>
  11719.  
  11720. double strtod(const char *nptr, char **endptr);
  11721.     /* Convert the string pointed to by nptr to double */
  11722.  
  11723. Language Level: ANSI, SAA 
  11724.  
  11725. Description 
  11726.  
  11727. The strtod function converts a character string to a double-precision value. 
  11728. The parameter nptr points to a sequence of characters that can be interpreted 
  11729. as a numerical value of the type double.  This function stops reading the 
  11730. string at the first character that it cannot recognize as part of a number. 
  11731. This character can be the null character at the end of the string. 
  11732.  
  11733. The strtod function expects nptr to point to a string with the following form: 
  11734.  
  11735.  ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ
  11736.     Γöé              Γöé  Γöé       Γöé  Γöé                                 Γöé
  11737.     ΓööΓöÇΓöÇwhitespaceΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ + ΓöÇΓöÇΓöñ  Γö£ΓöÇdigitsΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöñ
  11738.                       Γöé       Γöé  Γöé          Γöé      Γöé   Γöé        Γöé  Γöé
  11739.                       ΓööΓöÇΓöÇ - ΓöÇΓöÇΓöÿ  Γöé          ΓööΓöÇΓöÇ . ΓöÇΓöÿ   ΓööΓöÇdigitsΓöÇΓöÿ  Γöé
  11740.                                  Γöé                                 Γöé
  11741.                                  ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ . ΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  11742.  
  11743.  ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ
  11744.    Γöé                           Γöé
  11745.    Γö£ΓöÇΓöÇeΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇdigitsΓöÇΓöÇΓöÿ
  11746.    Γöé     Γöé   Γöé     Γöé
  11747.    ΓööΓöÇΓöÇEΓöÇΓöÇΓöÿ   Γö£ΓöÇ + ΓöÇΓöñ
  11748.              Γöé     Γöé
  11749.              ΓööΓöÇ - ΓöÇΓöÿ
  11750.  
  11751. The first character that does not fit this form stops the scan. 
  11752.  
  11753. ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ
  11754.     Γöé              Γöé  Γöé       Γöé  Γöé      Γöé  Γöé          Γöé
  11755.     ΓööΓöÇΓöÇwhitespaceΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ + ΓöÇΓöÇΓöñ  Γö£ΓöÇΓöÇ0ΓöÇΓöÇΓöÇΓöñ  ΓööΓöÇΓöÇdigitsΓöÇΓöÇΓöÿ
  11756.                       Γöé       Γöé  Γöé      Γöé
  11757.                       ΓööΓöÇΓöÇ - ΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ0xΓöÇΓöÇΓöñ
  11758.                                  Γöé      Γöé
  11759.                                  ΓööΓöÇΓöÇ0XΓöÇΓöÇΓöÿ
  11760.  
  11761. The strtod function returns the value of the floating-point number, except when 
  11762. the representation causes an underflow or overflow.  In the case of an 
  11763. overflow, it returns -HUGE_VAL or +HUGE_VAL;  in the case of an underflow, it 
  11764. returns 0. 
  11765.  
  11766. errno is set to ERANGE for the exceptional cases, depending on the base of the 
  11767. value.  If the string pointed to by nptr does not have the expected form, no 
  11768. conversion is performed and the value of nptr is stored in the object pointed 
  11769. to by endptr, provided that endptr is not a NULL pointer. 
  11770.  
  11771. Example of strtod 
  11772.  
  11773. Related Information 
  11774.  
  11775. o atof  - Convert Character Strings 
  11776. o atoi  - Convert Character Strings 
  11777. o atol  - Convert Character Strings 
  11778. o _atold - Convert ASCII String to Lo         ng Double 
  11779. o strtol  - Convert Character String to Numeric 
  11780. o strtoul  - Convert String Segment to Unsigned Integer 
  11781. o stdlib.h 
  11782. o strtold - Convert String to Long Double 
  11783.  
  11784.  
  11785. ΓòÉΓòÉΓòÉ 2.230. strtok  - Tokenize String ΓòÉΓòÉΓòÉ
  11786.  
  11787. #include <string.h>
  11788.  
  11789. char *strtok(char *string1, const char *string2);
  11790.  
  11791. Language Level: ANSI, SAA 
  11792.  
  11793. Description 
  11794.  
  11795. The strtok function reads string1 as a series of zero or more tokens and 
  11796. string2 as the set of characters serving as delimiters of the tokens in 
  11797. string1.  The tokens in string1 can be separated by one or more of the 
  11798. delimiters from string2.  The tokens in string1 can be located by a series of 
  11799. calls to strtok. 
  11800.  
  11801. In the first call to strtok for a given string1, strtok searches for the first 
  11802. token in string1, skipping over leading delimiters.  A pointer to the first 
  11803. token is returned. 
  11804.  
  11805. To read the next token from string1, call strtok with a NULL string1 argument. 
  11806. A NULL string1 argument causes strtok to search for the next token in the 
  11807. previous token string. Each delimiter is replaced by a null character.  The set 
  11808. of delimiters can vary from call to call, so string2 can take any value. 
  11809.  
  11810. The first time strtok is called, it returns a pointer to the first token in 
  11811. string1.  In later calls with the same token string, strtok returns a pointer 
  11812. to the next token in the string.  A NULL pointer is returned when there are no 
  11813. more tokens.  All tokens are null-terminated. 
  11814.  
  11815. Example of strtok 
  11816.  
  11817. Related Information 
  11818.  
  11819. o strcat  - Concatenate Strings 
  11820. o strchr  - Search for Character 
  11821. o strcmp  - Compare Strings 
  11822. o strcpy  - Copy Strings 
  11823. o strcspn  - Compare Strings 
  11824. o strspn  - Search Strings 
  11825. o string.h 
  11826.  
  11827.  
  11828. ΓòÉΓòÉΓòÉ 2.231. strtol  - Convert Character String to Numeric ΓòÉΓòÉΓòÉ
  11829.  
  11830. #include <stdlib.h>
  11831.  
  11832. long int strtol(const char *nptr, char **endptr, int base);
  11833.  
  11834. Language Level: ANSI, SAA 
  11835.  
  11836. Description 
  11837.  
  11838. The strtol function converts a character string to a long-integer value.  The 
  11839. parameter nptr points to a sequence of characters that can be interpreted as a 
  11840. numerical value of type long int.  This function stops reading the string at 
  11841. the first character that it cannot recognize as part of a number.  This 
  11842. character can be the null character at the end of the string. The ending 
  11843. character can also be the first numeric character greater than or equal to the 
  11844. base. 
  11845.  
  11846. strtol expects nptr to point to a string with the following form: 
  11847.  
  11848. ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ
  11849.     Γöé              Γöé  Γöé       Γöé  Γöé      Γöé  Γöé          Γöé
  11850.     ΓööΓöÇΓöÇwhitespaceΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ + ΓöÇΓöÇΓöñ  Γö£ΓöÇΓöÇ0ΓöÇΓöÇΓöÇΓöñ  ΓööΓöÇΓöÇdigitsΓöÇΓöÇΓöÿ
  11851.                       Γöé       Γöé  Γöé      Γöé
  11852.                       ΓööΓöÇΓöÇ - ΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ0xΓöÇΓöÇΓöñ
  11853.                                  Γöé      Γöé
  11854.                                  ΓööΓöÇΓöÇ0XΓöÇΓöÇΓöÿ
  11855.  
  11856. If base is from 2 through 36, it becomes the base of the number.  If base is 0, 
  11857. the prefix determines the base (8, 16, or 10):  the prefix 0 means base 8;  the 
  11858. prefix 0x or 0X means base 16;  using any other digit without a prefix means 
  11859. decimal. 
  11860.  
  11861. The strtol function returns the value represented in the string, except when 
  11862. the representation causes an overflow.  In the case of an overflow, it returns 
  11863. LONG_MAX or LONG_MIN, according to the sign of the value and errno is set to 
  11864. ERANGE. If base is not a valid number, strtol sets errno to EDOM. 
  11865.  
  11866. errno is set to ERANGE for the exceptional cases, depending on the base of the 
  11867. value.  If the string pointed to by nptr does not have the expected form, no 
  11868. conversion is performed and the value of nptr is stored in the object pointed 
  11869. to by endptr, provided that endptr is not a NULL pointer. 
  11870.  
  11871. Example of strtol 
  11872.  
  11873. Related Information 
  11874.  
  11875. o atof  - Convert Character Strings 
  11876. o atoi  - Convert Character Strings 
  11877. o atol  - Convert Character Strings 
  11878. o _atold - Convert ASCII String to Lo         ng Double 
  11879. o _ltoa - Convert Long Integer to String 
  11880. o strtod  - Convert Character String to Numeric 
  11881. o strtoul  - Convert String Segment to Unsigned Integer 
  11882. o stdlib.h 
  11883.  
  11884.  
  11885. ΓòÉΓòÉΓòÉ 2.232. strtold - Convert String to Long Double ΓòÉΓòÉΓòÉ
  11886.  
  11887. #include <stdlib.h>
  11888.  
  11889. long double strtold(const char *nptr, char **endptr);
  11890.  
  11891. Language Level: Extension 
  11892.  
  11893. Description 
  11894.  
  11895. The strtold function converts a character string pointed to by nptr to a long 
  11896. double value.  When it reads a character it does not recognize as part of a 
  11897. number, strtold stops conversion and endptr points to the remainder of nptr. 
  11898. This character may be the ending null character. 
  11899.  
  11900. The string pointed to by nptr must have the following format: 
  11901.  
  11902.  ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ
  11903.     ΓööΓöÇΓöÇwhitespaceΓöÇΓöÇΓöÿ  ΓööΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  11904.                         Γö£ΓöÇΓöÇΓöÇ+ΓöÇΓöÇΓöÇΓöñ  Γö£ΓöÇΓöÇdigitsΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöñ
  11905.                         ΓööΓöÇΓöÇΓöÇ-ΓöÇΓöÇΓöÇΓöÿ  Γöé          ΓööΓöÇΓöÇ.ΓöÇΓöÇΓöÿ ΓööΓöÇdigitsΓöÇΓöÿ Γöé
  11906.                                    ΓööΓöÇΓöÇΓöÇΓöÇΓöÇ.ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  11907.  
  11908.   ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ
  11909.     Γö£ΓöÇΓöÇeΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇdigitsΓöÇΓöÇΓöÿ
  11910.     ΓööΓöÇΓöÇEΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ+ΓöÇΓöÇΓöñ
  11911.              ΓööΓöÇΓöÇ-ΓöÇΓöÇΓöÿ
  11912.  
  11913. The digits are one or more decimal digits.  If no digits appear before the 
  11914. decimal point, at least one digit must follow the decimal point.  An exponent 
  11915. expressed as a decimal integer may follow the digits.  The exponent may be 
  11916. signed. 
  11917.  
  11918. The value of nptr can also be one of the strings infinity, inf, or nan.  These 
  11919. strings are case insensitive, and can be preceded by a unary minus (-). They 
  11920. are converted to infinity and NaN values. See Infinity and NaN Support for more 
  11921. information about using infinity and NaN values. 
  11922.  
  11923. If the string pointed to by nptr does not have the expected form, no conversion 
  11924. is performed and endptr points to the value of nptr. 
  11925.  
  11926. The strtold function ignores any whitespace characters, as defined by the 
  11927. isspace function. 
  11928.  
  11929. If successful, strtold returns the value of the long double number.  If it 
  11930. fails, strtold returns 0.  In the case of an underflow or overflow, it returns 
  11931. the following: 
  11932.  
  11933. Condition           Return Value 
  11934. Underflow           0 with errno set to ERANGE 
  11935. Positive overflow   +_LHUGE_VAL 
  11936. Negative overflow   -_LHUGE_VAL. 
  11937.  
  11938. Example of strtold 
  11939.  
  11940. Related Information 
  11941.  
  11942. o atof  - Convert Character Strings 
  11943. o atoi  - Convert Character Strings 
  11944. o atol  - Convert Character Strings 
  11945. o _atold - Convert ASCII String to Lo         ng Double 
  11946. o strtod  - Convert Character String to Numeric 
  11947. o strtol  - Convert Character String to Numeric 
  11948. o Infinity and NaN Support 
  11949. o stdlib.h 
  11950.  
  11951.  
  11952. ΓòÉΓòÉΓòÉ 2.233. strtoul  - Convert String Segment to Unsigned Integer ΓòÉΓòÉΓòÉ
  11953.  
  11954. #include <stdlib.h>
  11955.  
  11956. unsigned long int strtoul(const char *string1, char **string2, int base);
  11957.  
  11958. Language Level: ANSI, SAA 
  11959.  
  11960. Description 
  11961.  
  11962. The strtoul function converts a character string to an unsigned long-integer 
  11963. value.  The input string1 is a sequence of characters that can be interpreted 
  11964. as a numerical value of the type long int.  The function stops reading the 
  11965. string at the first character that it cannot recognize as part of a number. 
  11966. This character can be the first numeric character greater than or equal to the 
  11967. base. The strtoul function sets string2 to point to the resulting output string 
  11968. if a conversion is performed and provided that string2 is not a NULL pointer. 
  11969.  
  11970. strtoul expects string1 to point to a string with the following form: 
  11971.  
  11972. ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ
  11973.     Γöé              Γöé  Γöé       Γöé  Γöé      Γöé  Γöé          Γöé
  11974.     ΓööΓöÇΓöÇwhitespaceΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ + ΓöÇΓöÇΓöñ  Γö£ΓöÇΓöÇ0ΓöÇΓöÇΓöÇΓöñ  ΓööΓöÇΓöÇdigitsΓöÇΓöÇΓöÿ
  11975.                       Γöé       Γöé  Γöé      Γöé
  11976.                       ΓööΓöÇΓöÇ - ΓöÇΓöÇΓöÿ  Γö£ΓöÇΓöÇ0xΓöÇΓöÇΓöñ
  11977.                                  Γöé      Γöé
  11978.                                  ΓööΓöÇΓöÇ0XΓöÇΓöÇΓöÿ
  11979.  
  11980. If base is in the range of 2 through 36, it becomes the base of the number.  If 
  11981. base is 0, the prefix determines the base (8, 16, or 10):  the prefix 0 means 
  11982. base 8;  the prefix 0x or 0X means base 16;  using any other digit without a 
  11983. prefix means decimal. 
  11984.  
  11985. The strtoul function returns the value represented in the string or returns 0 
  11986. if no conversion could be performed. For an overflow, strtoul returns ULONG_MAX 
  11987. and sets errno to ERANGE.  If base is not a valid number, strtoul sets errno to 
  11988. EDOM. 
  11989.  
  11990. Example of strtoul 
  11991.  
  11992. Related Information 
  11993.  
  11994. o atof  - Convert Character Strings 
  11995. o atoi  - Convert Character Strings 
  11996. o atol  - Convert Character Strings 
  11997. o _atold - Convert ASCII String to Lo         ng Double 
  11998. o strtod  - Convert Character String to Numeric 
  11999. o strtol  - Convert Character String to Numeric 
  12000. o strtold - Convert String to Long Double 
  12001. o _ultoa - Convert Unsigned Long Integer to Str         ing 
  12002. o stdlib.h 
  12003.  
  12004.  
  12005. ΓòÉΓòÉΓòÉ 2.234. strupr - Convert Lowercase to Uppercase ΓòÉΓòÉΓòÉ
  12006.  
  12007. #include <string.h>
  12008.  
  12009. char *strupr(char *string);
  12010.  
  12011. Language Level: Extension 
  12012.  
  12013. Description 
  12014.  
  12015. The strupr function converts any lowercase letters in string to uppercase. 
  12016. Other characters are not affected. 
  12017.  
  12018. The strupr function returns a pointer to the converted string. There is no 
  12019. error return. 
  12020.  
  12021. Example of strupr 
  12022.  
  12023. Related Information 
  12024.  
  12025. o strlwr - Convert Uppercase to Lowercase 
  12026. o toascii - _tolower - _toupper - Convert Character 
  12027. o tolower - toupper  - Convert Character Case 
  12028. o string.h 
  12029.  
  12030.  
  12031. ΓòÉΓòÉΓòÉ 2.235. strxfrm  - Transforms Strings ΓòÉΓòÉΓòÉ
  12032.  
  12033. #include <string.h>
  12034.  
  12035. size_t strxfrm(char *string1, const char *string2, size_t count);
  12036.  
  12037. Language Level: ANSI, SAA 
  12038.  
  12039. Description 
  12040.  
  12041. The strxfrm function transforms the string pointed to by string2 and places the 
  12042. result into the string pointed to by string1.  The transformation is determined 
  12043. by the program's current locale.  The transformed string is not necessarily 
  12044. readable, but can be used with the strcmp or strncmp functions. 
  12045.  
  12046. The strxfrm function returns the length of the transformed string, not 
  12047. including the terminating null character.  If the value returned is equal to or 
  12048. greater than count, the contents of the transformed string are indeterminate. 
  12049.  
  12050. Example of strxfrm 
  12051.  
  12052. Related Information 
  12053.  
  12054. o localeconv  - Query Locale Conventions 
  12055. o strcmp  - Compare Strings 
  12056. o strcoll  - Compares Strings 
  12057. o strncmp  - Compare Strings 
  12058. o setlocale  - Sets Locale 
  12059. o string.h 
  12060.  
  12061.  
  12062. ΓòÉΓòÉΓòÉ 2.236. _swab - Swap Adjacent Bytes ΓòÉΓòÉΓòÉ
  12063.  
  12064. #include <stdlib.h>
  12065.  
  12066. void _swab(char *source, char *destination, int n);
  12067.  
  12068. Language Level: Extension 
  12069.  
  12070. Description 
  12071.  
  12072. The _swab function copies n bytes from source, swaps each pair of adjacent 
  12073. bytes, and stores the result at destination.  The integer n should be an even 
  12074. number to allow for swapping. If n is an odd number, a null character (\0) will 
  12075. be added after the last byte. 
  12076.  
  12077. The _swab function is typically used to prepare binary data for transfer to a 
  12078. machine that uses a different byte order. 
  12079.  
  12080. There is no return value. 
  12081.  
  12082. Example of _swab 
  12083.  
  12084. Related Information 
  12085.  
  12086. o fgetc  - Read a Character 
  12087. o fputc  - Write a Character 
  12088. o stdlib.h 
  12089.  
  12090.  
  12091. ΓòÉΓòÉΓòÉ 2.237. system - Invoke the Command Processor ΓòÉΓòÉΓòÉ
  12092.  
  12093. #include <stdlib.h>
  12094.  
  12095. int system(char *string);
  12096.  
  12097. Language Level: ANSI, SAA, Extension 
  12098.  
  12099. Description 
  12100.  
  12101. The system function passes the command string to a command processor to be run. 
  12102. The command processor specified in the COMSPEC environment variable is searched 
  12103. for first. If it does not exist or is not a valid executable file, the default 
  12104. command processor, CMD.EXE, is searched for in the current directory and in all 
  12105. the directories specified in the PATH environment variable. 
  12106.  
  12107. If the specified command is the name of an executable file created from a C 
  12108. program, full initialization and termination will be performed.  This operation 
  12109. includes automatic flushing of buffers and closing of files.  To pass 
  12110. information across a system function, use a method of interprocess 
  12111. communication like pipes or shared memory. 
  12112.  
  12113. You can redirect standard streams using the redirection operators (the angle 
  12114. brackets), for example: 
  12115.  
  12116.    rc = system("cprogram < in.file");
  12117.  
  12118. The defaults for the standard streams will be whatever the standard streams are 
  12119. at the point of the system call;  for example, if the root program redirects 
  12120. stdout to file.txt, a printf call in a C module invoked by a system call will 
  12121. append to file.txt. 
  12122.  
  12123. If the argument is a null pointer, the system function returns nonzero if a 
  12124. command processor exists and 0 if it does not exist. The return value will be 
  12125. the return value from the command processor if it is successfully called. If 
  12126. system cannot call the command processor successfully, the return value is -1 
  12127. and errno is set to one of the following values: 
  12128.  
  12129. Value         Meaning 
  12130. ENOCMD        No valid command processor found. 
  12131. ENOMEM        Insufficient memory to complete the function. 
  12132. EOS2ERR       A system error occurred.  Check _doserrno for the specific OS/2 
  12133.               error code. 
  12134.  
  12135. Example of system 
  12136.  
  12137. Related Information 
  12138.  
  12139. o exit  - End Program 
  12140. o _exit - End Process 
  12141. o process.h 
  12142. o stdlib.h 
  12143.  
  12144.  
  12145. ΓòÉΓòÉΓòÉ 2.238. tan  - Tangent ΓòÉΓòÉΓòÉ
  12146.  
  12147. #include <math.h>
  12148.  
  12149. double tan(double x);     /* Calculate tangent of x */
  12150.  
  12151. Language Level: ANSI, SAA 
  12152.  
  12153. Description 
  12154.  
  12155. The tan function returns the tangent of x, where x is expressed in radians.  If 
  12156. x is large, a partial loss of significance in the result can occur. 
  12157.  
  12158. Example of tan 
  12159.  
  12160. Related Information 
  12161.  
  12162. o acos  - Arc Cosine 
  12163. o asin  - Arc Sine 
  12164. o atan - atan2  - Arc Tangent 
  12165. o cos  - Cosine 
  12166. o cosh  - Hyperbolic Cosine 
  12167. o sin  - Sine 
  12168. o sinh  - Hyperbolic Sine 
  12169. o tanh  - Hyperbolic Tangent 
  12170. o math.h 
  12171.  
  12172.  
  12173. ΓòÉΓòÉΓòÉ 2.239. tanh  - Hyperbolic Tangent ΓòÉΓòÉΓòÉ
  12174.  
  12175. #include <math.h>
  12176.  
  12177. double tanh(double x);    /* Calculate hyperbolic tangent of x */
  12178.  
  12179. Language Level: ANSI, SAA 
  12180.  
  12181. Description 
  12182.  
  12183. The tanh function returns the hyperbolic tangent of x, where x is expressed in 
  12184. radians. The result of the tanh function cannot have a range error. 
  12185.  
  12186. Example of tanh 
  12187.  
  12188. Related Information 
  12189.  
  12190. o acos  - Arc Cosine 
  12191. o asin  - Arc Sine 
  12192. o atan - atan2  - Arc Tangent 
  12193. o cos  - Cosine 
  12194. o cosh  - Hyperbolic Cosine 
  12195. o sin  - Sine 
  12196. o sinh  - Hyperbolic Sine 
  12197. o tan  - Tangent 
  12198. o math.h 
  12199.  
  12200.  
  12201. ΓòÉΓòÉΓòÉ 2.240. _tell - Get Pointer Position ΓòÉΓòÉΓòÉ
  12202.  
  12203. #include <io.h>
  12204.  
  12205. long _tell(int handle);
  12206.  
  12207. Language Level: Extension 
  12208.  
  12209. Description 
  12210.  
  12211. The _tell function gets the current position of the file pointer associated 
  12212. with handle. The position is the number of bytes from the beginning of the 
  12213. file. 
  12214.  
  12215. The _tell function returns the current position. A return value of -1L 
  12216. indicates an error, and errno is set to one of the following values: 
  12217.  
  12218. Value          Meaning 
  12219. EBADF          The file handle is not valid. 
  12220. EOS2ERR        The call to the operating system was not successful. 
  12221.  
  12222. On devices incapable of seeking (such as screens and printers), the return 
  12223. value is -1L. 
  12224.  
  12225. Example of _tell 
  12226.  
  12227. Related Information 
  12228.  
  12229. o _lseek - Move File Pointer 
  12230. o io.h 
  12231.  
  12232.  
  12233. ΓòÉΓòÉΓòÉ 2.241. _tempnam - Produce Temporary File Name ΓòÉΓòÉΓòÉ
  12234.  
  12235. #include <stdio.h>
  12236.  
  12237. char *_tempnam(char *dir, char *prefix);
  12238.  
  12239. Language Level: Extension 
  12240.  
  12241. Description 
  12242.  
  12243. The _tempnam function creates a temporary file name in another directory.  The 
  12244. prefix is the prefix to the file name. The _tempnam function tests for the 
  12245. existence of the file with the given name in the following directories, listed 
  12246. in order of precedence: 
  12247.  
  12248. o If the TMP environment variable is set and the directory specified by TMP 
  12249.   exists, the directory is specified by TMP. 
  12250.  
  12251. o If the TMP environment variable is not set or the directory specified by TMP 
  12252.   does not exist, the directory is specified by the dir argument to _tempnam 
  12253.  
  12254. o If the dir argument is NULL, or dir is the name of nonexistent directory, the 
  12255.   directory is pointed to by P_tmpdir in <stdio.h>. 
  12256.  
  12257. o If P_tmpdir does not exist, the directory is the current working directory. 
  12258.  
  12259. Note:  Because _tempnam uses malloc to reserve space for the created file name, 
  12260. you must free this space when you no longer need it. 
  12261.  
  12262. The _tempnam function returns a pointer to the temporary name, unless the name 
  12263. cannot be created or the name is not unique.  If the name cannot be created or 
  12264. it already exists, _tempnam returns the value NULL. 
  12265.  
  12266. Example of _tempnam 
  12267.  
  12268. Related Information 
  12269.  
  12270. o malloc  - Reserve Storage Block 
  12271. o tmpfile  - Create Temporary File 
  12272. o tmpnam  - Produce Temporary File Name 
  12273. o stdio.h 
  12274.  
  12275.  
  12276. ΓòÉΓòÉΓòÉ 2.242. time  - Determine Current Time ΓòÉΓòÉΓòÉ
  12277.  
  12278. #include <time.h>
  12279.  
  12280. time_t time(time_t *timeptr);
  12281.  
  12282. Language Level: ANSI, SAA 
  12283.  
  12284. Description 
  12285.  
  12286. The time function returns the current calendar time, which is not necessarily 
  12287. the local time localtime.  The return value is also stored in the location 
  12288. given by timeptr.  If timeptr is NULL, the return value is not stored. 
  12289.  
  12290. The value (time_t)(-1) is returned if the calendar time is not available. 
  12291.  
  12292. Note:  The time and date functions begin at 00:00 Universal Time, January 1, 
  12293. 1970. :enote. 
  12294.  
  12295. Example of time 
  12296.  
  12297. Related Information 
  12298.  
  12299. o asctime  - Convert Time 
  12300. o ctime  - Convert Time 
  12301. o gmtime  - Convert Time 
  12302. o localtime  - Convert Time 
  12303. o mktime  - Convert Local Time 
  12304. o _strtime - Copy Time 
  12305. o time.h 
  12306.  
  12307.  
  12308. ΓòÉΓòÉΓòÉ 2.243. tmpfile  - Create Temporary File ΓòÉΓòÉΓòÉ
  12309.  
  12310. #include <stdio.h>
  12311.  
  12312. FILE *tmpfile(void);
  12313.  
  12314. Language Level: ANSI, SAA 
  12315.  
  12316. Description 
  12317.  
  12318. The tmpfile function creates a temporary binary file.  The file is 
  12319. automatically removed when it is closed or when the program is terminated. 
  12320.  
  12321. The tmpfile function opens the temporary file in wb+ mode. 
  12322.  
  12323. The tmpfile function returns a stream pointer, but returns a NULL pointer if it 
  12324. cannot open the file. On normal termination (exit), these temporary files are 
  12325. removed. 
  12326.  
  12327. Example of tmpfile 
  12328.  
  12329. Related Information 
  12330.  
  12331. o fopen  - Open Files 
  12332. o stdio.h 
  12333.  
  12334.  
  12335. ΓòÉΓòÉΓòÉ 2.244. tmpnam  - Produce Temporary File Name ΓòÉΓòÉΓòÉ
  12336.  
  12337. #include <stdio.h>
  12338.  
  12339. char *tmpnam(char *string);
  12340.  
  12341. Language Level: ANSI, SAA 
  12342.  
  12343. Description 
  12344.  
  12345. The tmpnam function produces a valid file name that is not the same as the name 
  12346. of any existing file. It stores this name in string.  If string is NULL, tmpnam 
  12347. leaves the result in an internal static buffer.  Any subsequent calls destroy 
  12348. this value.  If string is not NULL, it must point to an array of at least 
  12349. L_tmpnam bytes.  The value of L_tmpnam is defined in <stdio.h>. 
  12350.  
  12351. The tmpnam function returns a pointer to the name, unless it cannot create a 
  12352. unique name in which case it returns NULL. 
  12353.  
  12354. The tmpnam function produces a different name each time it is called within a 
  12355. module up to at least TMP_MAX (a value of at least 25) names.  Note that files 
  12356. created using names returned by tmpnam are not automatically discarded at the 
  12357. end of the program.  Files can be removed by the remove function. 
  12358.  
  12359. Example of tmpnam 
  12360.  
  12361. Related Information 
  12362.  
  12363. o fopen  - Open Files 
  12364. o remove  - Delete File 
  12365. o _tempnam - Produce Temporary File Name 
  12366. o stdio.h 
  12367.  
  12368.  
  12369. ΓòÉΓòÉΓòÉ 2.245. toascii - _tolower - _toupper - Convert Character ΓòÉΓòÉΓòÉ
  12370.  
  12371. #include <ctype.h>
  12372. int _toascii(int c);
  12373.  
  12374. int _tolower(int c);
  12375.  
  12376. int _toupper(int c);
  12377.  
  12378. Language Level: Extension 
  12379.  
  12380. Description 
  12381.  
  12382. The _toascii, _tolower, and _toupper macros convert a single character as 
  12383. described below. 
  12384.  
  12385. The _toascii macro sets all but the low-order 7 bits of c to 0 so that the 
  12386. converted value represents a character in the ASCII character set.  If c 
  12387. already represents an ASCII character, c is unchanged. 
  12388.  
  12389. Only use the _tolower macro when you know that c is uppercase. The result of 
  12390. _tolower is undefined if c is not an uppercase letter. 
  12391.  
  12392. Use the _toupper macro when you know that c is lowercase. The result of 
  12393. _toupper is undefined if c is not a lowercase letter. 
  12394.  
  12395. Note:  These are all macros, but _tolower and _toupper also have function 
  12396. versions because the macro versions do not correctly handle arguments with side 
  12397. effects.  Function declarations of tolower and toupper are given in <stdlib.h>. 
  12398. The function versions are part of the standard library, and are SAA-conforming. 
  12399. For portability, use the functions instead of the macros. 
  12400.  
  12401. The _toascii, _tolower, and _toupper macros return the possibly converted 
  12402. character c.  There is no error return. 
  12403.  
  12404. Example of _toascii - _tolower - _toupper 
  12405.  
  12406. Related Information 
  12407.  
  12408. o isalnum to isxdigit  - Test Integer Value 
  12409. o isascii - Test Integer Values 
  12410. o _iscsym - _iscsymf - Test Integer 
  12411. o tolower - toupper  - Convert Character Case 
  12412. o ctype.h 
  12413.  
  12414.  
  12415. ΓòÉΓòÉΓòÉ 2.246. tolower - toupper  - Convert Character Case ΓòÉΓòÉΓòÉ
  12416.  
  12417. #include <ctype.h>
  12418.  
  12419. int tolower(int c);   /* Convert c to lowercase if appropriate */
  12420.  
  12421. int toupper(int c);   /* Convert c to uppercase if appropriate */
  12422.  
  12423. Language Level: ANSI, SAA 
  12424.  
  12425. Description 
  12426.  
  12427. The tolower function returns a lowercase c if c represents an uppercase letter; 
  12428. otherwise, c is returned.  c is unchanged. 
  12429.  
  12430. The toupper function returns an uppercase c if c represents a lowercase letter; 
  12431. otherwise, c is returned. c is unchanged. 
  12432.  
  12433. Example of tolower - toupper 
  12434.  
  12435. Related Information 
  12436.  
  12437. o isalnum to isxdigit  - Test Integer Value 
  12438. o isascii - Test Integer Values 
  12439. o _iscsym - _iscsymf - Test Integer 
  12440. o toascii - _tolower - _toupper - Convert Character 
  12441. o ctype.h 
  12442.  
  12443.  
  12444. ΓòÉΓòÉΓòÉ 2.247. _tzset - Assign Values to Locale Information ΓòÉΓòÉΓòÉ
  12445.  
  12446. #include <time.h>
  12447.  
  12448. void _tzset(void);
  12449.  
  12450. Language Level: Extension 
  12451.  
  12452. Description 
  12453.  
  12454. The _tzset function uses the environment variable TZ to change the time zone 
  12455. and daylight saving time (DST) zone values of your current locale. These values 
  12456. are used by the gmtime and localtime functions to make corrections from 
  12457. coordinated universal time (formerly GMT) to local time. 
  12458.  
  12459. To use _tzset, set the TZ variable to the appropriate values (for the possible 
  12460. values for TZ, see the chapter on runtime environment variables in the IBM 
  12461. Giverny Programming Guide). Then call _tzset to incorporate the changes in the 
  12462. time zone information into your current locale. 
  12463.  
  12464. To set TZ from within a program, use the _putenv function before calling 
  12465. _tzset. 
  12466.  
  12467. Note:  The time and date functions begin at 00:00 Universal Time, January 1, 
  12468. 1970. :enote. 
  12469.  
  12470. There is no return value. 
  12471.  
  12472. Example of _tzset 
  12473.  
  12474. Related Information 
  12475.  
  12476. o asctime  - Convert Time 
  12477. o _ftime - Store Current Time 
  12478. o gmtime  - Convert Time 
  12479. o localtime  - Convert Time 
  12480. o _putenv - Modify Environment Variables 
  12481. o time.h 
  12482.  
  12483.  
  12484. ΓòÉΓòÉΓòÉ 2.248. _ultoa - Convert Unsigned Long Integer to Str                ing ΓòÉΓòÉΓòÉ
  12485.  
  12486. #include <stdlib.h>
  12487.  
  12488. char *_ultoa(unsigned long value, char *string, int radix);
  12489.  
  12490. Language Level: Extension 
  12491.  
  12492. Description 
  12493.  
  12494. The _ultoa function converts the digits of the given unsigned long value to a 
  12495. character string that ends with a null character and stores the result in 
  12496. string. No overflow checking is performed. The radix argument specifies the 
  12497. base of value; it must be in the range of 2 through 36. 
  12498.  
  12499. Note:  The space allocated for string must be large enough to hold the returned 
  12500. string. The function can return up to 33 bytes, including the null character 
  12501. (\0). 
  12502.  
  12503. The _ultoa function returns a pointer to string. There is no error return 
  12504. value. 
  12505.  
  12506. Example of _ultoa 
  12507.  
  12508. Related Information 
  12509.  
  12510. o _itoa - Convert Integer to String 
  12511. o _ltoa - Convert Long Integer to String 
  12512. o stdlib.h 
  12513.  
  12514.  
  12515. ΓòÉΓòÉΓòÉ 2.249. _umask - Sets File Mask of Current Process ΓòÉΓòÉΓòÉ
  12516.  
  12517. #include <io.h>
  12518. #include <sys\stat.h>
  12519.  
  12520. int _umask(int pmode);
  12521.  
  12522. Language Level: Extension 
  12523.  
  12524. Description 
  12525.  
  12526. The _umask function sets the file permission mask of the executing process 
  12527. environment to the mode specified by pmode. The file permission mask modifies 
  12528. the permission setting of new files created by _creat, _open, or _sopen. 
  12529.  
  12530. If a bit in the mask is 1, the corresponding bit in the requested permission 
  12531. value of the file is set to 0 (disallowed).  If a bit in the mask is 0, the 
  12532. corresponding bit is left unchanged.  The permission setting for a new file is 
  12533. not set until the file is closed for the first time. 
  12534.  
  12535. The _umask function returns the previous value of pmode.  A return value of -1 
  12536. indicates that the value used for pmode was not valid; errno will be set to 
  12537. EINVAL. 
  12538.  
  12539. The variable pmode contains one or both of the constants S_WRITE and S_IREAD, 
  12540. defined in <sys\stat.h>. The possible values for pmode are: 
  12541.  
  12542. Value                   Meaning 
  12543. S_IREAD                 No effect 
  12544. S_IWRITE                Writing not permitted 
  12545. S_IREAD | S_IWRITE      Writing not permitted. 
  12546.  
  12547. If the write bit is set in the mask, any new files will be read-only. You 
  12548. cannot give write-only permission; setting the read bit has no effect. 
  12549.  
  12550. Example of _umask 
  12551.  
  12552. Related Information 
  12553.  
  12554. o _chmod - Change File Permission Setting 
  12555. o _creat - Create New File 
  12556. o _open - Open File 
  12557. o _sopen - Open Shared File 
  12558. o io.h 
  12559. o sys\stat.h 
  12560. o sys\types.h 
  12561.  
  12562.  
  12563. ΓòÉΓòÉΓòÉ 2.250. ungetc  - Push Character onto Input Stream ΓòÉΓòÉΓòÉ
  12564.  
  12565. #include <stdio.h>
  12566.  
  12567. int ungetc(int c, FILE *stream);
  12568.  
  12569. Language Level: ANSI, SAA 
  12570.  
  12571. Description 
  12572.  
  12573. The ungetc function pushes the unsigned character c back onto the given input 
  12574. stream.  However, only one sequential ungetc is guaranteed to be pushed back 
  12575. onto the input stream if you call ungetc consecutively. The stream must be open 
  12576. for reading.  A subsequent read operation on the stream starts with c.  You 
  12577. cannot push EOF back on the stream using ungetc. 
  12578.  
  12579. Characters placed on the stream by ungetc will be erased if a fseek, fsetpos, 
  12580. rewind, or fflush function is called before the character is read from the 
  12581. stream. 
  12582.  
  12583. The ungetc function returns the integer argument c converted to an unsigned 
  12584. char or EOF if c cannot be pushed back. 
  12585.  
  12586. Example of ungetc 
  12587.  
  12588. Related Information 
  12589.  
  12590. o getc - getchar  - Read a Character 
  12591. o fflush  - Write Buffer to File 
  12592. o fseek  - Reposition File Position 
  12593. o fsetpos  - Set File Position 
  12594. o putc - putchar  - Write a Character 
  12595. o rewind  - Adjust Current File Position 
  12596. o _ungetch - Push Character Back to Keyboard 
  12597. o stdio.h 
  12598.  
  12599.  
  12600. ΓòÉΓòÉΓòÉ 2.251. _ungetch - Push Character Back to Keyboard ΓòÉΓòÉΓòÉ
  12601.  
  12602. #include <conio.h>
  12603.  
  12604. int _ungetch(int c);
  12605.  
  12606. Language Level: Extension 
  12607.  
  12608. Description 
  12609.  
  12610. The _ungetch function pushes the character c back to the keyboard, causing c to 
  12611. be the next character read. The _ungetch function fails if called more than 
  12612. once before the next read operation. The character c cannot be the EOF 
  12613. character. 
  12614.  
  12615. If successful, the _ungetch function returns the character c. A return value of 
  12616. EOF indicates an error. 
  12617.  
  12618. Example of _ungetch 
  12619.  
  12620. Related Information 
  12621.  
  12622. o _cscanf - Read Data from Keyboard 
  12623. o _getch - _getche - Read Character from Keyboard 
  12624. o ungetc  - Push Character onto Input Stream 
  12625. o conio.h 
  12626.  
  12627.  
  12628. ΓòÉΓòÉΓòÉ 2.252. _unlink - Delete File ΓòÉΓòÉΓòÉ
  12629.  
  12630. #include <stdio.h>
  12631.  
  12632. int _unlink(char *pathname);
  12633.  
  12634. Language Level: Extension 
  12635.  
  12636. Description 
  12637.  
  12638. The _unlink function deletes the file specified by pathname. 
  12639.  
  12640. An alternative to this function is the SAA remove function. 
  12641.  
  12642. The _unlink function returns the value 0 if the file is successfully deleted. A 
  12643. return value of -1 indicates an error, and errno is set to one of the following 
  12644. values: 
  12645.  
  12646. Value          Meaning 
  12647. EACCESS        The path name specifies a read-only file or a directory. 
  12648. EISOPEN        The file is open. 
  12649. ENOENT         An incorrect path name was specified, or the file or path name 
  12650.                was not found. 
  12651.  
  12652. Example of _unlink 
  12653.  
  12654. Related Information 
  12655.  
  12656. o remove  - Delete File 
  12657. o stdio.h 
  12658.  
  12659.  
  12660. ΓòÉΓòÉΓòÉ 2.253. _utime - Set Modification Time ΓòÉΓòÉΓòÉ
  12661.  
  12662. #include <sys\utime.h>
  12663. #include <sys\types.h>
  12664.  
  12665. int _utime(char *pathname, struct utimbuf *times);
  12666.  
  12667. Language Level: Extension 
  12668.  
  12669. Description 
  12670.  
  12671. The _utime function sets the modification time for the file specified by 
  12672. pathname.  The process must have write access to the file;  otherwise, the time 
  12673. cannot be changed. 
  12674.  
  12675. Although the utimbuf structure contains a field for access time, only the 
  12676. modification time is set in the DOS and OS/2 operating systems. If times is a 
  12677. NULL pointer, the modification time is set to the current time.  Otherwise, 
  12678. times must point to a structure of type utimbuf, defined in <sys\utime.h>.  The 
  12679. modification time is set from the modtime field in this structure. 
  12680.  
  12681. Note:  The _utime function accepts only even numbers of seconds. If you enter 
  12682.        an odd number of seconds, the function rounds it down. 
  12683.  
  12684. The _utime function returns the value 0 if the file modification time was 
  12685. changed.  A return value of -1 indicates an error, and errno is set to one of 
  12686. the following values: 
  12687.  
  12688. Value          Meaning 
  12689. EACCESS        The path name specifies a directory or read-only file. 
  12690. EMFILE         There are too many open files.  The file must be opened to 
  12691.                change its modification time. 
  12692. ENOENT         The file path name was not found, or the file name was 
  12693.                incorrectly specified. 
  12694.  
  12695. Example of _utime 
  12696.  
  12697. Related Information 
  12698.  
  12699. o asctime  - Convert Time 
  12700. o ctime  - Convert Time 
  12701. o _fstat - Information about Open File 
  12702. o gmtime  - Convert Time 
  12703. o localtime  - Convert Time 
  12704. o _stat - Get Information about File or Directory 
  12705. o time  - Determine Current Time 
  12706. o _tzset - Assign Values to Locale Information 
  12707. o sys\utime.h 
  12708. o sys\types.h 
  12709.  
  12710.  
  12711. ΓòÉΓòÉΓòÉ 2.254. va_arg - va_end - va_start ΓòÉΓòÉΓòÉ
  12712.  
  12713.  - Access Function Arguments 
  12714.  
  12715. #include <stdarg.h>
  12716.  
  12717. var_type va_arg(va_list arg_ptr, var_type);
  12718.  
  12719. void va_end(va_list arg_ptr);
  12720.  
  12721. void va_start(va_list arg_ptr, variable_name);
  12722.  
  12723. Language Level: ANSI, SAA 
  12724.  
  12725. Description 
  12726.  
  12727. The va_arg, va_end and va_start macros access the arguments to a function when 
  12728. it takes a fixed number of required arguments and a variable number of optional 
  12729. arguments.  You declare required arguments as ordinary parameters to the 
  12730. function and access the arguments through the parameter names. 
  12731.  
  12732. The va_start macro initializes the arg_ptr pointer for subsequent calls to 
  12733. va_arg and va_end. 
  12734.  
  12735. The argument variable_name is the identifier of the rightmost named parameter 
  12736. in the parameter list (preceding , ...).  Use the va_start macro before the 
  12737. va_arg macro. Corresponding va_start and va_end macros must be in the same 
  12738. function. 
  12739.  
  12740. The va_arg macro retrieves a value of the given var_type from the location 
  12741. given by arg_ptr and increases arg_ptr to point to the next argument in the 
  12742. list.  The va_arg macro can retrieve arguments from the list any number of 
  12743. times within the function. The var_type argument must be one of int, long, 
  12744. double, struct, union, or pointer, or a typedef of one of these types. 
  12745.  
  12746. The va_end macro is needed to indicate the end of parameter scanning. 
  12747.  
  12748. The va_arg macro returns the current argument. The va_end and va_start macros 
  12749. do not return a value. 
  12750.  
  12751. Example of va_arg - va_end - va_start 
  12752.  
  12753. Related Information 
  12754.  
  12755. o vfprintf  - Print Argument Data 
  12756. o vprintf  - Print Argument Data 
  12757. o vsprintf  - Print Argument Data 
  12758. o stdarg.h 
  12759.  
  12760.  
  12761. ΓòÉΓòÉΓòÉ 2.255. vfprintf  - Print Argument Data ΓòÉΓòÉΓòÉ
  12762.  
  12763. #include <stdarg.h>
  12764.  
  12765. #include <stdio.h>
  12766.  
  12767. int vfprintf(FILE *stream, const char *format, va_list arg_ptr);
  12768.  
  12769. Language Level: ANSI, SAA, Extension 
  12770.  
  12771. Description 
  12772.  
  12773. The vfprintf function is similar to fprintf, except that arg_ptr points to a 
  12774. list of arguments whose number can vary from call to call in the program. These 
  12775. arguments should be initialized by va_start for each call. In contrast, fprintf 
  12776. can have a list of arguments, but the number of arguments in that list is fixed 
  12777. when you compile the program. For a specification of the format string, see 
  12778. printf. 
  12779.  
  12780. In extended mode, vfprintf also converts floating-point values of NaN and 
  12781. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  12782. and sign of the string is determined by the format specifiers.  See Infinity 
  12783. and NaN Support for more information on infinity and NaN values. 
  12784.  
  12785. If there is no error, vfprintf returns the number of characters written to 
  12786. stream. If there is an error, the function returns a negative value. 
  12787.  
  12788. Example of vfprintf 
  12789.  
  12790. Related Information 
  12791.  
  12792. o fprintf  - Formatted Write 
  12793. o printf  - Formatted Print 
  12794. o sprintf  - Formatted Print to Buffer 
  12795. o va_arg - va_end - va_start  - Access Function Arguments 
  12796. o vprintf  - Print Argument Data 
  12797. o vsprintf  - Print Argument Data 
  12798. o Infinity and NaN Support 
  12799. o stdarg.h 
  12800. o stdio.h 
  12801.  
  12802.  
  12803. ΓòÉΓòÉΓòÉ 2.256. vprintf  - Print Argument Data ΓòÉΓòÉΓòÉ
  12804.  
  12805. #include <stdarg.h>
  12806.  
  12807. #include <stdio.h>
  12808.  
  12809. int vprintf(const char *format, va_list arg_ptr);
  12810.  
  12811. Language Level: ANSI, SAA, Extension 
  12812.  
  12813. Description 
  12814.  
  12815. The vprintf function is similar to printf, except that arg_ptr points to a list 
  12816. of arguments whose number can vary from call to call in the program. These 
  12817. arguments should be initialized by va_start for each call. In contrast, printf 
  12818. can have a list of arguments, but the number of arguments in that list is fixed 
  12819. when you compile the program. For a specification of the format string, see 
  12820. printf. 
  12821.  
  12822. In extended mode, vprintf also converts floating-point values of NaN and 
  12823. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  12824. and sign of the string is determined by the format specifiers.  See Infinity 
  12825. and NaN Support for more information on infinity and NaN values. 
  12826.  
  12827. If there is no error, vprintf returns the number of characters written to 
  12828. stdout If there is an error, this function returns a negative value. 
  12829.  
  12830. Example of vprintf 
  12831.  
  12832. Related Information 
  12833.  
  12834. o fprintf  - Formatted Write 
  12835. o printf  - Formatted Print 
  12836. o sprintf  - Formatted Print to Buffer 
  12837. o va_arg - va_end - va_start  - Access Function Arguments 
  12838. o vfprintf  - Print Argument Data 
  12839. o vsprintf  - Print Argument Data 
  12840. o Infinity and NaN Support 
  12841. o stdarg.h 
  12842. o stdio.h 
  12843.  
  12844.  
  12845. ΓòÉΓòÉΓòÉ 2.257. vsprintf  - Print Argument Data ΓòÉΓòÉΓòÉ
  12846.  
  12847. #include <stdarg.h>
  12848.  
  12849. #include <stdio.h>
  12850.  
  12851. int vsprintf(char *target-string, const char *format, va_list arg_ptr);
  12852.  
  12853. Language Level: ANSI, SAA, Extension 
  12854.  
  12855. Description 
  12856.  
  12857. The vsprintf function is similar to sprintf except that arg_ptr points to a 
  12858. list of arguments whose number can vary from call to call in the program.  In 
  12859. contrast, sprintf can have a list of arguments, but the number of arguments in 
  12860. that list is fixed when you compile the program. For a specification of the 
  12861. format string, see printf. 
  12862.  
  12863. In extended mode, vsprintf also converts floating-point values of NaN and 
  12864. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  12865. and sign of the string is determined by the format specifiers.  See Infinity 
  12866. and NaN Support for more information on infinity and NaN values. 
  12867.  
  12868. If there is no error, vsprintf returns the number of characters written 
  12869. target-string. If there is an error, this function returns a negative value. 
  12870.  
  12871. Example of vsprintf 
  12872.  
  12873. Related Information 
  12874.  
  12875. o fprintf  - Formatted Write 
  12876. o printf  - Formatted Print 
  12877. o sprintf  - Formatted Print to Buffer 
  12878. o va_arg - va_end - va_start  - Access Function Arguments 
  12879. o vfprintf  - Print Argument Data 
  12880. o vprintf  - Print Argument Data 
  12881. o Infinity and NaN Support 
  12882. o stdarg.h 
  12883. o stdio.h 
  12884.  
  12885.  
  12886. ΓòÉΓòÉΓòÉ 2.258. _wait - Wait for Child Process ΓòÉΓòÉΓòÉ
  12887.  
  12888. #include <process.h>
  12889.  
  12890. int _wait (int *stat_loc);
  12891.  
  12892. Language Level: Extension 
  12893.  
  12894. Description 
  12895.  
  12896. The _wait function delays a parent process until one of the immediate child 
  12897. processes stops.  If all the child processes stop before _wait is called, 
  12898. control returns immediately to the parent function. 
  12899.  
  12900. If stat_loc is NULL, the _wait function does not use it.  If it is not NULL, 
  12901. _wait places information about the return status and the return code ot the 
  12902. child process that ended in the location to that stat_loc points to. 
  12903.  
  12904. If the child process ended normally, using a call to the OS/2 DosExit function, 
  12905. the lowest-order byte of stat_loc is 0, and the next higher-order byte contains 
  12906. the lowest-order byte of the argument passed to DosExit by the child process. 
  12907. The value of this byte depends on how the child process caused the system to 
  12908. call DosExit. 
  12909.  
  12910. If the child process called exit, _exit, or return from main, the byte contains 
  12911. the lowest-order byte of the argument the child process passed to exit, _exit, 
  12912. or return.  The value of the byte is undefined if the child process caused a 
  12913. DosExit call simply by reaching the end of main. 
  12914.  
  12915. If the child process ended abnormally (without a call to DosExit), the 
  12916. lowest-order byte of stat_loc contains the return status code from the OS/2 
  12917. DosWaitChild function, and the next higher-order byte is 0. See the OS/2 online 
  12918. reference for details about the DosWaitChild return status codes. 
  12919.  
  12920. If _wait returns after a normal end of a child process, it returns the process 
  12921. identifier of the child process to the parent process. A return value of -1 
  12922. indicates an error, and errno is set to one of the following values: 
  12923.  
  12924. Value          Meaning 
  12925. ECHILD         There were no child processes or they all ended before the call 
  12926.                to _wait indicating that no child processes exist for the 
  12927.                particular process. 
  12928. EINTR          Unexpected end of a child process. 
  12929.  
  12930. Example of _wait 
  12931.  
  12932. Related Information 
  12933.  
  12934. o _cwait - Wait for Child Process 
  12935. o _execl - _execvp - Load and Run Child Process 
  12936. o exit  - End Program 
  12937. o _exit - End Process 
  12938. o _spawnl - _spawnvpe - Start and Run Child Processes 
  12939. o process.h 
  12940.  
  12941.  
  12942. ΓòÉΓòÉΓòÉ 2.259. wcscat  - Append wchar_t Strings ΓòÉΓòÉΓòÉ
  12943.  
  12944. #include <wcstr.h> /* SAA extension to ANSI */
  12945.  
  12946. wchar_t *wcscat(wchar_t *string1, const wchar_t *string2);
  12947. Language Level: SAA 
  12948.  
  12949. Description 
  12950.  
  12951. The wcscat function appends a copy of the string pointed to by string2 to the 
  12952. end of the string pointed to by string1 and returns the value of string1. 
  12953.  
  12954. The wcscat function operates on null-terminated wchar_t strings.  The string 
  12955. arguments to this function are expected to contain a wchar_t null character 
  12956. marking the end of the string.  Boundary checking is not performed. 
  12957.  
  12958. Example of wcscat 
  12959.  
  12960. Related Information 
  12961.  
  12962. o strcat  - Concatenate Strings 
  12963. o wcschr  - Search wchar_t String for Given wchar_t 
  12964. o wcscmp  - Compare wchar_t Strings 
  12965. o wcscpy  - Copy wchar_t Strings 
  12966. o wcscspn  - Find Offset of First wchar_t Match 
  12967. o wcslen  - Calculates Length of wchar_t String 
  12968. o wcsncat  - Concatenates wchar_t Strings 
  12969. o wcstr.h 
  12970.  
  12971.  
  12972. ΓòÉΓòÉΓòÉ 2.260. wcschr  - Search wchar_t String for Given wchar_t ΓòÉΓòÉΓòÉ
  12973.  
  12974. #include <wcstr.h> /* SAA extension to ANSI */
  12975.  
  12976. wchar_t  *wcschr(const wchar_t *string1, wchar_t character);
  12977. Language Level: SAA 
  12978.  
  12979. Description 
  12980.  
  12981. The wcschr function returns a pointer to the first occurrence of character in 
  12982. string.  The character value may be a wchar_t null character (\0);  the wchar_t 
  12983. null character at the end of string is included in the search.  If the 
  12984. character is not found, a NULL pointer is returned. 
  12985.  
  12986. The wcschr function operates on null-terminated wchar_t strings.  The string 
  12987. argument to this function is expected to contain a wchar_t null character 
  12988. marking the end of the string. 
  12989.  
  12990. Example of wcschr 
  12991.  
  12992. Related Information 
  12993.  
  12994. o strchr  - Search for Character 
  12995. o wcscat  - Append wchar_t Strings 
  12996. o wcscmp  - Compare wchar_t Strings 
  12997. o wcscpy  - Copy wchar_t Strings 
  12998. o wcscspn  - Find Offset of First wchar_t Match 
  12999. o wcslen  - Calculates Length of wchar_t String 
  13000. o wcsncmp  - Compares wchar_t Strings 
  13001. o wcstr.h 
  13002.  
  13003.  
  13004. ΓòÉΓòÉΓòÉ 2.261. wcscmp  - Compare wchar_t Strings ΓòÉΓòÉΓòÉ
  13005.  
  13006. #include <wcstr.h> /* SAA extension to ANSI */
  13007.  
  13008. int wcscmp(const wchar_t *string1, const wchar_t *string2);
  13009. Language Level: SAA 
  13010.  
  13011. Description 
  13012.  
  13013. The wcscmp function compares two wchar_t strings.  It returns an integer 
  13014. greater than zero if string1 is greater than string2.  It returns zero if the 
  13015. two strings are equivalent.  It returns a number less than zero if string1 is 
  13016. less than string2. 
  13017.  
  13018. The wcscmp function operates on null-terminated wchar_t strings.  The string 
  13019. arguments to this function are expected to contain a wchar_t null character 
  13020. marking the end of the string.  Boundary checking is not performed when a 
  13021. string is added to or copied. 
  13022.  
  13023. Example of wcscmp 
  13024.  
  13025. Related Information 
  13026.  
  13027. o strcmp  - Compare Strings 
  13028. o strcmpi - Compare Strings 
  13029. o stricmp - Compare Strings 
  13030. o strnicmp - Compare Strings 
  13031. o wcscat  - Append wchar_t Strings 
  13032. o wcschr  - Search wchar_t String for Given wchar_t 
  13033. o wcscpy  - Copy wchar_t Strings 
  13034. o wcscspn  - Find Offset of First wchar_t Match 
  13035. o wcslen  - Calculates Length of wchar_t String 
  13036. o wcsncmp  - Compares wchar_t Strings 
  13037. o wcstr.h 
  13038.  
  13039.  
  13040. ΓòÉΓòÉΓòÉ 2.262. wcscpy  - Copy wchar_t Strings ΓòÉΓòÉΓòÉ
  13041.  
  13042. #include <wcstr.h> /* SAA extension to ANSI */
  13043.  
  13044. wchar_t *wcscpy(wchar_t *string1, const wchar_t *string2);
  13045. Language Level: SAA 
  13046.  
  13047. Description 
  13048.  
  13049. The wcscpy function copies the contents of string2 (including the ending 
  13050. wchar_t null character) into string1 and returns the value of string1. 
  13051.  
  13052. The wcscpy function operates on null-terminated wchar_t strings.  The string 
  13053. arguments to this function are expected to contain a wchar_t null character 
  13054. marking the end of the string.  Boundary checking is not performed. 
  13055.  
  13056. Example of wcscpy 
  13057.  
  13058. Related Information 
  13059.  
  13060. o strcpy  - Copy Strings 
  13061. o wcscat  - Append wchar_t Strings 
  13062. o wcschr  - Search wchar_t String for Given wchar_t 
  13063. o wcscmp  - Compare wchar_t Strings 
  13064. o wcscspn  - Find Offset of First wchar_t Match 
  13065. o wcslen  - Calculates Length of wchar_t String 
  13066. o wcsncpy  - Copies wchar_t Strings 
  13067. o wcstr.h 
  13068.  
  13069.  
  13070. ΓòÉΓòÉΓòÉ 2.263. wcscspn  - Find Offset of First wchar_t Match ΓòÉΓòÉΓòÉ
  13071.  
  13072. #include <wcstr.h> /* SAA extension to ANSI */
  13073.  
  13074. size_t wcscspn(const wchar_t *string1, const wchar_t *string2);
  13075. Language Level: SAA 
  13076.  
  13077. Description 
  13078.  
  13079. The wcscspn function computes the number of wchar_t characters in the initial 
  13080. segment of the string pointed to by string1 that do not appear in the string 
  13081. pointed to by string2.  The wcscspn function returns the number of wchar_t in 
  13082. the segment. 
  13083.  
  13084. The wcscspn function operates on null-terminated wchar_t strings.  The string 
  13085. arguments to these functions are expected to contain a wchar_t null character 
  13086. marking the end of the string. 
  13087.  
  13088. Example of wcscspn 
  13089.  
  13090. Related Information 
  13091.  
  13092. o strcspn  - Compare Strings 
  13093. o wcscat  - Append wchar_t Strings 
  13094. o wcschr  - Search wchar_t String for Given wchar_t 
  13095. o wcscmp  - Compare wchar_t Strings 
  13096. o wcscpy  - Copy wchar_t Strings 
  13097. o wcslen  - Calculates Length of wchar_t String 
  13098. o wcstr.h 
  13099.  
  13100.  
  13101. ΓòÉΓòÉΓòÉ 2.264. wcslen  - Calculates Length of wchar_t String ΓòÉΓòÉΓòÉ
  13102.  
  13103. #include <wcstr.h> /* SAA extension to ANSI */
  13104.  
  13105. size_t wcslen(const wchar_t *string);
  13106. Language Level: SAA 
  13107.  
  13108. Description 
  13109.  
  13110. The wcslen function computes the number of wchar_t characters in the string 
  13111. pointed to by string. 
  13112.  
  13113. The wcslen function returns the number of wchar_t characters that precede the 
  13114. terminating wchar_t null character. 
  13115.  
  13116. Example of wcslen 
  13117.  
  13118. Related Information 
  13119.  
  13120. o mblen  - Multibyte String Length 
  13121. o strlen  - String Length 
  13122. o wcsncat  - Concatenates wchar_t Strings 
  13123. o wcsncmp  - Compares wchar_t Strings 
  13124. o wcsncpy  - Copies wchar_t Strings 
  13125. o wcstr.h 
  13126.  
  13127.  
  13128. ΓòÉΓòÉΓòÉ 2.265. wcsncat  - Concatenates wchar_t Strings ΓòÉΓòÉΓòÉ
  13129.  
  13130. #include <wcstr.h> /* SAA extension to ANSI */
  13131.  
  13132. wchar_t *wcsncat(wchar_t *string1, const wchar_t *string2, size_t count);
  13133. Language Level: SAA 
  13134.  
  13135. Description 
  13136.  
  13137. The wcsncat function operates on null-terminated wchar_t strings. 
  13138.  
  13139. The wcsncat function appends up to count wide characters from string2 to the 
  13140. end of string1, appends a wchar_t null character to the result, and returns 
  13141. string1. 
  13142.  
  13143. Example of wcsncat 
  13144.  
  13145. Related Information 
  13146.  
  13147. o strncat  - Concatenate Strings 
  13148. o wcscat  - Append wchar_t Strings 
  13149. o wcsncmp  - Compares wchar_t Strings 
  13150. o wcsncpy  - Copies wchar_t Strings 
  13151. o wcstr.h 
  13152.  
  13153.  
  13154. ΓòÉΓòÉΓòÉ 2.266. wcsncmp  - Compares wchar_t Strings ΓòÉΓòÉΓòÉ
  13155.  
  13156. #include <wcstr.h> /* SAA extension to ANSI */
  13157.  
  13158. int wcsncmp(const wchar_t *string1, const wchar_t *string2, size_t count);
  13159. Language Level: SAA 
  13160.  
  13161. Description 
  13162.  
  13163. The wcsncmp function operates on null-terminated wchar_t strings. 
  13164.  
  13165. The wcsncmp function compares up to count wide characters in string1 to string2 
  13166. and returns an integer greater than zero if string1 is greater than string2, 
  13167. zero if the strings are equivalent, and an integer less than zero if string1 is 
  13168. less than string2. 
  13169.  
  13170. Example of wcsncmp 
  13171.  
  13172. Related Information 
  13173.  
  13174. o strncmp  - Compare Strings 
  13175. o strnicmp - Compare Strings 
  13176. o wcscmp  - Compare wchar_t Strings 
  13177. o wcsncat  - Concatenates wchar_t Strings 
  13178. o wcsncpy  - Copies wchar_t Strings 
  13179. o wcstr.h 
  13180.  
  13181.  
  13182. ΓòÉΓòÉΓòÉ 2.267. wcsncpy  - Copies wchar_t Strings ΓòÉΓòÉΓòÉ
  13183.  
  13184. #include <wcstr.h> /* SAA extension to ANSI */
  13185.  
  13186. wchar_t *wcsncpy(wchar_t *string1, const wchar_t *string2, size_t count);
  13187. Language Level: SAA 
  13188.  
  13189. Description 
  13190.  
  13191. The wcsncpy function operates on null-terminated wchar_t strings. 
  13192.  
  13193. The wcsncpy function copies up to count wide characters from string2 to string1 
  13194. and returns string1.  If string2 is shorter than count characters, string1 is 
  13195. padded out to count characters with wchar_t null characters. 
  13196.  
  13197. Example of wcsncpy 
  13198.  
  13199. Related Information 
  13200.  
  13201. o strncpy  - Copy Strings 
  13202. o wcscpy  - Copy wchar_t Strings 
  13203. o wcsncat  - Concatenates wchar_t Strings 
  13204. o wcsncmp  - Compares wchar_t Strings 
  13205. o wcstr.h 
  13206.  
  13207.  
  13208. ΓòÉΓòÉΓòÉ 2.268. wcspbrk  - Locates wchar_t Characters in String ΓòÉΓòÉΓòÉ
  13209.  
  13210. #include <wcstr.h> /* SAA extension to ANSI */
  13211.  
  13212. wchar_t *wcspbrk(const wchar_t *string1, const wchar_t *string2);
  13213. Language Level: SAA 
  13214.  
  13215. Description 
  13216.  
  13217. The wcspbrk function locates the first occurrence in the string pointed to by 
  13218. string1 of any character from the string pointed to by string2. 
  13219.  
  13220. The wcspbrk function returns a pointer to the character, or NULL if no wchar_t 
  13221. from string2 occurs in string1. 
  13222.  
  13223. Example of wcspbrk 
  13224.  
  13225. Related Information 
  13226.  
  13227. o strpbrk  - Find Characters in String 
  13228. o wcschr  - Search wchar_t String for Given wchar_t 
  13229. o wcscmp  - Compare wchar_t Strings 
  13230. o wcscspn  - Find Offset of First wchar_t Match 
  13231. o wcsncmp  - Compares wchar_t Strings 
  13232. o wcsrchr  - Locates wchar_t Character in String 
  13233. o wcswcs  - Locates wchar_t Substring in wchar_t String 
  13234. o wcstr.h 
  13235.  
  13236.  
  13237. ΓòÉΓòÉΓòÉ 2.269. wcsrchr  - Locates wchar_t Character in String ΓòÉΓòÉΓòÉ
  13238.  
  13239. #include <wcstr.h> /* SAA extension to ANSI */
  13240.  
  13241. wchar_t *wcsrchr(const wchar_t *string, wchar_t character);
  13242. Language Level: SAA 
  13243.  
  13244. Description 
  13245.  
  13246. The wcsrchr function locates the last occurrence of character in the string 
  13247. pointed to by string.  The terminating wchar_t null character is considered to 
  13248. be part of the string. 
  13249.  
  13250. The wcsrchr function returns a pointer to the character, or a NULL pointer if 
  13251. character does not occur in the string. 
  13252.  
  13253. Example of wcsrchr 
  13254.  
  13255. Related Information 
  13256.  
  13257. o strrchr  - Find Last Occurrence of Character in String 
  13258. o wcschr  - Search wchar_t String for Given wchar_t 
  13259. o wcscmp  - Compare wchar_t Strings 
  13260. o wcscspn  - Find Offset of First wchar_t Match 
  13261. o wcsncmp  - Compares wchar_t Strings 
  13262. o wcswcs  - Locates wchar_t Substring in wchar_t String 
  13263. o wcspbrk  - Locates wchar_t Characters in String 
  13264. o wcstr.h 
  13265.  
  13266.  
  13267. ΓòÉΓòÉΓòÉ 2.270. wcsspn  - Searches wchar_t Characters in String ΓòÉΓòÉΓòÉ
  13268.  
  13269. #include <wcstr.h> /* SAA extension to ANSI */
  13270.  
  13271. size_t wcsspn(const wchar_t *string1, const wchar_t *string2);
  13272. Language Level: SAA 
  13273.  
  13274. Description 
  13275.  
  13276. The wcsspn function computes the number of wchar_t characters in the initial 
  13277. segment of the string pointed to by string1, which consists entirely of wchar_t 
  13278. characters from the string pointed to by string2. 
  13279.  
  13280. The wcsspn function returns the number of wchar_t characters in the segment. 
  13281.  
  13282. Example of wcsspn 
  13283.  
  13284. Related Information 
  13285.  
  13286. o strspn  - Search Strings 
  13287. o wcscat  - Append wchar_t Strings 
  13288. o wcschr  - Search wchar_t String for Given wchar_t 
  13289. o wcscmp  - Compare wchar_t Strings 
  13290. o wcscspn  - Find Offset of First wchar_t Match 
  13291. o wcsncmp  - Compares wchar_t Strings 
  13292. o wcstr.h 
  13293.  
  13294.  
  13295. ΓòÉΓòÉΓòÉ 2.271. wcstombs  - Converts wchar_t String to Multibyte Character String ΓòÉΓòÉΓòÉ
  13296.  
  13297. #include <stdlib.h>
  13298.  
  13299. size_t wcstombs(char *dest, const wchar_t *string, size_t count);
  13300.  
  13301. Language Level: ANSI, SAA 
  13302.  
  13303. Description 
  13304.  
  13305. The wcstombs function converts the wchar_t string pointed to by string into the 
  13306. multibyte array pointed to by dest.  The converted string begins in the initial 
  13307. shift state.  The conversion stops after count bytes in dest are filled up or a 
  13308. wchar_t null character is encountered. 
  13309.  
  13310. The wcstombs function returns the length in bytes of the multibyte character 
  13311. string, not including a terminating null character.  The value (size_t)-1 is 
  13312. returned if an invalid multibyte character is encountered. 
  13313.  
  13314. Example of wcstombs 
  13315.  
  13316. Related Information 
  13317.  
  13318. o mbstowcs  - Convert Multibyte Characters to wchar_t Characters 
  13319. o wcslen  - Calculates Length of wchar_t String 
  13320. o wctomb  - Converts wchar_t Character to Multibyte Character 
  13321. o stdlib.h 
  13322.  
  13323.  
  13324. ΓòÉΓòÉΓòÉ 2.272. wcswcs  - Locates wchar_t Substring in wchar_t String ΓòÉΓòÉΓòÉ
  13325.  
  13326. #include <wcstr.h> /* SAA extension to ANSI */
  13327.  
  13328. wchar_t *wcswcs(const wchar_t *string1, const wchar_t *string2);
  13329.  
  13330. Language Level: SAA 
  13331.  
  13332. Description 
  13333.  
  13334. The wcswcs function locates the first occurrence in the string pointed to by 
  13335. string1 of the sequence of wchar_t characters (excluding the terminating 
  13336. wchar_t null character) in the string pointed to by string2. 
  13337.  
  13338. The wcswcs function returns a pointer to the located string or NULL if the 
  13339. string is not found.  If string2 points to a string with zero length, the 
  13340. function returns string1. 
  13341.  
  13342. Example of wcswcs 
  13343.  
  13344. Related Information 
  13345.  
  13346. o wcschr  - Search wchar_t String for Given wchar_t 
  13347. o wcscmp  - Compare wchar_t Strings 
  13348. o wcscspn  - Find Offset of First wchar_t Match 
  13349. o wcspbrk  - Locates wchar_t Characters in String 
  13350. o wcsrchr  - Locates wchar_t Character in String 
  13351. o wcstr.h 
  13352.  
  13353.  
  13354. ΓòÉΓòÉΓòÉ 2.273. wctomb  - Converts wchar_t Character to Multibyte Character ΓòÉΓòÉΓòÉ
  13355.  
  13356. #include <stdlib.h>
  13357.  
  13358. int wctomb(char *string, wchar_t character);
  13359.  
  13360. Language Level: ANSI, SAA 
  13361.  
  13362. Description 
  13363.  
  13364. The wctomb function converts the wchar_t value of character into a multibyte 
  13365. array pointed to by string.  If the value of character is zero (0), the 
  13366. function is left in the initial shift state.  At most, wctomb stores MB_CUR_MAX 
  13367. characters in string. 
  13368.  
  13369. The wctomb function returns the length in bytes of the multibyte character. 
  13370. The value -1 is returned if character is not the a valid multibyte character. 
  13371. If string is a NULL pointer, the wctomb function returns nonzero if 
  13372. shift-dependent encoding is used;  zero otherwise. 
  13373.  
  13374. Example of wctomb 
  13375.  
  13376. Related Information 
  13377.  
  13378. o mbtowc  - Convert Multibyte Character to wchar_t 
  13379. o wcslen  - Calculates Length of wchar_t String 
  13380. o wcstombs  - Converts wchar_t String to Multibyte Character String 
  13381. o stdlib.h 
  13382.  
  13383.  
  13384. ΓòÉΓòÉΓòÉ 2.274. _write - Writes from Buffer to File ΓòÉΓòÉΓòÉ
  13385.  
  13386. #include <io.h>
  13387.  
  13388. int _write(int handle, const void *buffer, unsigned int count);
  13389.  
  13390. Language Level: Extension 
  13391.  
  13392. Description 
  13393.  
  13394. The _write function writes count bytes from buffer into the file associated 
  13395. with handle. The write operation begins at the current position of the file 
  13396. pointer associated with the given file. If the file is open for appending, the 
  13397. operation begins at the end of the file. After the write operation, the file 
  13398. pointer is increased by the number of bytes actually written. 
  13399.  
  13400. If the given file was opened in text mode, each line feed character is replaced 
  13401. with a carriage return/line feed pair in the output.  The replacement does not 
  13402. affect the return value. 
  13403.  
  13404. The _write function returns the number of bytes moved from the buffer to the 
  13405. file. The return value may be positive but less than count. A return value of 
  13406. -1 indicates an error, and errno is set to one of the following values: 
  13407.  
  13408. Value          Meaning 
  13409. EBADF          The file handle is not valid, or the file is not open for 
  13410.                writing. 
  13411. ENOSPC         No space is left on the device. 
  13412. EOS2ERR        The call to the operating system was not successful. 
  13413.  
  13414. Example of _write 
  13415.  
  13416. Related Information 
  13417.  
  13418. o _creat - Create New File 
  13419. o _lseek - Move File Pointer 
  13420. o _open - Open File 
  13421. o _read - Read Into Buffer 
  13422. o _sopen - Open Shared File 
  13423. o _tell - Get Pointer Position 
  13424. o io.h 
  13425.  
  13426.  
  13427. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13428.  
  13429. /************************************************************************
  13430. *
  13431.  
  13432. In the following example, fscanf converts NaN and infinity strings to their 
  13433. numeric values. 
  13434.  
  13435.                                                                         *
  13436. ************************************************************************/
  13437.  
  13438.  
  13439. Example of fscanf Using NaN and Infinity Values
  13440.  
  13441. #include <stdio.h>
  13442. int main(void)
  13443. {
  13444.    int n, count;
  13445.    double d1, d2, d3;
  13446.    FILE *stream;
  13447.    stream = tmpfile();
  13448.    fputs(" INFINITY NAn INF", stream);
  13449.    rewind(stream);
  13450.    n = fscanf(stream, "%lF%lf%lF%n", &d1, &d2, &d3, &count);
  13451.    if (n != EOF)
  13452.    {
  13453.       printf("Number of fields converted = %d\n", n);
  13454.       printf("Number of characters read = %d\n", count);
  13455.       printf("Output = %f %F %F\n", d1, d2, d3);
  13456.    }
  13457.    return 0;
  13458.    /* The expected output is:
  13459.       Number of fields converted = 3
  13460.       Number of characters read = 17
  13461.       Output = infinity NAN INFINITY  */
  13462. }
  13463.  
  13464.  
  13465. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13466.  
  13467. /************************************************************************
  13468. *
  13469.  
  13470. In the following example, printf converts the NaN and infinity values and 
  13471. prints out the corresponding string. 
  13472.  
  13473.                                                                         *
  13474. ************************************************************************/
  13475.  
  13476.  
  13477. Example of printf Using NaN and Infinity Values
  13478.  
  13479. #include <stdio.h>
  13480. #include <float.h>
  13481. int main(void)
  13482. {
  13483.    double infval = -(_INF);
  13484.    float nanval = _NANF;
  13485.    printf("-_INF is the same as %-15.30f\n", infval);
  13486.    printf("_NANF is the same as %-15.30F\n", nanval);
  13487.    return 0;
  13488.    /* The expected output is:
  13489.       -_INF is the same as -infinity
  13490.       _NANF is the same as NAN        */
  13491. }
  13492.  
  13493.  
  13494. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13495.  
  13496. /************************************************************************
  13497. *
  13498.  
  13499. The following example uses atof to convert the strings "naN" and "infinity" to 
  13500. the corresponding macro value. 
  13501.  
  13502.                                                                         *
  13503. ************************************************************************/
  13504.  
  13505.  
  13506. Example of atof Using NaN and Infinity Values
  13507.  
  13508. #include <stdlib.h>
  13509. #include <stdio.h>
  13510. int main(void)
  13511. {
  13512.    char *nanstr;
  13513.    char *infstr;
  13514.    nanstr = "naN";
  13515.    printf( "Result of atof = %.10e\n", atof(nanstr) );
  13516.    infstr = "inf";
  13517.    printf( "Result of atof = %.10E\n", atof(infstr) );
  13518.    return 0;
  13519.    /* The expected output is:
  13520.       Result of atof = nan
  13521.       Result of atof = INFINITY  */
  13522. }
  13523.  
  13524.  
  13525. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13526.  
  13527. /************************************************************************
  13528. *
  13529.  
  13530. The following example tests for successful opening of the file myfile.  If an 
  13531. error occurs, an error message is printed and the program ends with a call to 
  13532. the abort function. 
  13533.  
  13534.                                                                         *
  13535. ************************************************************************/
  13536.  
  13537. #include <stdio.h>
  13538. #include <stdlib.h>
  13539. int main(void)
  13540. {
  13541.    FILE *stream;
  13542.    if ((stream = fopen("myfile.dat", "r")) == NULL)
  13543.    {
  13544.       perror("Could not open data file");
  13545.       abort();
  13546.    }
  13547. }
  13548.  
  13549.  
  13550. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13551.  
  13552. #include <stdlib.h>
  13553. int main(void)
  13554. {
  13555.     int x = -4, y;
  13556.     y = abs(x);   /* y = 4 */
  13557. }
  13558.  
  13559.  
  13560. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13561.  
  13562. /************************************************************************
  13563. *
  13564.  
  13565. The following checks for the existence of the file sample.dat. If the file does 
  13566. not exist, it is created. 
  13567.  
  13568.                                                                         *
  13569. ************************************************************************/
  13570.  
  13571. #include <io.h>
  13572. #include <stdio.h>
  13573. #include <stdlib.h>
  13574. int main(void)
  13575. {
  13576.    if (-1 == _access("sample.dat",00))
  13577.    {
  13578.       printf("File sample.dat does not exist.\n");
  13579.       printf("Creating sample.dat.\n");
  13580.       system("echo Sample Program > sample.dat");
  13581.       if (0 == _access("sample.dat",00))
  13582.          printf("File sample.dat created.\n");
  13583.    }
  13584.    else
  13585.       printf("File sample.dat exists.\n");
  13586.    return 0;
  13587. /****************  The output should be similar to:  ********************
  13588.       File sample.dat does not exist.
  13589.       Creating sample.dat.
  13590.       File sample.dat created.
  13591. */
  13592. }
  13593.  
  13594.  
  13595. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13596.  
  13597. /************************************************************************
  13598. *
  13599. This example prompts for a value for x.  It prints an error message if x is 
  13600. greater than 1 or less than -1;  otherwise, it assigns the arc cosine of x to 
  13601. y. 
  13602.  
  13603.                                                                         *
  13604. ************************************************************************/
  13605.  
  13606. #include <stdio.h>
  13607. #include <stdlib.h>
  13608. #include <math.h>
  13609. #define MAX  1.0
  13610. #define MIN -1.0
  13611. int main(void) {
  13612.   double x, y;
  13613.   printf( "Enter x\n" );
  13614.   scanf( "%lf", &x );
  13615.   /* Output error if not in range */
  13616.   if ( x > MAX )
  13617.     printf( "Error: %lf too large for acos\n", x );
  13618.   else if ( x < MIN )
  13619.     printf( "Error: %lf too small for acos\n", x );
  13620.   else {
  13621.     y = acos( x );
  13622.     printf( "acos( %lf ) = %lf\n", x, y );
  13623.   }
  13624. }
  13625.  
  13626. /************************************************************************
  13627. *
  13628.  
  13629. /*******  Expected output if 0.4 is entered:  *********
  13630. Enter x
  13631. acos( 0.400000 ) = 1.159279
  13632. */
  13633.  
  13634.                                                                         *
  13635. ************************************************************************/
  13636.  
  13637.  
  13638. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13639.  
  13640. /************************************************************************
  13641. *
  13642. The following example uses srand to generate five random numbers.  The numbers 
  13643. determine how much space _alloca is to allocate for the array barstr.  The 
  13644. result is a ragged two-dimensional array of strings. 
  13645.  
  13646.                                                                         *
  13647. ************************************************************************/
  13648.  
  13649. #include <stdio.h>
  13650. #include <stdlib.h>
  13651. #include <time.h>
  13652. int main(void)
  13653. {
  13654.     char *fullbar = "1 2 3 4 5";
  13655.     int range, rval;
  13656.     char *barstr[5];
  13657.     int i;
  13658.     printf("Bar representation of 5 random numbers ");
  13659.     printf("(each generated from 1 to 5):\n\n");
  13660.     srand( (unsigned int)time(NULL) );     /* set seed for rand function  */
  13661.                                            /* using time in seconds       */
  13662.     for (i = 0; i < 5; i++)
  13663.     {
  13664.        rval = (rand() + 1) % 5;    /* generate random number from 0 to 4  */
  13665.        /* for partial copy of fullbar, allocate space on stack for barstr
  13666.           from 2 to 10 characters long + one space for a null character   */
  13667.        barstr[i] = _alloca( (rval * sizeof(char) << 1) + 3 );
  13668.        memset(barstr[i], '\0', (rval 8 sizeof(char) <<1) + 3);
  13669.        /* copy random sized portion of fullbar  */
  13670.        strncpy(barstr[i], fullbar, ((rval +1) * 2) );
  13671.        printf("%s\n", barstr[i]);    /*  print random length bar  */
  13672.     }
  13673.     return 0;
  13674.     /***************  Possible output could be:  ********************
  13675.        Bar representation of 5 random numbers (each generated from 1 to 5):
  13676.        1
  13677.        1 2 3 4
  13678.        1 2 3
  13679.        1 2 3 4 5
  13680.        1 2                                */
  13681. }
  13682.  
  13683.  
  13684. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13685.  
  13686. /************************************************************************
  13687. *
  13688. This example polls the system clock and prints a message giving the current 
  13689. time. 
  13690.  
  13691.                                                                         *
  13692. ************************************************************************/
  13693.  
  13694. #include <time.h>
  13695. #include <stdio.h>
  13696. int main(void)
  13697. {
  13698.     struct tm *newtime;
  13699.     time_t ltime;
  13700.         /* Get the time in seconds */
  13701.     time(<ime);
  13702.         /* Convert it to the structure tm */
  13703.     newtime = localtime(<ime);
  13704.         /* Print the local time as a string */
  13705.     printf("The current date and time are %s",
  13706.              asctime(newtime));
  13707. }
  13708.  
  13709. /************************************************************************
  13710. *
  13711.  
  13712. /****************  Output should be similar to:  ******************
  13713. The current date and time are Fri Mar 26 13:29:51 1993
  13714. */
  13715.  
  13716.                                                                         *
  13717. ************************************************************************/
  13718.  
  13719.  
  13720. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13721.  
  13722. /************************************************************************
  13723. *
  13724. This example prompts for a value for x.  It prints an error message if x is 
  13725. greater than 1 or less than -1;  otherwise, it assigns the arc sine of x to y. 
  13726.  
  13727.                                                                         *
  13728. ************************************************************************/
  13729.  
  13730. #include <stdio.h>
  13731. #include <stdlib.h>
  13732. #include <math.h>
  13733. #define MAX  1.0
  13734. #define MIN -1.0
  13735. int main(void) {
  13736.   double x, y;
  13737.   printf( "Enter x\n" );
  13738.   scanf( "%lf", &x );
  13739.   /* Output error if not in range */
  13740.   if ( x > MAX )
  13741.     printf( "Error: %lf too large for asin\n", x );
  13742.   else if ( x < MIN )
  13743.     printf( "Error: %lf too small for asin\n", x );
  13744.   else {
  13745.     y = asin( x );
  13746.     printf( "asin( %lf ) = %lf\n", x, y );
  13747.   }
  13748. }
  13749.  
  13750. /************************************************************************
  13751. *
  13752.  
  13753. /****************  Output should be similar to:  ******************
  13754. Enter x
  13755. asin( 0.200000 ) = 0.201358
  13756. */
  13757.  
  13758.                                                                         *
  13759. ************************************************************************/
  13760.  
  13761.  
  13762. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13763.  
  13764. /************************************************************************
  13765. *
  13766. In this example, the assert function tests the string argument for a null 
  13767. string and an empty string and verifies that the length argument is positive 
  13768. before processing these arguments. 
  13769.  
  13770.                                                                         *
  13771. ************************************************************************/
  13772.  
  13773. #include <stdio.h>
  13774. #include <assert.h>
  13775. void analyze (char *, int);
  13776. int main(void)
  13777. {
  13778.    char *string = "ABC";
  13779.    int length = 3;
  13780.    analyze(string, length);
  13781.    printf("The string %s is not null or empty, and has length %d \n",
  13782.             string, length);
  13783. }
  13784. void analyze(char *string, int length)
  13785. {
  13786.    assert(string != NULL);            /* cannot be NULL */
  13787.    assert(*string != '\0');    /* cannot be empty */
  13788.    assert(length > 0);          /* must be positive */
  13789. }
  13790.  
  13791. /************************************************************************
  13792. *
  13793.  
  13794. /****************  Output should be similar to:  ******************
  13795. The string ABC is not null or empty, and has length 3
  13796. */
  13797.  
  13798.                                                                         *
  13799. ************************************************************************/
  13800.  
  13801.  
  13802. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13803.  
  13804. /************************************************************************
  13805. *
  13806. This example calculates arc tangents using the atan and atan2 functions. 
  13807.  
  13808.                                                                         *
  13809. ************************************************************************/
  13810.  
  13811. #include <math.h>
  13812. int main(void)
  13813. {
  13814.     double a,b,c,d;
  13815.     c = 0.45;
  13816.     d = 0.23;
  13817.     a = atan(c);
  13818.     b = atan2(c,d);
  13819.     printf("atan( %lf ) = %lf\n", c, a);
  13820.     printf("atan2( %lf, %lf ) = %lf\n", c, d, b);
  13821. }
  13822.  
  13823. /************************************************************************
  13824. *
  13825.  
  13826. /****************  Output should be similar to:  ******************
  13827. atan( 0.450000 ) = 0.422854
  13828. atan2( 0.450000, 0.230000 ) = 1.098299
  13829. */
  13830.  
  13831.                                                                         *
  13832. ************************************************************************/
  13833.  
  13834.  
  13835. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13836.  
  13837. /************************************************************************
  13838. *
  13839. The following example uses the atexit function to call the function goodbye at 
  13840. program termination. 
  13841.  
  13842.                                                                         *
  13843. ************************************************************************/
  13844.  
  13845. #include <stdlib.h>
  13846. #include <stdio.h>
  13847. int main(void)
  13848. {
  13849.    void goodbye(void);
  13850.    int rc;
  13851.    rc = atexit(goodbye);
  13852.    if (rc != 0)
  13853.       perror("Error in atexit");
  13854.    exit(0);
  13855. }
  13856. void goodbye(void)
  13857.           /* This function is called at normal program termination */
  13858. {
  13859.    printf("The function goodbye was called at program termination\n");
  13860. }
  13861.  
  13862. /************************************************************************
  13863. *
  13864.  
  13865. /****************  Output should be similar to:  ******************
  13866. The function goodbye was called at program termination
  13867. */
  13868.  
  13869.                                                                         *
  13870. ************************************************************************/
  13871.  
  13872.  
  13873. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13874.  
  13875. /************************************************************************
  13876. *
  13877. The example shows how to convert numbers stored as strings to numerical values 
  13878. using the atof function. 
  13879.  
  13880.                                                                         *
  13881. ************************************************************************/
  13882.  
  13883. #include <stdlib.h>
  13884. int main(void)
  13885. {
  13886.     double x;
  13887.     char *s;
  13888.     s = " -2309.12E-15";
  13889.     x = atof(s);     /* x = -2309.12E-15 */
  13890. }
  13891.  
  13892.  
  13893. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13894.  
  13895. /************************************************************************
  13896. *
  13897. The example shows how to convert numbers stored as strings to numerical values 
  13898. using the atoi function. 
  13899.  
  13900.                                                                         *
  13901. ************************************************************************/
  13902.  
  13903. #include <stdlib.h>
  13904. int main(void)
  13905. {
  13906.     int i;
  13907.     char *s;
  13908.     s = " -9885";
  13909.     i = atoi(s);     /* i = -9885 */
  13910. }
  13911.  
  13912.  
  13913. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13914.  
  13915. /************************************************************************
  13916. *
  13917. The example shows how to convert numbers stored as strings to numerical values 
  13918. using the atol function. 
  13919.  
  13920.                                                                         *
  13921. ************************************************************************/
  13922.  
  13923. #include <stdlib.h>
  13924. int main(void)
  13925. {
  13926.     long l;
  13927.     char *s;
  13928.     s = "98854 dollars";
  13929.     l = atol(s);     /* l = 98854 */
  13930. }
  13931.  
  13932.  
  13933. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13934.  
  13935. /************************************************************************
  13936. *
  13937. The following example uses _atold to convert two strings, "  -001234.5678e10end 
  13938. of string" and "NaNQ", to their corresponding long double values. 
  13939.  
  13940.                                                                         *
  13941. ************************************************************************/
  13942.  
  13943. #include <stdlib.h>
  13944. #include <stdio.h>
  13945. int main(void)
  13946. {
  13947.   char *string;
  13948.   string = "  -001234.5678e10end of string";
  13949.   printf("_atold = %.10Le\n", _atold(string) );
  13950.   string = "NaNQ";
  13951.   printf("_atold = %.10Le\n", _atold(string) );
  13952.   return 0;
  13953.   /* The expected output is:
  13954.      _atold = -1.2345678000e+13
  13955.      _atold = nan                */
  13956. }
  13957.  
  13958.  
  13959. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  13960.  
  13961. /************************************************************************
  13962. *
  13963. This example uses _beginthread to start a new thread bonjour, which prints 
  13964. Bonjour! five times then implicitly ends itself. The program then prints a 
  13965. statement indicating the thread identifier number for bonjour. 
  13966.  
  13967. Note:  To run this example, you must compile it using the /Gm+ compiler option. 
  13968.  
  13969.                                                                         *
  13970. ************************************************************************/
  13971.  
  13972. #define INCL_DOS
  13973. #include <os2.h>
  13974. #include <stdio.h>
  13975. #include <stdlib.h>
  13976. static int wait = 1;
  13977. void bonjour(void *arg)
  13978. {
  13979.    int i = 0;
  13980.    while (wait)     /* wait until the thread id has been printed */
  13981.       DosSleep(0l);
  13982.    while ( i++ < 5 )
  13983.       printf("Bonjour!\n");
  13984. }
  13985. int main(void)
  13986. {
  13987.    unsigned long tid;
  13988.    tid = _beginthread(bonjour, NULL, 8192, NULL);
  13989.    if ( tid == -1 )
  13990.    {
  13991.       printf("Unable to start thread.\n");
  13992.       exit(-1);
  13993.    }
  13994.    else
  13995.    {
  13996.       printf("Thread started with thread identifier number %d.\n", tid);
  13997.       wait = 0;
  13998.    }
  13999.    DosWaitThread( &tid, DCWW_WAIT );  /* wait for thread bonjour to end */
  14000.                                       /* before ending main thread      */
  14001.    return 0;
  14002.    /* The expected output (with possible thread id number) is:
  14003.       Thread started with thread identifier number 2.
  14004.       Bonjour!
  14005.       Bonjour!
  14006.       Bonjour!
  14007.       Bonjour!
  14008.       Bonjour!                                                  */
  14009. }
  14010.  
  14011.  
  14012. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14013.  
  14014. /************************************************************************
  14015. *
  14016. The following example computes y to be the order 0 Bessel function of the first 
  14017. kind for x and z to be the order 3 Bessel function of the second kind for x. 
  14018.  
  14019.                                                                         *
  14020. ************************************************************************/
  14021.  
  14022. #include <math.h>
  14023. int main(void)
  14024. {
  14025.     double x, y, z;
  14026.     x = 4.27;
  14027.     y = j0(x);      /* y = -0.3660 is the order 0 bessel */
  14028.                     /* function of the first kind for x  */
  14029.     z = yn(3,x);    /* z = -0.0875 is the order 3 bessel */
  14030.                     /* function of the second kind for x */
  14031. }
  14032.  
  14033.  
  14034. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14035.  
  14036. /************************************************************************
  14037. *
  14038. The following example performs a binary search on the argv array of pointers to 
  14039. the program parameters and finds the position of the argument PATH. It first 
  14040. removes the program name from argv, then sorts the array alphabetically before 
  14041. calling bsearch. The functions compare1 and compare2 compare the values pointed 
  14042. to by arg1 and arg2 and return the result to bsearch. 
  14043.  
  14044.                                                                         *
  14045. ************************************************************************/
  14046.  
  14047. #include <stdlib.h>
  14048. #include <stdio.h>
  14049. #include <string.h>
  14050. int compare1(const void *arg1, const void *arg2);
  14051. int compare2(const void *arg1, const void *arg2);
  14052. int main(int argc, char *argv[])
  14053. {
  14054.    char **result;
  14055.    char *key = "PATH";
  14056.    int i;
  14057.    argv++;
  14058.    argc--;
  14059.    qsort((char *)argv, argc, sizeof(char *), compare1);
  14060.    result = (char**)bsearch(key, argv, argc, sizeof(char *), compare2);
  14061.    if (result != NULL)
  14062.    {
  14063.       printf("result = <%s>\n",*result);
  14064.    }
  14065.    else printf("result is null\n");
  14066. }
  14067. int compare1(const void *arg1, const void *arg2)
  14068. {
  14069.    return (strcmp(*(char **)arg1, *(char **)arg2));
  14070. }
  14071. int compare2(const void *arg1, const void *arg2)
  14072. {
  14073.    return (strcmp((char *)arg1, *(char **)arg2));
  14074. }
  14075.  
  14076. /************************************************************************
  14077. *
  14078.  
  14079. /********************  Output should be similar to:  **************
  14080. progname where is PATH in this phrase?
  14081. result = <PATH>
  14082. */
  14083.  
  14084.                                                                         *
  14085. ************************************************************************/
  14086.  
  14087.  
  14088. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14089.  
  14090. /************************************************************************
  14091. *
  14092. The following example prompts for the number of array entries required and then 
  14093. reserves enough space in storage for the entries. If calloc is successful, the 
  14094. example prints out each entry;  otherwise, it prints out an error. 
  14095.  
  14096.                                                                         *
  14097. ************************************************************************/
  14098.  
  14099. #include <stdio.h>
  14100. #include <stdlib.h>
  14101. int main(void) {
  14102.   long * array;    /* start of the array */
  14103.   long * index;    /* index variable     */
  14104.   int    i;        /* index variable     */
  14105.   int  num;        /* number of entries of the array */
  14106.   printf( "Enter the size of the array\n" );
  14107.   scanf( "%i", &num );
  14108.   /* allocate num entries */
  14109.   if ( (index = array = calloc( num, sizeof( long ))) != NULL ) {
  14110.     for ( i = 0; i < num; ++i )           /* put values in array    */
  14111.        *index++ = i;                      /* using pointer notation */
  14112.     for ( i = 0; i < num; ++i )           /* print the array out    */
  14113.       printf( "array[ %i ] = %i\n", i, array[i] );
  14114.   }
  14115.   else { /* out of storage */
  14116.     perror( "Out of storage" );
  14117.     abort();
  14118.   }
  14119. }
  14120.  
  14121. /************************************************************************
  14122. *
  14123.  
  14124. /******************  Output should be similar to:  **********************
  14125. Enter the size of the array
  14126. array[ 0 ] = 0
  14127. array[ 1 ] = 1
  14128. array[ 2 ] = 2
  14129. */
  14130.  
  14131.                                                                         *
  14132. ************************************************************************/
  14133.  
  14134.  
  14135. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14136.  
  14137. /************************************************************************
  14138. *
  14139. The following example sets y to the smallest integer greater than 1.05, and 
  14140. then to the smallest integer greater than -1.05.  The results are 2. and -1., 
  14141. respectively. 
  14142.  
  14143.                                                                         *
  14144. ************************************************************************/
  14145.  
  14146. #include <math.h>
  14147. int main(void)
  14148. {
  14149.    double y, z;
  14150.    y = ceil(1.05);       /* y = 2.0 */
  14151.    z = ceil(-1.05);      /* z = -1.0 */
  14152. }
  14153.  
  14154.  
  14155. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14156.  
  14157. /************************************************************************
  14158. *                                                                          *
  14159.  
  14160. This program creates a buffer and initializes the first byte to the size of the 
  14161. buffer.  Next, the program accepts an input string using cgetsand displays the 
  14162. size and text of that string. 
  14163.  
  14164.                                                                         *
  14165. ************************************************************************/
  14166.  
  14167.  
  14168. #include <conio.h>
  14169. #include <stdio.h>
  14170. void nothing(void)
  14171. {
  14172. }
  14173. int main(void)
  14174. {
  14175.     char buffer[82] = { 84, 0 };
  14176.     char * buffer2;
  14177.     int i;
  14178.     _cputs("\nPress any key to continue.");
  14179.     printf("\n");
  14180.     while (_kbhit() == 0)
  14181.     {
  14182.     nothing();
  14183.     }
  14184.     _getch();
  14185.     _cputs("\nEnter a line of text:");
  14186.     printf("\n");
  14187.     buffer2= _cgets(buffer);
  14188.     printf("\nText entered was: %s",buffer2);
  14189.     return 0;
  14190. }
  14191.  
  14192.  
  14193. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14194.  
  14195. /************************************************************************
  14196. *                                                                          *
  14197. The following program changes the current working directory to the root 
  14198. directory, and then to the \red\green\blue directory: 
  14199.  
  14200.                                                                         *
  14201. ************************************************************************/
  14202.  
  14203. #include <direct.h>
  14204. #include <stdio.h>
  14205. int main(void)
  14206. {
  14207.     printf("Changing to the root directory.\n");
  14208.     if (_chdir("\\"))
  14209.        perror(NULL);
  14210.     else
  14211.        printf("Changed to the root directory.\n\n");
  14212.     printf("Changing to directory '\\red\\green\\blue'.\n");
  14213.     if (_chdir("\\red\\green\\blue"))
  14214.        perror(NULL);
  14215.     else
  14216.        printf("Changed to directory '\\red\\green\\blue'.\n");
  14217.     return 0;
  14218. /****************  The output should be similar to:  ********************
  14219.   Changing to the root directory.
  14220.   Changed to the root directory.
  14221.   Changing to directory '\red\green\blue'.
  14222.   Changed to directory '\red\green\blue'.
  14223. */
  14224. }
  14225.  
  14226.  
  14227. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14228.  
  14229. /************************************************************************
  14230. *
  14231. The following program uses _chdrive to change the current working drive to C:. 
  14232.  
  14233.                                                                         *
  14234. ************************************************************************/
  14235.  
  14236. #include <direct.h>
  14237. #include <stdio.h>
  14238. int main(void)
  14239. {
  14240.     if (_chdrive(3))
  14241.          printf("Cannot change current working drive to 'C' drive.\n");
  14242.     else
  14243.     {
  14244.          printf("Current working drive changed to ");
  14245.          printf("'%c' drive.\n", ('A'+_getdrive() - 1) );
  14246.     }
  14247.     return 0;
  14248. /**************  The output should be similar to:  **********************
  14249.    Current working drive changed to 'C' drive.
  14250. */
  14251. }
  14252.  
  14253.  
  14254. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14255.  
  14256. /************************************************************************
  14257. *
  14258.  
  14259. The following program opens the file chmod.dat for writing after checking the 
  14260. file to see if writing is permissible. It then writes from the buffer to the 
  14261. opened file. This program takes file names passed as arguments and sets each to 
  14262. read-only. 
  14263.  
  14264.                                                                         *
  14265. ************************************************************************/
  14266.  
  14267. #include <sys\stat.h>
  14268. #include <io.h>
  14269. #include <stdio.h>
  14270. #include <stdlib.h>
  14271. int main(void)
  14272. {
  14273.    if (-1 == _access("chmod.dat",00))    /* Check if file exists. */
  14274.    {
  14275.       printf("\nCreating chmod.dat.\n");
  14276.       system("echo Sample Program > chmod.dat");
  14277.       printf("_chmod chmod.dat to be readonly.\n");
  14278.       if (-1 == _chmod("chmod.dat",S_IREAD))
  14279.          perror("_chmod failed");
  14280.       if (-1 == _access("chmod.dat",02))
  14281.          printf("File chmod.dat is now readonly.\n\n");
  14282.       printf("Run this program again to erase chmod.dat.\n\n");
  14283.    }
  14284.    else
  14285.    {
  14286.       printf("\nFile chmod.dat exist.\n");
  14287.       printf("_chmod chmod.dat to become writable.\n");
  14288.       if (-1 == _chmod("chmod.dat",S_IWRITE))
  14289.          perror("_chmod failed");
  14290.       system("erase  chmod.dat");
  14291.       printf("File chmod.dat removed.\n\n");
  14292.    }
  14293.    return 0;
  14294. /****************  If chmod.dat does not exist,  ************************
  14295. ****************  the output should be similar to:  *********************
  14296.       Creating chmod.dat.
  14297.       _chmod chmod.dat to be readonly.
  14298.       File chmod.dat is now readonly.
  14299. *************  Run this program again to erase chmod.dat.  *************/
  14300. }
  14301.  
  14302.  
  14303. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14304.  
  14305. /************************************************************************
  14306. *
  14307.  
  14308. This program opens a file named sample.dat and returns the current length of 
  14309. that file. It then alters the size of sample.dat and returns the new length of 
  14310. that file. 
  14311.  
  14312.                                                                         *
  14313. ************************************************************************/
  14314.  
  14315. #include <io.h>
  14316. #include <stdio.h>
  14317. #include <stdlib.h>
  14318. #include <fcntl.h>
  14319. int main(void)
  14320. {
  14321.    long length;
  14322.    int  fh;
  14323.    printf("\nCreating sample.dat.\n");
  14324.    system("echo Sample Program > sample.dat");
  14325.    if (-1 == (fh = _open("sample.dat",O_RDWR | O_APPEND))) {
  14326.       printf("Unable to open sample.dat.\n");
  14327.       return 1;
  14328.    }
  14329.    if (-1 == (length = _filelength(fh))) {
  14330.       printf("Unable to determine length of sample.dat.\n");
  14331.       return 1;
  14332.    }
  14333.    printf("Current length of sample.dat is %d.\n",length);
  14334.    printf("Changing the length of sample.dat to 20.\n");
  14335.    if (-1 == (_chsize(fh,20))) {
  14336.       perror("_chsize failed");
  14337.       return 1;
  14338.    }
  14339.    if (-1 == (length = _filelength(fh))) {
  14340.       printf("Unable to determine length of sample.dat.\n");
  14341.       return 1;
  14342.    }
  14343.    printf("New length of sample.dat is %d.\n",length);
  14344.    _close(fh);
  14345.    return 0;
  14346. /**************  The output should be similar to:  **********************
  14347.       Creating sample.dat.
  14348.       Current length of sample.dat is 17.
  14349.       Changing the length of sample.dat to 20.
  14350.       New length of sample.dat is 20.
  14351. */
  14352. }
  14353.  
  14354.  
  14355. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14356.  
  14357. /************************************************************************
  14358. *
  14359. The following example reads a data stream and then checks that a read error has 
  14360. not occurred. 
  14361.  
  14362.                                                                         *
  14363. ************************************************************************/
  14364.  
  14365. #include <stdio.h>
  14366. #include <stdlib.h>
  14367. FILE *stream;
  14368. int c;
  14369. int main(void)
  14370. {
  14371.    if ((stream = fopen("myfile.dat", "r")) != NULL) {
  14372.       if ((c=getc(stream)) == EOF) {
  14373.          if (ferror(stream)) {
  14374.             perror("Read error");
  14375.             clearerr(stream);
  14376.          }
  14377.       }
  14378.    }
  14379.    else
  14380.       exit(0);
  14381. }
  14382.  
  14383.  
  14384. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14385.  
  14386. /************************************************************************
  14387. *
  14388. The following example takes a number close to 0 as a double and assigns it to a 
  14389. float.  The result is a loss of significance, y becomes a denormal number, and 
  14390. the underflow bit of the floating-point status word is set. The _clear87 
  14391. function gets the current floating-point status word and then clears it, and 
  14392. the printf function prints it as immediate data. The result shows the change in 
  14393. the floating-point word due to the loss of significance. 
  14394.  
  14395. The program then assigns the denormal y to another variable, causing the 
  14396. denormal bit to be set in the floating-point status word.  Again, the _clear87 
  14397. gets the current status word and clears it, and printf prints it to the screen. 
  14398.  
  14399.                                                                         *
  14400. ************************************************************************/
  14401.  
  14402. #include <stdio.h>
  14403. #include <float.h>
  14404. double a = 1e-40;
  14405. double b;
  14406. float y;
  14407. int main(void)
  14408. {
  14409.    unsigned int statword;
  14410.    unsigned int old_cw;
  14411.    /*  change control word to mask all exceptions */
  14412.    _control87(0x037f,0xffff);
  14413.    /* Assignment of the double to the float y is inexact; */
  14414.    /*       the underflow bit is set.                     */
  14415.    y = a;
  14416.    statword = _clear87();
  14417.    printf("floating-point status = 0x%.4x after underflow\n", statword);
  14418.    statword = _status87();
  14419.    printf("cleared floating-point status word = 0x%.4x\n", statword);
  14420.    /*  reset floating point status word  */
  14421.    _fpreset();
  14422.    /*  change control word to mask all exception */
  14423.    _control87(0x037f,0xffff);
  14424.    /* Reassigning the denormal y to the double b */
  14425.    /*   causes the denormal bit to be set. */
  14426.    b = y;
  14427.    statword = _clear87();
  14428.    printf("floating-point status = 0x%.4x for denormal\n", statword);
  14429.    /*  reset floating point status word  */
  14430.    _fpreset();
  14431.    return 0;
  14432.    /* The expected output is:
  14433.       floating-point status = 0x0030 after underflow
  14434.       cleared floating-point status word = 0x0000
  14435.       floating-point status = 0x0002 for denormal    */
  14436. }
  14437.  
  14438.  
  14439. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14440.  
  14441. /************************************************************************
  14442. *
  14443. The following example prints the time elapsed since the program was invoked. 
  14444.  
  14445.                                                                         *
  14446. ************************************************************************/
  14447.  
  14448. #include <time.h>
  14449. #include <stdio.h>
  14450. double time1, timedif;/* use doubles to show small values */
  14451. int main(void)
  14452. {
  14453.     time1 = (double) clock();            /* get initial time */
  14454.     time1 = time1 / CLOCKS_PER_SEC;      /*    in seconds    */
  14455.    .
  14456.    .
  14457.    .
  14458.     /* call clock a second time */
  14459.     timedif = ( ((double) clock()) / CLOCKS_PER_SEC) - time1;
  14460.     printf("The elapsed time is %f seconds\n", timedif);
  14461. }
  14462.  
  14463.  
  14464. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14465.  
  14466. /************************************************************************
  14467. *
  14468. This example prints the initial control word in hexadecimal, and then 
  14469. illustrates different representations of 0.1, depending on the precision. 
  14470.  
  14471.                                                                         *
  14472. ************************************************************************/
  14473.  
  14474. #include <stdio.h>
  14475. #include <float.h>
  14476. double a = .13;
  14477. int main(void)
  14478. {
  14479.     printf("control = 0x%.4x\n",
  14480.     _control87(CW_DEFAULT, 0));        /* Get control word */
  14481.     printf("a*a = .0169 = %.15e\n",a*a);
  14482.     _control87(PC_24, MCW_PC);         /* Set precision to 24 bits */
  14483.     printf("a*a = .0169 (rounded to 24 bits) = %.15e\n",a*a);
  14484.     _control87(CW_DEFAULT, 0xffff);    /* Restore to initial default */
  14485.     printf("a*a = .0169 = %.15e\n",a*a);
  14486.     return 0;
  14487.     /* Possible output could be:
  14488.        control = 0x0362
  14489.        a*a = .0169 = 1.690000000000000e-02
  14490.        a*a = .0169 (rounded to 24 bits) = 1.689999046325684e-03
  14491.        a*a = .0169 = 1.690000000000000e-02                      */
  14492. }
  14493.  
  14494.  
  14495. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14496.  
  14497. /************************************************************************
  14498. *
  14499.  
  14500. The following program opens the file edclose.dat and then closes it using the 
  14501. _close function. 
  14502.  
  14503.                                                                         *
  14504. ************************************************************************/
  14505.  
  14506. #include <io.h>
  14507. #include <stdio.h>
  14508. #include <fcntl.h>
  14509. #include <sys\stat.h>
  14510. int main(void)
  14511. {
  14512.    int fh;
  14513.    printf("\nCreating edclose.dat.\n");
  14514.    if ( -1 ==
  14515.            (fh = _open("edclose.dat",
  14516.                       O_RDWR | O_CREAT | O_TRUNC,
  14517.                       S_IREAD | S_IWRITE)))
  14518.    {
  14519.       perror("Unable to open edclose.dat");
  14520.       return 1;
  14521.    }
  14522.    printf("File was successfully opened.\n");
  14523.    if ( -1 == _close(fh))
  14524.    {
  14525.       perror("Unable to close edclose.dat");
  14526.       return 1;
  14527.    }
  14528.    printf("File was successfully closed.\n");
  14529.    return 0;
  14530. /****************  The output should be similar to:  ********************
  14531.       Creating edclose.dat.
  14532.       File was successfully opened.
  14533.       File was successfully closed.
  14534. */
  14535. }
  14536.  
  14537.  
  14538. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14539.  
  14540. /************************************************************************
  14541. *
  14542. The following example calculates y to be the cosine of x. 
  14543.  
  14544.                                                                         *
  14545. ************************************************************************/
  14546.  
  14547. #include <math.h>
  14548. int main(void)
  14549. {
  14550.    double x, y;
  14551.    x = 7.2;
  14552.    y = cos(x);
  14553.    printf("cos( %lf ) = %lf\n", x, y);
  14554. }
  14555.  
  14556. /************************************************************************
  14557. *
  14558.  
  14559. /*********************  Output should be similar to:  *******************
  14560. cos( 7.200000 ) = 0.608351
  14561. */
  14562.  
  14563.                                                                         *
  14564. ************************************************************************/
  14565.  
  14566.  
  14567. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14568.  
  14569. /************************************************************************
  14570. *
  14571. The following example calculates y to be the hyperbolic cosine of x. 
  14572.  
  14573.                                                                         *
  14574. ************************************************************************/
  14575.  
  14576. #include <math.h>
  14577. int main(void)
  14578. {
  14579.    double x,y;
  14580.    x = 7.2;
  14581.    y = cosh(x);
  14582.    printf("cosh( %lf ) = %lf\n", x, y);
  14583. }
  14584.  
  14585. /************************************************************************
  14586. *
  14587.  
  14588. /*********************  Output should be similar to:  *******************
  14589. cosh( 7.200000 ) = 669.715755
  14590. */
  14591.  
  14592.                                                                         *
  14593. ************************************************************************/
  14594.  
  14595.  
  14596. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14597.  
  14598. /************************************************************************
  14599. *
  14600. The following program uses _cprintf to write strings to the screen. 
  14601.  
  14602.                                                                         *
  14603. ************************************************************************/
  14604.  
  14605. #include <conio.h>
  14606. int main(void)
  14607. {
  14608.     char buffer[24];
  14609.     _cprintf("\nPlease enter a file name:\n");
  14610.     _cscanf("%23s", buffer);
  14611.     _cprintf("\nThe file name you entered was %23s.", buffer);
  14612.     return 0;
  14613. /******************  The output should be similar to:  ******************
  14614.     Please enter a file name:
  14615.                             file.dat
  14616.     The file name you entered was                file.dat.
  14617. */
  14618. }
  14619.  
  14620.  
  14621. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14622.  
  14623. /************************************************************************
  14624. *
  14625.  
  14626. The following statement puts a prompt out to the screen. 
  14627.  
  14628.                                                                         *
  14629. ************************************************************************/
  14630.  
  14631. #include <conio.h>
  14632. int main(void)
  14633. {   char *buffer = "Insert data disk in drive a: \r\n";
  14634.     _cputs(buffer);
  14635.     return 0;
  14636. /***************  The output should be similar to:  *********************
  14637.     Insert data disk in drive a:
  14638. */
  14639. }
  14640.  
  14641.  
  14642. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14643.  
  14644. /************************************************************************
  14645. *
  14646.  
  14647. This example creates the file sample.dat so it can be read from and written to. 
  14648.  
  14649.                                                                         *
  14650. ************************************************************************/
  14651.  
  14652. #include <sys\stat.h>
  14653. #include <io.h>
  14654. #include <stdio.h>
  14655. int main(void)
  14656. {
  14657.    int fh;
  14658.    fh = _creat("sample.dat", S_IREAD | S_IWRITE);
  14659.    if ( -1 == fh)
  14660.    {
  14661.       perror("Error in creating sample.dat");
  14662.       return 1;
  14663.    }
  14664.    else
  14665.       printf("Successfully created sample.dat.\n");
  14666.    _close(fh);
  14667.    return 0;
  14668. /******************  Expected output is:  *******************************
  14669.       Successfully created sample.dat.
  14670. */
  14671. }
  14672.  
  14673.  
  14674. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14675.  
  14676. /************************************************************************
  14677. *
  14678.  
  14679. The following program uses _cscanf to read stings from the screen. 
  14680.  
  14681.                                                                         *
  14682. ************************************************************************/
  14683.  
  14684. #include <conio.h>
  14685. int main(void)
  14686. {
  14687.     char buffer[24];
  14688.     _cprintf("\nPlease enter a file name:\n");
  14689.     _cscanf("%23s", buffer);
  14690.     _cprintf("\nThe file name you entered was %23s.", buffer);
  14691.     return 0;
  14692. /******************  The output should be similar to:  ******************
  14693.     Please enter a file name:
  14694.                             file.dat
  14695.     The file name you entered was                file.dat.
  14696. */
  14697. }
  14698.  
  14699.  
  14700. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14701.  
  14702. /************************************************************************
  14703. *
  14704. The following example polls the system clock by using the library function 
  14705. time.  It then prints a message giving the current date and time. 
  14706.  
  14707.                                                                         *
  14708. ************************************************************************/
  14709.  
  14710. #include <time.h>
  14711. #include <stdio.h>
  14712. int main(void)
  14713. {
  14714.    time_t ltime;
  14715.    time(<ime);
  14716.    printf("the time is %s", ctime(<ime));
  14717. }
  14718.  
  14719.  
  14720. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14721.  
  14722. /************************************************************************
  14723. *
  14724. The following program creates a new process called child.exe.  The parent calls 
  14725. _cwait and waits for the child to end.  The parent then displays the child's 
  14726. return information in hexadecimal. 
  14727.  
  14728.                                                                        *
  14729. ***********************************************************************/
  14730.  
  14731. #include <stdio.h>
  14732. #include <process.h>
  14733. #include <errno.h>
  14734. int stat_child;
  14735. int main(void)
  14736. {
  14737.     int i, result;
  14738.     /* spawn a child and 'cwait' for it to finish*/
  14739.     if ((result = _spawnl(P_NOWAIT,"child","child","1",NULL)) != -1) {
  14740.        if ((i= _cwait(&stat_child,result,WAIT_CHILD)) != result)
  14741.           printf("Error ...expected pid from child");
  14742.        else {
  14743.           if (errno == 0) {
  14744.               printf("Child process ended successfully and ...\n");
  14745.               printf("program returned to the Parent process.\n");
  14746.           }
  14747.           else
  14748.               printf("Child process had an error\n");
  14749.        }
  14750.    }
  14751.    else
  14752.       printf("Error ...could not spawn a child process\n");
  14753.    return 0;
  14754. }
  14755. /**************  If the source code for child.exe is:  ****************
  14756. #include <stdio.h>
  14757. int main(void)
  14758. {
  14759.     puts("This line was written by child.exe");
  14760. }
  14761. */
  14762. ***************  then the output should be similar to:  **************
  14763.    This line was written by child.exe
  14764.    Child process ended successfully and ...
  14765.    program returned to the Parent process.
  14766. */
  14767.  
  14768.  
  14769. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14770.  
  14771. /************************************************************************
  14772. *
  14773. The following example reserves storage of 124 bytes. It then attempts to write 
  14774. to storage that was not allocated.  When _debug_calloc is called again, 
  14775. _heap_check detects the error, generates several messages, and stops the 
  14776. program. 
  14777.  
  14778. Note:  Although the function calloc is coded in the example, the 
  14779. __DEBUG_ALLOC__ macro redefines calloc to _debug_calloc. 
  14780.  
  14781.                                                                         *
  14782. ************************************************************************/
  14783.  
  14784. #ifndef __DEBUG_ALLOC__      /* this macro could also be defined */
  14785.    #define __DEBUG_ALLOC__   /*      from the command line       */
  14786. #endif
  14787. #include <stdlib.h>
  14788. #include <stdio.h>
  14789. int main(void)
  14790. {
  14791.    char *ptr;
  14792.    if (( ptr = calloc(2, 62) ) == NULL)
  14793.    {
  14794.       printf( "Could not allocate memory block.\n" );
  14795.       return EXIT_FAILURE;
  14796.    }
  14797.    *(ptr + 124) = 'a';     /* overwrites storage that was not allocated */
  14798.    ptr = calloc(23, 45); /* this call to calloc invokes _heap_check */
  14799.    printf("_debug_calloc did not detect that a memory block was overwritten.\n");
  14800.    return EXIT_FAILURE;
  14801.    /* Possible output is:
  14802.       Memory was overwritten after the allocated memory block which starts
  14803.             at address 0x000B0F10.
  14804.       The first eight bytes of the memory block (in hex) are: 0000000000000000.
  14805.       This memory block was (re)allocated at line number 11 in TDCALLC.C.       */
  14806. }
  14807.  
  14808.  
  14809. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14810.  
  14811. /************************************************************************
  14812. *
  14813. The following example reserves two blocks of 62 bytes each.  It then frees the 
  14814. first block and attempts to overwrite the freed storage.  When _debug_free is 
  14815. called a second time, _heap_check detects the error, prints out several 
  14816. messages, and stops the program. 
  14817.  
  14818. Note:  Although the function free is coded in the example, the __DEBUG_ALLOC__ 
  14819. macro redefines free to _debug_free. 
  14820.  
  14821.                                                                         *
  14822. ************************************************************************/
  14823.  
  14824. #ifndef __DEBUG_ALLOC__      /* this macro could also be defined */
  14825.    #define __DEBUG_ALLOC__   /*      from the command line       */
  14826. #endif
  14827. #include <stdlib.h>
  14828. #include <stdio.h>
  14829. int main(void)
  14830. {
  14831.    char *ptr1;
  14832.    char *ptr2;
  14833.    if ( (( ptr1 = malloc(62) ) == NULL) || (( ptr2 = malloc(62) ) == NULL) )
  14834.    {
  14835.       printf("Could not allocate memory block.\n");
  14836.       return EXIT_FAILURE;
  14837.    }
  14838.    free(ptr1);
  14839.    *(ptr1 - 1) = 'a';   /* overwrites storage that has been freed */
  14840.    free(ptr2);         /* this call to free invokes _heap_check */
  14841.    printf("_debug_free did not detect that a free memory block was overwritten.\n");
  14842.    return EXIT_FAILURE;
  14843.    /* Possible output is:
  14844.       Memory was overwritten before the free memory block which starts
  14845.             at address 0x00150010.
  14846.       The first eight bytes of the memory block (in hex) are: B5B5A5A500000000.
  14847.       This memory block was freed at line number 17 in TDFREE.C.                */
  14848. }
  14849.  
  14850.  
  14851. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14852.  
  14853. /************************************************************************
  14854. *
  14855. The following example allocates 5000 bytes of storage, then changes the storage 
  14856. size to 35 bytes, and uses _debug_heapmin to return the unused memory to the 
  14857. operating system. The storage is then freed, and the program attempts to 
  14858. overwrite the freed storage. When _debug_heapmin is called again, _heap_check 
  14859. detects the error, generates several messages, and stops the program. 
  14860.  
  14861. Note:  Although the function _heapmin is coded in the example, the 
  14862. __DEBUG_ALLOC__ macro redefines _heapmin to _debug_free. 
  14863.  
  14864.                                                                         *
  14865. ************************************************************************/
  14866.  
  14867. #ifndef __DEBUG_ALLOC__       /* this macro could also be defined */
  14868.    #define __DEBUG_ALLOC__    /*      from the command line       */
  14869. #endif
  14870. #include <stdlib.h>
  14871. #include <stdio.h>
  14872. int main(void)
  14873. {
  14874.    char *ptr;
  14875.    ptr = malloc(5000);
  14876.    ptr = realloc(ptr, 35);
  14877.    _heapmin();    /* no allocation problems to detect */
  14878.    free(ptr);
  14879.    *ptr = 'a';     /* overwrites storage that has been freed */
  14880.    _heapmin();    /* this call to _heapmin invokes _heap_check */
  14881.    printf("_debug_heapmin did not detect that a free memory block was accessed\n");
  14882.    return 0;
  14883.    /* Possible output is:
  14884.       The free memory block which starts at address 0x00150010 has been accessed.
  14885.       The first eight bytes of the memory block (in hex) are: 61B5A5A500000000.
  14886.       This memory block was freed at line number 17 in THPMIN.C.                  */
  14887.    }
  14888.  
  14889.  
  14890. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14891.  
  14892. /************************************************************************
  14893. *
  14894. The following example allocates 62 bytes of storage. It then attempts to write 
  14895. to storage that was not allocated.  When _debug_malloc is called again, 
  14896. _heap_check detects the error, generates several messages, and stops the 
  14897. program. 
  14898.  
  14899. Note:  Although the function malloc is coded in the example, the 
  14900. __DEBUG_ALLOC__ macro redefines malloc to _debug_malloc. 
  14901.  
  14902.                                                                         *
  14903. ************************************************************************/
  14904.  
  14905. #ifndef __DEBUG_ALLOC__     /* this macro could also be defined */
  14906.    #define __DEBUG_ALLOC__  /*      from the command line       */
  14907. #endif
  14908. #include <stdlib.h>
  14909. #include <stdio.h>
  14910. int main(void)
  14911. {
  14912.    char *ptr;
  14913.    if ( (ptr = malloc(62) ) == NULL)
  14914.    {
  14915.       printf( "Could not allocate memory block.\n" );
  14916.       return EXIT_FAILURE;
  14917.    }
  14918.    *(ptr - 1) = 'a';     /* overwrites storage that was not allocated */
  14919.    ptr = malloc(2345);   /* this call to malloc invokes _heap_check */
  14920.    printf("_debug_malloc did not detect that a memory block was overwritten.\n");
  14921.    return EXIT_FAILURE;
  14922.    /* Possible output is:
  14923.       Memory was overwritten before the allocated memory block which starts
  14924.             at address 0x00150010.
  14925.       The first eight bytes of the memory block (in hex) are: 0000000000000000.
  14926.       This memory block was (re)allocated at line number 11 in TDMALLC.C.        */
  14927. }
  14928.  
  14929.  
  14930. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14931.  
  14932. /************************************************************************
  14933. *
  14934. The following example uses _debug_realloc to allocate 62 bytes of storage. It 
  14935. then attempts to write to storage that was not allocated. When _debug_realloc 
  14936. is called again, _heap_check detects the error, generates several messages, and 
  14937. stops the program. 
  14938.  
  14939. Note:  Although the function realloc is coded in the example, the 
  14940. __DEBUG_ALLOC__ macro redefines realloc to _debug_realloc. 
  14941.  
  14942.                                                                         *
  14943. ************************************************************************/
  14944.  
  14945. #ifndef __DEBUG_ALLOC__      /* this macro could also be defined */
  14946.    #define __DEBUG_ALLOC__   /*      from the command line       */
  14947. #endif
  14948. #include <stdlib.h>
  14949. #include <stdio.h>
  14950. int main(void)
  14951. {
  14952.    char *ptr;
  14953.    if (( ptr = realloc(NULL, 62) ) == NULL)
  14954.    {
  14955.       printf("Could not allocate memory block.\n");
  14956.       return EXIT_FAILURE;
  14957.    }
  14958.    *(ptr - 2) = 'a';           /* overwrites storage that was not allocated */
  14959.    ptr = realloc(ptr, 2345); /* this call to realloc invokes _heap_check */
  14960.    printf("_debug_realloc did not detect that a memory block was overwritten.\n");
  14961.    return EXIT_FAILURE;
  14962.    /* Possible output is:
  14963.       Memory was overwritten before the allocated memory block which starts
  14964.             at address 0x00150010.
  14965.       The first eight bytes of the memory block (in hex) are: 0000000000000000.
  14966.       This memory block was (re)allocated at line number 11 in TDRALLC.C.       */
  14967. }
  14968.  
  14969.  
  14970. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  14971.  
  14972. /************************************************************************
  14973. *
  14974. The following example shows a timing application using difftime.  The example 
  14975. calculates how long, on average, it takes to find the prime numbers from 2 to 
  14976. 10000. 
  14977.  
  14978.                                                                         *
  14979. ************************************************************************/
  14980.  
  14981. #include <time.h>
  14982. #include <stdio.h>
  14983. #define RUNS 1000
  14984. #define SIZE 10000
  14985. int mark[SIZE];
  14986. int main(void)
  14987. {
  14988.    time_t start, finish;
  14989.    int i, loop, n, num;
  14990.    time(&start);
  14991.    /*  This loop finds the prime numbers between 2 and SIZE   */
  14992.    for (loop = 0; loop < RUNS; ++loop)
  14993.       {
  14994.       for (n = 0; n < SIZE; ++n)
  14995.          mark [n] = 0;
  14996.       /*  This loops marks all the composite numbers with -1  */
  14997.       for (num = 0, n = 2; n < SIZE; ++n)
  14998.          if ( ! mark[n]) {
  14999.             for (i = 2 * n; i < SIZE; i += n)
  15000.                 mark[i] = -1;
  15001.             ++num;
  15002.             }
  15003.       }
  15004.    time(&finish);
  15005.    printf("\nProgram takes an average of %f seconds to find %d primes.\n",
  15006.       difftime(finish,start)/RUNS,num);
  15007. }
  15008.  
  15009. /************************************************************************
  15010. *
  15011.  
  15012. /********************  Output should be similar:  *****************
  15013. The program takes an average of 0.106000 seconds to find 1229 primes.
  15014. */
  15015.  
  15016.                                                                         *
  15017. ************************************************************************/
  15018.  
  15019.  
  15020. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15021.  
  15022. /************************************************************************
  15023. *
  15024.  
  15025.  
  15026. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15027.  
  15028. #include <stdlib.h>
  15029. #include <stdio.h>
  15030. int main(void)
  15031. {
  15032.    int num[2] = {45,-45};
  15033.    int den[2] = {7,-7};
  15034.    div_t ans;   /* div_t is a struct type containing two ints:
  15035.                    'quot' stores quotient; 'rem' stores remainder */
  15036.    short i,j;
  15037.    printf("Results of division:\n");
  15038.    for (i = 0; i < 2; i++)
  15039.       for (j = 0; j < 2; j++) {
  15040.          ans = div(num[i],den[j]);
  15041.          printf("Dividend: %6ld  Divisor: %6ld", num[i], den[j]);
  15042.          printf("  Quotient: %6ld  Remainder: %6ld\n", ans.quot, ans.rem);
  15043.       }
  15044. }
  15045.  
  15046. /************************************************************************
  15047. *
  15048.  
  15049. /*****************  Output should be similar to:  *****************
  15050. Results of division:
  15051. Dividend:  45  Divisor:   7  Quotient:   6  Remainder:   3
  15052. Dividend:  45  Divisor:  -7  Quotient:  -6  Remainder:   3
  15053. Dividend: -45  Divisor:   7  Quotient:  -6  Remainder:  -3
  15054. Dividend: -45  Divisor:  -7  Quotient:   6  Remainder:  -3
  15055. */ 
  15056.  
  15057.                                                                         *
  15058. ************************************************************************/
  15059.  
  15060.  
  15061. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15062.  
  15063. /************************************************************************
  15064. *
  15065. The following example allocates three memory blocks, and then calls 
  15066. _dump_allocated to dump information and the first 8 bytes for each memory 
  15067. block. 
  15068.  
  15069.                                                                         *
  15070. ************************************************************************/
  15071.  
  15072. rules=none.
  15073.  
  15074. #ifndef __DEBUG_ALLOC__     /* this macro could also be defined */
  15075.    #define __DEBUG_ALLOC__  /*      from the command line       */
  15076. #endif
  15077. #include <stdlib.h>
  15078. #include <string.h>
  15079. #include <stdio.h>
  15080. #define INIT_STR     "It\0works"
  15081. #define INIT_STR_LEN (sizeof(INIT_STR) - 1)
  15082. int main(void)
  15083. {
  15084.    char *pBlock1;
  15085.    char *pBlock2;
  15086.    char *pBlock3;
  15087.    if (( pBlock1 = malloc(35) ) == NULL)    /* allocate first memory block */
  15088.    {
  15089.       printf( "Could not allocate first memory block.\n" );
  15090.       return EXIT_FAILURE;
  15091.    }
  15092.    memcpy(pBlock1, INIT_STR, INIT_STR_LEN);    /* initialize first memory block */
  15093.    if (( pBlock2 = calloc(2, 120) ) == NULL)   /* allocate second memory block */
  15094.    {
  15095.       printf( "Could not allocate second memory block.\n" );
  15096.       return EXIT_FAILURE;
  15097.    }
  15098.    memcpy(pBlock2, INIT_STR, INIT_STR_LEN);    /* initialize second memory block */
  15099.    if (( pBlock3 = realloc(NULL, 2235) ) == NULL) /* allocate third memory block */
  15100.    {
  15101.       printf( "Could not allocate third memory block.\n" );
  15102.       return EXIT_FAILURE;
  15103.    }
  15104.    memcpy(pBlock3, INIT_STR, INIT_STR_LEN);    /* initialize third memory block */
  15105.    if (( pBlock3 = realloc(pBlock3, 300) ) == NULL) /* reallocate third memory block */
  15106.                                                     /*      to different size        */
  15107.    {
  15108.       printf("Could not reallocate third memory block.\n");
  15109.       return EXIT_FAILURE;
  15110.    }
  15111.    _dump_allocated(8);   /* show first eight bytes of each memory block */
  15112.    return 0;
  15113.    /* Possible output is:
  15114.  ===============================================================================
  15115.                   START OF DUMP OF ALLOCATED MEMORY BLOCKS
  15116.  ===============================================================================
  15117.  Address: 0x00180010      Size: 0x0000012C (300)
  15118.  This memory block was (re)allocated at line number 41 in TDMPAL.C.
  15119.  Memory contents:  49740077 6F726B73                      {It.works        }
  15120.  ===============================================================================
  15121.  Address: 0x00170010      Size: 0x000000F0 (240)
  15122.  This memory block was (re)allocated at line number 25 in TDMPAL.C.
  15123.  Memory contents:  49740077 6F726B73                      {It.works        }
  15124.  ===============================================================================
  15125.  Address: 0x00150010      Size: 0x00000023 (35)
  15126.  This memory block was (re)allocated at line number 17 in TDMPAL.C.
  15127.  Memory contents:  49740077 6F726B73                      {It.works        }
  15128.  ===============================================================================
  15129.                   END OF DUMP OF ALLOCATED MEMORY BLOCKS
  15130.  ===============================================================================
  15131.                                                                        */
  15132. }
  15133.  
  15134.  
  15135. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15136.  
  15137. /************************************************************************
  15138. *
  15139.  
  15140. The following program makes a second file handle, fh3, refer to the same file 
  15141. as the file handle fh1 using DUP. The file handle fh2 is then associated with 
  15142. the file edopen.da2, and finally fh2 is forced to associate with edopen.da1 by 
  15143. the _dup2 function. 
  15144.  
  15145.                                                                         *
  15146. ************************************************************************/
  15147.  
  15148. #include <io.h>
  15149. #include <stdio.h>
  15150. #include <fcntl.h>
  15151. #include <sys\stat.h>
  15152. int main(void)
  15153. {
  15154.    int fh1, fh2, fh3;
  15155.    if ( -1 == (fh1 = _open("edopen.da1", O_CREAT | O_TRUNC | O_RDWR ,
  15156.    S_IREAD | S_IWRITE))) {
  15157.       perror("Unable to open edopen.da1");
  15158.       return 1;
  15159.    }
  15160.    /* fh3 refers to the sample file as fh1 */
  15161.    if (-1 == (fh3 = _dup(fh1))) {
  15162.       perror("Unable to dup");
  15163.       _close(fh1);
  15164.       return 1;
  15165.    }
  15166.    else
  15167.       printf("Successfully performed dup handle.\n");
  15168.    if ( -1 == (fh2 = _open("edopen.da2", O_CREAT | O_TRUNC | O_RDWR ,
  15169.    S_IREAD | S_IWRITE))) {
  15170.       perror("Unable to open edopen.da2");
  15171.       _close(fh1);
  15172.       _close(fh3);
  15173.       return 1;
  15174.    }
  15175.  
  15176.    if (-1 == _dup2(fh1,fh2))  /* Force fh2 to the refer to the same file */
  15177.    {                         /* as fh1.                                 */
  15178.       perror("Unable to dup2");
  15179.    }
  15180.    else
  15181.       printf("Successfully performed dup2 handle.\n");
  15182.    _close(fh1);
  15183.    _close(fh2);
  15184.    _close(fh3);
  15185.    return 0;
  15186. /******************  The expected output is:  ***************************
  15187.       Successfully performed dup handle.
  15188.       Successfully performed dup2 handle.
  15189. */
  15190. }
  15191.  
  15192.  
  15193. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15194.  
  15195. /************************************************************************
  15196. *
  15197. This example reads in two floating-point numbers, computes their product, and 
  15198. prints out only the billions digit of its character representation. At most, 16 
  15199. decimal digits of significance can be expected. The output assumes the user 
  15200. enters the numbers 1000000 and 3000. 
  15201.  
  15202.                                                                         *
  15203. ************************************************************************/
  15204.  
  15205.  
  15206. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15207.  
  15208. /************************************************************************
  15209. *
  15210.  
  15211.                                                                         *
  15212. ************************************************************************/
  15213.  
  15214.  
  15215. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15216.  
  15217. /************************************************************************
  15218. *
  15219.  
  15220. The following program creates the file sample.dat and then checks if the file 
  15221. pointer is at the end of that file using the _eof function: 
  15222.  
  15223.                                                                         *
  15224. ************************************************************************/
  15225.  
  15226. #include <sys\stat.h>
  15227. #include <io.h>
  15228. #include <stdio.h>
  15229. int main(void)
  15230. {
  15231.    int fh, returnValue;
  15232.    fh = _creat("sample.dat", S_IREAD | S_IWRITE);
  15233.    if ( -1 == fh)
  15234.    {
  15235.       perror("Error creating sample.dat");
  15236.       return 1;
  15237.    }
  15238.    if ( -1 == (returnValue = _eof(fh)))
  15239.    {
  15240.       perror("eof function error");
  15241.       return 1;
  15242.    }
  15243.    if (returnValue == 1)
  15244.       printf("File pointer is at end-of-file position.\n");
  15245.    else
  15246.       printf("File pointer is not at end-of-file position.\n");
  15247.    _close(fh);
  15248.    return 0;
  15249. /****************  The expected output is:  *****************************
  15250.       File pointer is at end-of-file position.
  15251. */
  15252. }
  15253.  
  15254.  
  15255. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15256.  
  15257. /************************************************************************
  15258. *
  15259. In the following example, the main program creates two threads, bonjour and 
  15260. au_revoir. The thread bonjour is forcibly terminated by a call to _endthread, 
  15261. while the au_revoir thread ends itself with an implicit call to _endthread. 
  15262.  
  15263. Note:  To run this example, you must compile it using the /Gm+ compile-time 
  15264. option. 
  15265.  
  15266.                                                                         *
  15267. ************************************************************************/
  15268.  
  15269. #define INCL_DOS
  15270. #include <os2.h>
  15271. #include <stdio.h>
  15272. #include <stdlib.h>
  15273. #include <process.h>
  15274. void bonjour(void *arg)
  15275. {
  15276.    int i = 0;
  15277.    while ( i++ < 5 )
  15278.       printf("Bonjour!\n");
  15279.    _endthread();              /* This thread ends itself explicitly */
  15280.    puts("thread should terminate before printing this");
  15281. }
  15282. void au_revoir(void *arg)
  15283. {
  15284.    int i = 0;
  15285.    while ( i++ < 5 )           /* This thread makes an implicit */
  15286.       printf("Au revoir!\n");  /* call to _endthread            */
  15287. }
  15288. int main(void)
  15289. {
  15290.    unsigned long tid1;
  15291.    unsigned long tid2;
  15292.    tid1 = _beginthread(bonjour, NULL, 8192, NULL);
  15293.    tid2 = _beginthread(au_revoir, NULL, 8192, NULL);
  15294.    if ( (tid1 == -1) || (tid2 == -1) )
  15295.    {
  15296.       printf("Unable to start threads.\n");
  15297.       exit(-1);
  15298.    }
  15299.    DosWaitThread( &tid2, DCWW_WAIT );   /*  wait until threads 1 and 2  */
  15300.    DosWaitThread( &tid1, DCWW_WAIT );   /*  have been completed         */
  15301.    return 0;
  15302.    /* Possible output could be:
  15303.       Bonjour!
  15304.       Au revoir!
  15305.       Bonjour!
  15306.       Au revoir!
  15307.       Bonjour!
  15308.       Au revoir!
  15309.       Bonjour!
  15310.       Au revoir!
  15311.       Bonjour!
  15312.       Au revoir!           */
  15313. }
  15314.  
  15315.  
  15316. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15317.  
  15318. #include <stdio.h>
  15319. #include <math.h>
  15320. double smallx, largex, value;
  15321. int main(void)
  15322. {
  15323.    smallx = 0.1;
  15324.    largex = 10.0;
  15325.    value = erf(smallx);         /* value = 0.112463 */
  15326.    printf("Error value for 0.1: %lf\n", value);
  15327.    value = erfc(largex);        /* value = 2.088488e-45 */
  15328.    printf("Error value for 10.0: %le\n", value);
  15329. }
  15330.  
  15331. /************************************************************************
  15332. *
  15333.  
  15334. /*****************  Output should be similar to:  *****************
  15335. Error value for 0.1: 0.112463
  15336. Error value for 10.0: 2.088488e-45
  15337. */
  15338.  
  15339.                                                                         *
  15340. ************************************************************************/
  15341.  
  15342.  
  15343. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15344.  
  15345. /************************************************************************
  15346. *
  15347. The following program calls four of the eight _exec routines.  When invoked 
  15348. without arguments, the program first runs the code for case PARENT.  It then 
  15349. calls _execle() to load and run a copy of itself.  The instructions for the 
  15350. child are blocked to run only if argv[0] and one parameter were passed (case 
  15351. CHILD).  In its turn, the child runs its own child as a copy of the same 
  15352. program.  This sequence is continued until four generations of child processes 
  15353. have run.  Each of the processes prints a message identifying itself. 
  15354.  
  15355.                                                                         *
  15356. ************************************************************************/
  15357.  
  15358. #include <stdio.h>
  15359. #include <stdlib.h>
  15360. #include <process.h>
  15361. #define  PARENT       1
  15362. #define  CHILD        2
  15363. char *args[3];
  15364. int main(int argc, char **argv, char **envp)
  15365. {
  15366.     switch(argc)
  15367.     {
  15368.         case PARENT:      /* No argument: run a child */
  15369.         {
  15370.             printf("Parent process began.\n");
  15371.             _execle(argv[0],argv[0],"1",NULL,envp);
  15372.             abort();  /* Not executed because parent was overlaid. */
  15373.         }
  15374.         case CHILD:       /* One argument: run a child's child */
  15375.         {
  15376.             printf("Child process %s began.\n", argv[1]);
  15377.             if('1'==*argv[1])     /* generation one */
  15378.             {
  15379.                 _execl(argv[0],argv[0],"2",NULL);
  15380.                 abort();  /* Not executed because child was overlaid */
  15381.             }
  15382.  
  15383.             if('2'==*argv[1])     /* generation two */
  15384.             {
  15385.                 args[0]=argv[0];
  15386.                 args[1]="3";
  15387.                 args[2]=NULL;
  15388.                 _execv(argv[0],args);
  15389.                 abort();  /* Not executed because child was overlaid */
  15390.             }
  15391.             if('3'==*argv[1])     /* generation three */
  15392.             {
  15393.                 args[0]=argv[0];
  15394.                 args[1]="4";
  15395.                 args[2]=NULL;
  15396.                 _execve(argv[0],args,_environ);
  15397.                 abort();    /* Not executed because child was overlaid */
  15398.             }
  15399.             if('4'==*argv[1])     /* generation four */
  15400.                 printf("Child process %s", argv[1]);
  15401.         }
  15402.     }
  15403.     printf(" ended.\n");
  15404.     _exit(0);
  15405.     return 0;
  15406. /***************** The output should be similar to:  ********************
  15407.    Parent process began.
  15408.    Child process 1 began.
  15409.    Child process 2 began.
  15410.    Child process 3 began.
  15411.    Child process 4 began.
  15412.    Child process 4 ended.
  15413. */
  15414. }
  15415.  
  15416.  
  15417. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15418.  
  15419. /***********************************************************************
  15420. *
  15421. The following example ends the program after flushing buffers and closing any 
  15422. open files if it cannot open the file myfile. 
  15423.  
  15424.                                                                        *
  15425. ***********************************************************************/
  15426.  
  15427. #include <stdio.h>
  15428. #include <stdlib.h>
  15429. FILE *stream;
  15430. int main(void)
  15431. {
  15432.    .
  15433.    .
  15434.    .
  15435.    if ((stream = fopen("myfile.dat", "r")) == NULL) {
  15436.       perror("Could not open data file");
  15437.       exit(EXIT_FAILURE);
  15438.       }
  15439. }
  15440.  
  15441.  
  15442. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15443.  
  15444. /************************************************************************
  15445. *
  15446. The following program calls _exit to end the process. Because _exit does not 
  15447. flush the buffer first, the output from the second printf statement will not 
  15448. appear. 
  15449.  
  15450.                                                                         *
  15451. ************************************************************************/
  15452.  
  15453. #include <stdio.h>
  15454. #include <stdlib.h>   /* You can also use <process.h> */
  15455. char buf[51];
  15456. int main(void)
  15457. {
  15458.    /* Make sure the standard output stream is line-buffered even if the       */
  15459.    /* output is redirected to a file.            */
  15460.    if (setvbuf( stdout, buf, _IOLBF, 50 ) != 0)
  15461.       printf("The buffering was not set correctly.\n");
  15462.    printf( "This will print out but ...\n" );
  15463.    printf( "this will not!" );
  15464.    _exit( 1 );
  15465.     return 0;
  15466. /******************  The output should be similar to:  ******************
  15467.    This will print out but ...
  15468. */
  15469. }
  15470.  
  15471.  
  15472. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15473.  
  15474. /***********************************************************************
  15475. *
  15476. The following example calculates y as the exponential function of x: 
  15477.  
  15478.                                                                        *
  15479. ***********************************************************************/
  15480.  
  15481. #include <math.h>
  15482. int main(void)
  15483. {
  15484.    double x, y;
  15485.    x = 5.0;
  15486.    y = exp(x);
  15487.    printf("exp( %lf ) = %lf\n", x, y);
  15488. }
  15489.  
  15490. /************************************************************************
  15491. *
  15492.  
  15493. /*****************  Output should be similar to:  *****************
  15494. exp( 5.000000 ) = 148.413159
  15495. */
  15496.  
  15497.                                                                         *
  15498. ************************************************************************/
  15499.  
  15500.  
  15501. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15502.  
  15503. /************************************************************************
  15504. *
  15505. This example calculates y as the absolute value of x: 
  15506.  
  15507.                                                                         *
  15508. ************************************************************************/
  15509.  
  15510. #include <math.h>
  15511. int main(void)
  15512. {
  15513.    double x, y;
  15514.    x = -5.6798;
  15515.    y = fabs(x);
  15516.    printf("fabs( %lf ) = %lf\n", x, y);
  15517. }
  15518.  
  15519. /************************************************************************
  15520. *
  15521.  
  15522. /*******************  Output should be similar to:  ***************
  15523. fabs( -5.679800 ) = 5.679800
  15524. */
  15525.  
  15526.                                                                         *
  15527. ************************************************************************/
  15528.  
  15529.  
  15530. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15531.  
  15532. /************************************************************************
  15533. *
  15534.  
  15535.                                                                         *
  15536. ************************************************************************/
  15537.  
  15538.  
  15539. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15540.  
  15541. /************************************************************************
  15542. *
  15543.  
  15544.                                                                         *
  15545. ************************************************************************/
  15546.  
  15547.  
  15548. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15549.  
  15550. /************************************************************************
  15551. *
  15552. The following example opens a file myfile.dat for reading as a stream; then it 
  15553. closes this file. 
  15554.  
  15555.                                                                         *
  15556. ************************************************************************/
  15557.  
  15558. #include <stdio.h>
  15559. int main(void)
  15560. {
  15561.    FILE *stream;
  15562.    stream = fopen("myfile.dat", "r");
  15563.    .
  15564.    .
  15565.    .
  15566.    if (fclose(stream))   /* Close the stream. */
  15567.       perror("fclose error");
  15568. }
  15569.  
  15570.  
  15571. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15572.  
  15573. /************************************************************************
  15574. *
  15575. The following example opens a file john for reading as a data stream, and then 
  15576. closes the file. It closes all other streams except stdin, stdout, and stderr. 
  15577.  
  15578.                                                                         *
  15579. ************************************************************************/
  15580.  
  15581. #include <stdio.h>
  15582. int main(void)
  15583. {
  15584.     FILE *stream;
  15585.     int numclosed;
  15586.     stream = fopen("john", "w");
  15587.     numclosed = _fcloseall();
  15588.     printf("Number of files closed = %d\n", numclosed);
  15589.     return 0;
  15590.     /* The expected output is:
  15591.        Number of files closed = 1    */
  15592. }
  15593.  
  15594.  
  15595. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15596.  
  15597. /************************************************************************
  15598. *
  15599.  
  15600.                                                                         *
  15601. ************************************************************************/
  15602.  
  15603.  
  15604. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15605.  
  15606. /************************************************************************
  15607. *
  15608.  
  15609.                                                                         *
  15610. ************************************************************************/
  15611.  
  15612.  
  15613. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15614.  
  15615. /************************************************************************
  15616. *
  15617. This example reads in two floating-point numbers, computes their product, and 
  15618. prints out only the billions digit of its character representation.  At most, 
  15619. 16 decimal digits of significance can be expected. The output given assumes the 
  15620. user enters the values 2000000 and 3000. 
  15621.  
  15622.                                                                         *
  15623. ************************************************************************/
  15624.  
  15625.  
  15626. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15627.  
  15628. /************************************************************************
  15629. *
  15630.  
  15631. The following program opens the file sample.dat and associates a stream with 
  15632. the file using _fdopen. It then reads from the stream into the buffer. 
  15633.  
  15634.                                                                         *
  15635. ************************************************************************/
  15636.  
  15637. #include <io.h>
  15638. #include <stdio.h>
  15639. #include <stdlib.h>
  15640. #include <fcntl.h>
  15641. #include <string.h>
  15642. int main(void)
  15643. {
  15644.    long length;
  15645.    int  fh;
  15646.    char buffer[20];
  15647.    FILE *fp;
  15648.    memset(buffer,'\0',20); /* Initialize buffer */
  15649.    printf("\nCreating sample.dat.\n");
  15650.    system("echo Sample Program > sample.dat");
  15651.    if (-1 == (fh = _open("sample.dat",O_RDWR | O_APPEND)))
  15652.    {
  15653.       perror("Unable to open sample.dat");
  15654.       return 1;
  15655.       }
  15656.  
  15657.    if (NULL == (fp = _fdopen(fh,"r")))
  15658.    {
  15659.       perror("fdopen failed");
  15660.       _close(fh);
  15661.       return 1;
  15662.       }
  15663.    if ( 7 != fread(buffer,1,7,fp))
  15664.    {
  15665.       perror("fread failed");
  15666.       fclose(fp);
  15667.       return 1;
  15668.    }
  15669.    printf("Successfully read from the stream the following:\n%s\n ",buffer);
  15670.    fclose(fp);
  15671.    return 0;
  15672. /*******************  The expected output is:  **************************
  15673.       Creating sample.dat.
  15674.       Successfully read from the stream the following:
  15675.       Sample
  15676. */
  15677. }
  15678.  
  15679.  
  15680. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15681.  
  15682. /************************************************************************
  15683. *
  15684. The following example scans the input stream until it reads an end-of-file 
  15685. character. 
  15686.  
  15687.                                                                         *
  15688. ************************************************************************/
  15689.  
  15690. #include <stdio.h>
  15691. int main(void)
  15692. {
  15693.    char string[100];
  15694.    FILE *stream;
  15695.    stream = fopen("myfile.dat", "r");
  15696.    .
  15697.    .
  15698.    .
  15699.    /* scan an input stream until an end-of-file character is read */
  15700.    while (!feof(stream))
  15701.       if (fscanf(stream, "%s", string))
  15702.          /* process the string */;
  15703. }
  15704.  
  15705.  
  15706. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15707.  
  15708. /************************************************************************
  15709. *
  15710. The following example puts data out to a stream and then checks that a write 
  15711. error has not occurred. 
  15712.  
  15713.                                                                         *
  15714. ************************************************************************/
  15715.  
  15716. #include <stdio.h>
  15717. int main(void)
  15718. {
  15719.    FILE *stream;
  15720.    char *string = "Important information";
  15721.    stream = fopen("myfile.dat","w");
  15722.    fprintf(stream, "%s\n", string);
  15723.    if (ferror(stream))
  15724.    {
  15725.       printf("write error\n");
  15726.       clearerr(stream);
  15727.    }
  15728.    if (fclose(stream))
  15729.       perror("fclose error");
  15730. }
  15731.  
  15732.  
  15733. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15734.  
  15735. /************************************************************************
  15736. *
  15737. The following statements flush a stream buffer. 
  15738.  
  15739.                                                                         *
  15740. ************************************************************************/
  15741.  
  15742. #include <stdio.h>
  15743. int main(void)
  15744. {
  15745.    FILE *stream;
  15746.    stream = fopen("myfile.dat", "w");
  15747.    .
  15748.    .
  15749.    .
  15750.    fflush(stream);
  15751. }
  15752.  
  15753.  
  15754. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15755.  
  15756. /************************************************************************
  15757. *
  15758. The following example gathers a line of input from a stream. 
  15759.  
  15760.                                                                         *
  15761. ************************************************************************/
  15762.  
  15763. #include <stdio.h>
  15764. #define  MAX_LEN  80
  15765. int main(void)
  15766. {
  15767.    FILE *stream;
  15768.    char buffer[MAX_LEN + 1];
  15769.    int i, ch;
  15770.    stream = fopen("myfile.dat","r");
  15771.    for (i = 0; (i < (sizeof(buffer)-1) &&
  15772.          ((ch = fgetc(stream)) != EOF) && (ch != '\n')); i++)
  15773.       buffer[i] = ch;
  15774.    buffer[i] = '\0';
  15775.    if (fclose(stream))
  15776.       perror("fclose error");
  15777. }
  15778.  
  15779.  
  15780. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15781.  
  15782. /************************************************************************
  15783. *
  15784. The following program gathers a line of input from stdin using _fgetchar: 
  15785.  
  15786.                                                                         *
  15787. ************************************************************************/
  15788.  
  15789. #include <stdio.h>
  15790. int main(void)
  15791. {
  15792.     char buffer[81];
  15793.     int i, ch;
  15794.     printf("Please input a line of characters...\n");
  15795.     for (i=0; (i<80) && ((ch = _fgetchar()) != EOF) && (ch!='\n'); i++)
  15796.         buffer[i] = ch;
  15797.     buffer[i] = '\0';
  15798.     printf("The input line was : %s\n", buffer);
  15799.     return 0;
  15800. /***********  If the input was "A line of characters.", then  *********
  15801. **************    the output should be similar to:  *******************
  15802.    Please input a line of characters...
  15803.    A line of characters.
  15804.    The input line was : A line of characters.
  15805. */
  15806. }
  15807.  
  15808.  
  15809. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15810.  
  15811. /************************************************************************
  15812. *
  15813. The following example opens the file myfile.dat for reading.  The current file 
  15814. pointer position is stored into the variable pos. 
  15815.  
  15816.                                                                         *
  15817. ************************************************************************/
  15818.  
  15819. #include <stdio.h>
  15820. FILE *stream;
  15821. int main(void)
  15822. {
  15823.    int retcode;
  15824.    fpos_t pos;
  15825.    stream = fopen("myfile.dat", "rb");
  15826.    /* The value returned by fgetpos can be used by fsetpos */
  15827.    /* to set the file pointer if 'retcode' is 0            */
  15828.    if ((retcode = fgetpos(stream, &pos)) == 0)
  15829.       printf("Current position of file pointer found\n");
  15830.    fclose(stream);
  15831. }
  15832.  
  15833.  
  15834. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15835.  
  15836. /************************************************************************
  15837. *
  15838. The following example gets a line of input from a data stream.  The example 
  15839. reads no more than MAX_LEN - 1 characters, or up to a newline character, from 
  15840. the stream. 
  15841.  
  15842.                                                                         *
  15843. ************************************************************************/
  15844.  
  15845. #include <stdio.h>
  15846. #define  MAX_LEN  100
  15847. int main(void)
  15848. {
  15849.    FILE *stream;
  15850.    char line[MAX_LEN], *result;
  15851.    stream = fopen("myfile.dat","rb");
  15852.    if ((result = fgets(line,MAX_LEN,stream)) != NULL)
  15853.        printf("The string is %s\n", result);
  15854.    if (fclose(stream))
  15855.        perror("fclose error");
  15856. }
  15857.  
  15858.  
  15859. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15860.  
  15861. /************************************************************************
  15862. *
  15863.  
  15864. After opening a file, the following program tries to determine the current 
  15865. length of the file using _filelength. 
  15866.  
  15867.                                                                         *
  15868. ************************************************************************/
  15869.  
  15870. #include <io.h>
  15871. #include <stdio.h>
  15872. #include <stdlib.h>
  15873. #include <fcntl.h>
  15874. int main(void)
  15875. {
  15876.    long length;
  15877.    int  fh;
  15878.    printf("\nCreating sample.dat.\n");
  15879.    system("echo Sample Program > sample.dat");
  15880.    if (-1 == (fh = _open("sample.dat",O_RDWR | O_APPEND)))
  15881.    {
  15882.       printf("Unable to open sample.dat.\n");
  15883.       return 1;
  15884.    }
  15885.    if (-1 == (length = _filelength(fh)))
  15886.    {
  15887.       printf("Unable to determine length of sample.dat.\n");
  15888.       return 1;
  15889.    }
  15890.    printf("Current length of sample.dat is %d.\n",length);
  15891.    _close(fh);
  15892.    return 0;
  15893. /****************  The expected output is:  *****************************
  15894.       Creating sample.dat.
  15895.       Current length of sample.dat is 17.
  15896. */
  15897. }
  15898.  
  15899.  
  15900. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15901.  
  15902. /************************************************************************
  15903. *
  15904. The following program determines the file handle of the stderr data stream: 
  15905.  
  15906.                                                                         *
  15907. ************************************************************************/
  15908.  
  15909. #include <stdio.h>
  15910. int main(void)
  15911. {
  15912.     int result;
  15913.     result = 0xFFFF & _fileno(stderr);
  15914.     printf("The file handle associated with stderr is %d.\n", result);
  15915.     return 0;
  15916. /*******************  The output should be similar to:  *****************
  15917.    The file handle associated with stderr is 2.
  15918. */
  15919. }
  15920.  
  15921.  
  15922. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15923.  
  15924. /************************************************************************
  15925. *
  15926. This example assigns y value of the largest integer less than or equal to 2.8 
  15927. and z the value of the largest integer less than or equal to -2.8. 
  15928.  
  15929.                                                                         *
  15930. ************************************************************************/
  15931.  
  15932. #include <math.h>
  15933. int main(void)
  15934. {
  15935.    double y, z;
  15936.    y = floor(2.8);
  15937.    z = floor(-2.8);
  15938.    printf("floor(  2.8 ) = %lf\n", y);
  15939.    printf("floor( -2.8 ) = %lf\n", z);
  15940. }
  15941.  
  15942. /************************************************************************
  15943. *
  15944.  
  15945. /*******************  Output should be similar to:  ***************
  15946. floor(  2.8 ) = 2.000000
  15947. floor( -2.8 ) = -3.000000
  15948. */
  15949.  
  15950.                                                                         *
  15951. ************************************************************************/
  15952.  
  15953.  
  15954. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15955.  
  15956. /************************************************************************
  15957. *
  15958. In this program, _flushall completes any pending input or output on all streams 
  15959. by flushing all buffers: 
  15960.  
  15961.                                                                         *
  15962. ************************************************************************/
  15963.  
  15964. #include <stdio.h>
  15965. int main(void)
  15966. {
  15967.     int i,numflushed;
  15968.     char buffer1[5] = {1,2,3,4};
  15969.     char buffer2[5] = {5,6,7,8};
  15970.     char *file1 = "file1.dat";
  15971.     char *file2 = "file2.dat";
  15972.     FILE *stream1, *stream2;
  15973.     stream1 = fopen(file1,"a+");
  15974.     stream2 = fopen(file2,"a+");
  15975.     for(i = 0; i <= sizeof(buffer1); i++)
  15976.     {
  15977.          fputc(buffer1[i], stream1);
  15978.          fputc(buffer2[i], stream2);
  15979.     };
  15980.     numflushed = _flushall();       /*  all streams flushed  */
  15981.     printf("Number of files flushed = %d\n", numflushed);
  15982.     fclose(stream1);
  15983.     fclose(stream2);
  15984.     return 0;
  15985. /*******************  The output should be similar to:  *****************
  15986.    Number of files flushed = 5
  15987. */
  15988. }
  15989.  
  15990.  
  15991. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  15992.  
  15993. /************************************************************************
  15994. *
  15995. The following example computes z as the remainder of x/y; here x/y is -3 with a 
  15996. remainder of -1: 
  15997.  
  15998.                                                                         *
  15999. ************************************************************************/
  16000.  
  16001. #include <math.h>
  16002. int main(void)
  16003. {
  16004.    double x, y, z;
  16005.    x = -10.0;
  16006.    y = 3.0;
  16007.    z = fmod(x,y);      /* z = -1.0 */
  16008.    printf("fmod( %lf, %lf) = %lf\n", x, y, z);
  16009. }
  16010.  
  16011. /************************************************************************
  16012. *
  16013.  
  16014. /*******************  Output should be similar to:  ***************
  16015. fmod( -10.000000, 3.000000) = -1.000000
  16016. */
  16017.  
  16018.                                                                         *
  16019. ************************************************************************/
  16020.  
  16021.  
  16022. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16023.  
  16024. /************************************************************************
  16025. *
  16026. The following statements attempt to open a file for reading: 
  16027.  
  16028.                                                                         *
  16029. ************************************************************************/
  16030.  
  16031. #include <stdio.h>
  16032. int main(void)
  16033. {
  16034.    FILE *stream;
  16035.    if ((stream = fopen("myfile.dat", "r")) == NULL)
  16036.       printf("Could not open data file\n");
  16037.    /* The following call opens a fixed record length file */
  16038.    /* for reading and writing.      */
  16039.    stream = fopen("myfile.dat", "rb+, lrecl=80,  \
  16040.                blksize=240, recfm=f");
  16041. }
  16042.  
  16043.  
  16044. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16045.  
  16046. /************************************************************************
  16047. *
  16048.  
  16049.                                                                         *
  16050. ************************************************************************/
  16051.  
  16052.  
  16053. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16054.  
  16055. /************************************************************************
  16056. *
  16057. The following example establishes the function fphandler as a floating-point 
  16058. error handler. The main program produces a floating-point error, which causes 
  16059. control to be passed to fphandler. The fphandler function calls _fpreset to 
  16060. reset the floating-point unit, and then returns to main. 
  16061.  
  16062.                                                                         *
  16063. ************************************************************************/
  16064.  
  16065. #include <stdio.h>
  16066. #include <signal.h>
  16067. #include <setjmp.h>
  16068. #include <float.h>
  16069. jmp_buf mark;
  16070. void fphandler(int sig)
  16071. {
  16072.     printf("Floating point signal = %d\n", sig);
  16073.     _fpreset();     /* Reinitialize floating-point package */
  16074.     longjmp(mark, -1);
  16075. }
  16076. int main(void)
  16077. {
  16078.     double a = 1.0, b = 0.0, c;
  16079.     if (signal(SIGFPE, fphandler) == SIG_ERR)
  16080.         exit(-1);
  16081.     if (setjmp(mark) == 0)
  16082.     {
  16083.         c = a / b;             /* generate floating-point error */
  16084.         printf("Should never get here\n");
  16085.     }
  16086.     printf("Recovered from floating-point error\n");
  16087.     return 0;
  16088.     /* The expected output is:
  16089.        Floating point signal = 3
  16090.        Recovered from floating-point error  */
  16091. }
  16092.  
  16093.  
  16094. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16095.  
  16096. /************************************************************************
  16097. *
  16098. This example sends a line of asterisks for each integer in the array count to 
  16099. the file myfile.dat.  The number of asterisks printed on each line corresponds 
  16100. to an integer in the array. 
  16101.  
  16102.                                                                         *
  16103. ************************************************************************/
  16104.  
  16105. #include <stdio.h>
  16106. int count [10] = {1, 5, 8, 3, 0, 3, 5, 6, 8, 10};
  16107. int main(void)
  16108. {
  16109.    int i,j;
  16110.    FILE *stream;
  16111.    stream = fopen("myfile.dat", "w");
  16112.                   /* Open the stream for writing */
  16113.    for (i=0; i < sizeof(count) / sizeof(count[0]); i++)
  16114.    {
  16115.       for (j = 0; j < count[i]; j++)
  16116.          fprintf(stream,"*");
  16117.                   /* Print asterisk */
  16118.          fprintf(stream,"\n");
  16119.                   /* Move to the next line */
  16120.    }
  16121.    fclose (stream);
  16122. }
  16123.  
  16124. /************************************************************************
  16125. *
  16126.  
  16127. /*******************  Output should be similar to:  ***************
  16128. *
  16129. *****
  16130. ********
  16131. ***
  16132. ***
  16133. *****
  16134. ******
  16135. ********
  16136. **********
  16137. */
  16138.  
  16139.                                                                         *
  16140. ************************************************************************/
  16141.  
  16142.  
  16143. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16144.  
  16145. /************************************************************************
  16146. *
  16147.  
  16148.                                                                         *
  16149. ************************************************************************/
  16150.  
  16151.  
  16152. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16153.  
  16154. /************************************************************************
  16155. *
  16156. The following example writes the contents of buffer to a file called 
  16157. myfile.dat. 
  16158.  
  16159. Note:  Because the output occurs as a side effect within the second expression 
  16160. of the for statement,  the statement body is null. 
  16161.  
  16162.                                                                         *
  16163. ************************************************************************/
  16164.  
  16165. #include <stdio.h>
  16166. #define NUM_ALPHA  26
  16167. int main(void) {
  16168.   FILE * stream;
  16169.   int i;
  16170.   int ch;
  16171.   /* Don't forget the NULL char at the end of the string! */
  16172.   char buffer[NUM_ALPHA + 1] = "abcdefghijklmnopqrstuvwxyz";
  16173.   if (( stream = fopen("myfile.dat", "w"))!= NULL ) {
  16174.     /* Put buffer into file */
  16175.     for ( i = 0; ( i < sizeof(buffer) ) &&
  16176.            ((ch = fputc( buffer[i], stream)) != EOF ); ++i );
  16177.     fclose( stream );
  16178.   }
  16179.   else
  16180.     perror( "Error opening myfile.dat" );
  16181. }
  16182.  
  16183.  
  16184. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16185.  
  16186. /************************************************************************
  16187. *
  16188. The following program writes the contents of buffer to stdout: 
  16189.  
  16190.                                                                         *
  16191. ************************************************************************/
  16192.  
  16193. #include <stdio.h>
  16194. int main(void)
  16195. {
  16196.     char buffer[80];
  16197.     int i, ch = 1;
  16198.     for (i=0; i<80; i++)
  16199.         buffer[i] = 'c';
  16200.     for (i=0; (i<80) && (ch!=EOF); i++)
  16201.         ch = _fputchar(buffer[i]);
  16202.     printf("\n");
  16203.     return 0;
  16204. /************************  The output should be similar to:  *************
  16205.   ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
  16206. */
  16207. }
  16208.  
  16209.  
  16210. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16211.  
  16212. /************************************************************************
  16213. *
  16214. The following example writes a string to a stream. 
  16215.  
  16216.                                                                         *
  16217. ************************************************************************/
  16218.  
  16219. #include <stdio.h>
  16220. #define NUM_ALPHA  26
  16221. int main(void) {
  16222.   FILE * stream;
  16223.   int num;
  16224.   /* Do not forget that the '\0' char occupies one character */
  16225.   static char buffer[NUM_ALPHA + 1] = "abcdefghijklmnopqrstuvwxyz";
  16226.   if ((stream = fopen("myfile.dat", "w")) != NULL ) {
  16227.      /* Put buffer into file */
  16228.      if ( (num = fputs( buffer, stream )) != EOF ) {
  16229.        /* Note that fputs() does not copy the \0 character */
  16230.        printf( "Total number of characters written to file = %i\n", num );
  16231.        fclose( stream );
  16232.      }
  16233.      else   /* fputs failed */
  16234.        perror( "fputs failed" );
  16235.   }
  16236.   else
  16237.      perror( "Error opening myfile.dat" );
  16238. }
  16239.  
  16240.  
  16241. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16242.  
  16243. /************************************************************************
  16244. *
  16245. The following example attempts to read NUM_ALPHA characters from the file 
  16246. myfile.dat. If there are any errors with either fread or fopen, a message is 
  16247. printed. 
  16248.  
  16249.                                                                         *
  16250. ************************************************************************/
  16251.  
  16252. #include <stdio.h>
  16253. #define NUM_ALPHA  26
  16254. int main(void) {
  16255.   FILE * stream;
  16256.   int num;       /* number of characters read from stream */
  16257.   /* Do not forget that the '\0' char occupies one character too! */
  16258.   char buffer[NUM_ALPHA + 1];
  16259.   if (( stream = fopen("myfile.dat", "r"))!= NULL ) {
  16260.     num = fread( buffer, sizeof( char ), NUM_ALPHA, stream );
  16261.     if ( num ) {  /* fread success */
  16262.       printf( "Number of characters has been read = %i\n", num );
  16263.       printf( "buffer = %s\n", buffer );
  16264.       fclose( stream );
  16265.     }
  16266.     else {  /* fread failed */
  16267.       if ( ferror(stream) )    /* possibility 1 */
  16268.         perror( "Error reading myfile.dat" );
  16269.       else if ( feof(stream))  /* possibility 2 */
  16270.         perror( "EOF found" );
  16271.     }
  16272.   }
  16273.   else
  16274.     perror( "Error opening myfile.dat" );
  16275. }
  16276.  
  16277.  
  16278. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16279.  
  16280. /************************************************************************
  16281. *
  16282. The following example uses calloc to allocate storage for x array elements and 
  16283. then frees them. 
  16284.  
  16285.                                                                         *
  16286. ************************************************************************/
  16287.  
  16288. #include <stdio.h>
  16289. #include <stdlib.h>
  16290. int main(void) {
  16291.   long * array;    /* start of the array */
  16292.   long * index;    /* index variable     */
  16293.   int    i;        /* index variable     */
  16294.   int  num;        /* number of entries of the array */
  16295.   printf( "Enter the size of the array\n" );
  16296.   scanf( "%i", &num );
  16297.   /* allocate num entries */
  16298.   if ( (index = array = calloc( num, sizeof( long ))) != NULL )  {
  16299.     .
  16300.     .  /*  do something with the array  */
  16301.     .
  16302.     free( array );                        /* deallocates array  */
  16303.   }
  16304.   else { /* Out of storage */
  16305.     perror( "Error: out of storage" );
  16306.     abort();
  16307.   }
  16308. }
  16309.  
  16310.  
  16311. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16312.  
  16313. /************************************************************************
  16314. *
  16315. The following example loads the DLL mark with _loadmod, and uses the OS/2 
  16316. function DosQueryProcAddr to get the address of the function dor from within 
  16317. the DLL. It then calls that function, which multiplies two integers passed to 
  16318. it. When the function and DLL are no longer needed, the program frees the DLL 
  16319. module. The macro INCL_DOS and the types PFN and APIRET are required for the 
  16320. OS/2 call, and are defined by including the <os2.h> header file. 
  16321.  
  16322. Note:  To run this program, you must first create mark.dll. Copy the code for 
  16323.        the PLUS function into a file called mark.c, and the code for the .DEF 
  16324.        file into mark.def.  Eliminate the comments from these two files. 
  16325.        Compile with the command: 
  16326.  
  16327.                  icc /Ge- mark.c mark.def
  16328.        You can then run the example: 
  16329.  
  16330.                                                                         *
  16331. ************************************************************************/
  16332.  
  16333.  
  16334. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16335.  
  16336. /************************************************************************
  16337. *
  16338. The following example closes the stream1 data stream and reassigns its stream 
  16339. pointer: 
  16340.  
  16341.                                                                         *
  16342. ************************************************************************/
  16343.  
  16344. #include <stdio.h>
  16345. int main(void)
  16346. {
  16347.    FILE *stream, *stream1, *stream2;
  16348.    stream = fopen("myfile.dat","r");
  16349.    stream1 = stream;
  16350.    stream2 = freopen("", "w+", stream1);
  16351. }
  16352.  
  16353. /************************************************************************
  16354. *
  16355. Note that stream1 and stream2 will have the same value, but they will not 
  16356. necessarily have the same value as stream. 
  16357.  
  16358.                                                                         *
  16359. ************************************************************************/
  16360.  
  16361.  
  16362. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16363.  
  16364. /************************************************************************
  16365. *
  16366. This example decomposes the floating-point value of x, 16.4, into its mantissa 
  16367. 0.5125, and its exponent 5.  It stores the mantissa in y and the exponent in n. 
  16368.  
  16369.                                                                         *
  16370. ************************************************************************/
  16371.  
  16372. #include <math.h>
  16373. int main(void)
  16374. {
  16375.    double x, m;
  16376.    int n;
  16377.    x = 16.4;
  16378.    m = frexp(x, &n);
  16379.    printf("The mantissa is %lf and the exponent is %d\n", m, n);
  16380. }
  16381.  
  16382. /************************************************************************
  16383. *
  16384.  
  16385. /*******************  Output should be similar to:  ***************
  16386. The mantissa is 0.512500 and the exponent is 5
  16387. */
  16388.  
  16389.                                                                         *
  16390. ************************************************************************/
  16391.  
  16392.  
  16393. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16394.  
  16395. /************************************************************************
  16396. *
  16397. This example opens the file myfile.dat for reading and then scans this file for 
  16398. a string, a long integer value, a character, and a floating-point value. 
  16399.  
  16400.                                                                         *
  16401. ************************************************************************/
  16402.  
  16403. #include <stdio.h>
  16404. #define  MAX_LEN  80
  16405. int main(void)
  16406. {
  16407.    FILE *stream;
  16408.    long l;
  16409.    float fp;
  16410.    char s[MAX_LEN + 1];
  16411.    char c;
  16412.    stream = fopen("myfile.dat", "r");
  16413.    /* Put in various data. */
  16414.    fscanf(stream, "%s", &s[0]);
  16415.    fscanf(stream, "%ld", &l);
  16416.    fscanf(stream, "%c", &c);
  16417.    fscanf(stream, "%f", &fp);
  16418.    printf("string = %s\n", s);
  16419.    printf("long double = %ld\n", l);
  16420.    printf("char = %c\n", c);
  16421.    printf("float = %f\n", fp);
  16422. }
  16423.  
  16424. /************************************************************************
  16425. *
  16426.  
  16427. /***************  If myfile.dat contains  ********************
  16428. ****************abcdefghijklmnopqrstuvwxyz 343.2,  ***********
  16429. **********************  expected output is:  *********************
  16430. string = abcdefghijklmnopqrstuvwxyz
  16431. long double = 343
  16432. char = .
  16433. float = 2.000000
  16434. */
  16435.  
  16436.                                                                         *
  16437. ************************************************************************/
  16438.  
  16439.  
  16440. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16441.  
  16442. /************************************************************************
  16443. *
  16444. The following example opens a file myfile.dat for reading.  After performing 
  16445. input operations (not shown), it moves the file pointer to the beginning of the 
  16446. file. 
  16447.  
  16448.                                                                         *
  16449. ************************************************************************/
  16450.  
  16451. #include <stdio.h>
  16452. int main(void)
  16453. {
  16454.    FILE *stream;
  16455.    int result;
  16456.    stream = fopen("myfile.dat", "r");
  16457.    .
  16458.    .
  16459.    .
  16460.    result = fseek(stream, 0L, SEEK_SET);  /* moves the pointer to the */
  16461.                                           /* beginning of the file    */
  16462. }
  16463.  
  16464.  
  16465. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16466.  
  16467. /************************************************************************
  16468. *
  16469. The following example opens a file myfile.dat for reading.  After performing 
  16470. input operations (not shown), it moves the file pointer to the beginning of the 
  16471. file and rereads the first byte. 
  16472.  
  16473.                                                                          *
  16474. *************************************************************************/
  16475.  
  16476. #include <stdio.h>
  16477. FILE *stream;
  16478. int main(void)
  16479. {
  16480.    int retcode;
  16481.    fpos_t pos, pos1, pos2, pos3;
  16482.    char ptr[20];  /* existing file 'myfile.dat' has 20 byte records */
  16483.    /* Open file, get position of file pointer, and read first record */
  16484.    stream = fopen("myfile.dat", "rb");
  16485.    fgetpos(stream,&pos);
  16486.    pos1 = pos;
  16487.    if (!fread(ptr,sizeof(ptr),1,stream))
  16488.        perror("fread error");
  16489.    /* Perform a number of read operations
  16490.        - the value of 'pos' changes       */
  16491.    .
  16492.    .
  16493.    .
  16494.    /* Re-set pointer to start of file and re-read first record */
  16495.    fsetpos(stream,&pos1);
  16496.    if (!fread(ptr,sizeof(ptr),1,stream))
  16497.        perror("fread error");
  16498.    fclose(stream);
  16499. }
  16500.  
  16501.  
  16502. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16503.  
  16504. /************************************************************************
  16505. *
  16506.  
  16507.                                                                         *
  16508. ************************************************************************/
  16509.  
  16510.  
  16511. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16512.  
  16513. /************************************************************************
  16514. *
  16515.  
  16516.                                                                         *
  16517. ************************************************************************/
  16518.  
  16519.  
  16520. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16521.  
  16522. /************************************************************************
  16523. *
  16524.  
  16525.                                                                         *
  16526. ************************************************************************/
  16527.  
  16528.  
  16529. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16530.  
  16531. /************************************************************************
  16532. *
  16533. This program uses _fstat to report the size of a file named data. 
  16534.  
  16535.                                                                         *
  16536. ************************************************************************/
  16537.  
  16538. #include <time.h>
  16539. #include <sys\types.h>
  16540. #include <sys\stat.h>
  16541. #include <stdio.h>
  16542. int main(void)
  16543. {
  16544.     struct stat buf;
  16545.     FILE *fp;
  16546.     int fh, result;
  16547.     char *buffer = "A line to output";
  16548.     fp = fopen("data", "w+");
  16549.     fprintf(fp, "%s", buffer);
  16550.     fflush(fp);
  16551.     fclose(fp);
  16552.     fp = fopen("data", "r");
  16553.     if (_fstat(_fileno(fp), &buf) == 0)
  16554.     {
  16555.         printf("file size is %ld\n", buf.st_size);
  16556.         printf("time modified is %s\n", ctime(&buf.st_atime));
  16557.     }
  16558.     else
  16559.         printf("Bad file handle\n");
  16560.     fclose(fp);
  16561.     return 0;
  16562. /**************  The output should be similar to:  **********************
  16563.    file size is 16
  16564.    time modified is Tue March 30 16:08:14 1993
  16565. */
  16566. }
  16567.  
  16568.  
  16569. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16570.  
  16571. /************************************************************************
  16572. *
  16573. The following example opens the file myfile.dat for reading. It reads enough 
  16574. characters to fill half of the buffer and prints out the position in the stream 
  16575. and the buffer. 
  16576.  
  16577.                                                                         *
  16578. ************************************************************************/
  16579.  
  16580. #include <stdio.h>
  16581. #define NUM_ALPHA  26
  16582. #define NUM_CHAR    6
  16583. int main(void) {
  16584.   FILE * stream;
  16585.   int i;
  16586.   char ch;
  16587.   char buffer[NUM_ALPHA];
  16588.   long position;
  16589.   if (( stream = fopen("myfile.dat", "r")) != NULL ) {
  16590.     /* read into buffer */
  16591.     for ( i = 0; ( i < NUM_ALPHA/2 ) &&
  16592.            ((buffer[i] = fgetc(stream)) != EOF ); ++i )
  16593.         if (i==NUM_CHAR-1)  /* We want to be able to position the   */
  16594.                             /* file pointer to the character in     */
  16595.                             /* position NUM_CHAR                    */
  16596.            position = ftell(stream);
  16597.     buffer[i] = '\0';
  16598.     fseek (stream, position, SEEK_SET);
  16599.     ch = fgetc (stream);  /* get the character at position NUM_CHAR    */
  16600.     fclose( stream );
  16601.   }
  16602.   else
  16603.     perror( "Error opening myfile.dat" );
  16604. }
  16605.  
  16606.  
  16607. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16608.  
  16609. /************************************************************************
  16610. *
  16611. This program polls the system clock, converts the current time to a character 
  16612. string, prints the string, and saves the time data in the structure timebuffer: 
  16613.  
  16614.                                                                         *
  16615. ************************************************************************/
  16616.  
  16617. #include <sys\types.h>
  16618. #include <sys\timeb.h>
  16619. #include <stdio.h>
  16620. #include <time.h>
  16621. int main(void)
  16622. {
  16623.     struct timeb timebuffer;
  16624.     _ftime(&timebuffer);
  16625.     printf("the time is %s\n", ctime(&(timebuffer.time)));
  16626.     return 0;
  16627. /**************  The output should be similar to:  **********************
  16628.    the time is Tue March 30 16:08:17 1993
  16629. */
  16630. }
  16631.  
  16632.  
  16633. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16634.  
  16635. /************************************************************************
  16636. *
  16637. The following example uses _fullpath to get and store the full path name of the 
  16638. current directory. 
  16639.  
  16640.                                                                         *
  16641. ************************************************************************/
  16642.  
  16643. #include <stdio.h>
  16644. #include <stdlib.h>
  16645. #include <errno.h>
  16646. int main(void)
  16647. {
  16648.     char *retBuffer;
  16649.     retBuffer = _fullpath(NULL, ".", 0);
  16650.     if ( retBuffer == NULL )
  16651.        printf("An error has occurred, errno is set to %d.\n", errno);
  16652.     else
  16653.        printf("Full path name of current directory is %s.\n", retBuffer);
  16654.     return 0;
  16655.     /* If path of current directory is D:\BIN, the expected output is:
  16656.        Full path name of current directory is D:\BIN.                  */
  16657. }
  16658.  
  16659.  
  16660. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16661.  
  16662. /************************************************************************
  16663. *
  16664. The following example writes NUM long integers to a stream in binary format. 
  16665.  
  16666.                                                                         *
  16667. ************************************************************************/
  16668.  
  16669. #include <stdio.h>
  16670. #define  NUM  100
  16671. int main(void)
  16672. {
  16673.    FILE *stream;
  16674.    long list[NUM];
  16675.    int numwritten;
  16676.    stream = fopen("myfile.dat", "w+b");
  16677.       .
  16678.       .  /* assign values to list[] */
  16679.       .
  16680.    numwritten = fwrite(list, sizeof(long), NUM, stream);
  16681. }
  16682.  
  16683.  
  16684. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16685.  
  16686. /************************************************************************
  16687. *
  16688.  
  16689.                                                                         *
  16690. ************************************************************************/
  16691.  
  16692.  
  16693. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16694.  
  16695. /************************************************************************
  16696. *
  16697.  
  16698.                                                                         *
  16699. ************************************************************************/
  16700.  
  16701.  
  16702. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16703.  
  16704. /************************************************************************
  16705. *
  16706.  
  16707.                                                                         *
  16708. ************************************************************************/
  16709.  
  16710.  
  16711. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16712.  
  16713. #include <math.h>
  16714. #include <stdio.h>
  16715. int main(void)
  16716. {
  16717.    double x=42, g_at_x;
  16718.    g_at_x = exp(gamma(x));       /* g_at_x = 3.345253e+49 */
  16719.    printf ("The value of G(%4.2f) is %7.2e\n", x, g_at_x);
  16720. }
  16721.  
  16722. /************************************************************************
  16723. *
  16724.  
  16725. /************************  Output should be similar to:  **********
  16726. The value of G(42.00) is 3.35e+49
  16727. */
  16728.  
  16729.                                                                         *
  16730. ************************************************************************/
  16731.  
  16732.  
  16733. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16734.  
  16735. /************************************************************************
  16736. *
  16737. The following example converts the value -3.1415e3 to a character string and 
  16738. places it in the character array buffer1. It then converts the macro value _INF 
  16739. to a character string and places it in buffer2. 
  16740.  
  16741.                                                                         *
  16742. ************************************************************************/
  16743.  
  16744. #include <stdio.h>
  16745. #include <stdlib.h>
  16746. #include <float.h>    /* for the definition of _INF */
  16747. int main(void)
  16748. {
  16749.     char buffer1[10], buffer2[10];
  16750.     _gcvt(-3.1415e3, 7, buffer1);
  16751.     printf("The first result is %s \n", buffer1);
  16752.     _gcvt(_INF, 5, buffer2);
  16753.     printf("The second result is %s \n", buffer2);
  16754.     return 0;
  16755.     /* The expected output is:
  16756.        The first result is -3141.5
  16757.        The second result is INFINITY */
  16758. }
  16759.  
  16760.  
  16761. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16762.  
  16763. /************************************************************************
  16764. *
  16765. The following example gets a line of input from the stdin stream.  You can also 
  16766. use getc(stdin) instead of getchar() in the for statement to get a line of 
  16767. input from stdin. 
  16768.  
  16769.                                                                         *
  16770. ************************************************************************/
  16771.  
  16772. #include <stdio.h>
  16773. #define LINE 80
  16774. int main(void) {
  16775.   char buffer[LINE+1];
  16776.   int i;
  16777.   int ch;
  16778.   printf( "Please enter string\n" );
  16779.   /* Keep reading until either:
  16780.      1. the length of LINE is exceeded  or
  16781.      2. the input character is EOF  or
  16782.      3. the input character is a newline character
  16783.    */
  16784.   for ( i = 0; ( i < LINE ) && (( ch = getchar()) != EOF) &&
  16785.                ( ch !='\n' ); ++i )
  16786.     buffer[i] = ch;
  16787.   buffer[i] = '\0';  /* a string should always end with '\0' ! */
  16788.   printf( "The string is %s\n", buffer );
  16789. }
  16790.  
  16791. /************************************************************************
  16792. *
  16793.  
  16794. /************************  Output should be similar to:  **********
  16795. Please enter string
  16796. hello world
  16797. The string is hello world
  16798. */
  16799.  
  16800.                                                                         *
  16801. ************************************************************************/
  16802.  
  16803.  
  16804. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16805.  
  16806. /************************************************************************
  16807. *
  16808.  
  16809. The following program gets characters from the keyboard until it finds the 
  16810. character 'x': 
  16811.  
  16812.                                                                         *
  16813. ************************************************************************/
  16814.  
  16815. #include <conio.h>
  16816. #include <stdio.h>
  16817. int main(void)
  16818. {
  16819.    int ch;
  16820.    _cprintf("\nType in some letters.");
  16821.    printf("\n");
  16822.    _cprintf("If you type in an 'x', the program ends.\n");
  16823.    printf("\n");
  16824.    for(;;)
  16825.    {
  16826.       ch = _getch();
  16827.       if (ch == 'x') {
  16828.          _ungetch(ch);
  16829.          break;
  16830.       }
  16831.       _putch(ch);
  16832.    }
  16833.    ch=_getch();
  16834.    printf("\n");
  16835.    _cprintf("\nThe last character was '%c'.", ch);
  16836.    return 0;
  16837. /**************  The output should be similar to:  **********************
  16838.    Type in some letters.
  16839.    If you type in an 'x', the program ends.
  16840.    One Two Three Four Five Si
  16841.    The last character was 'x'.
  16842. */
  16843. }
  16844.  
  16845.  
  16846. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16847.  
  16848. /************************************************************************
  16849. *
  16850. The following program stores the name of the current working directory (up to 
  16851. _MAX_PATH characters) in a buffer.  The value of _MAX_PATH is defined in 
  16852. <stdlib.h>. 
  16853.  
  16854.                                                                         *
  16855. ************************************************************************/
  16856.  
  16857. #include <direct.h>
  16858. #include <stdio.h>
  16859. #include <stdlib.h>
  16860. int main(void)
  16861. {
  16862.     char buffer[_MAX_PATH];
  16863.     if (_getcwd(buffer, _MAX_PATH) == NULL)
  16864.        perror("getcwd error");
  16865.     printf("The current directory is %s\n", buffer);
  16866.     return 0;
  16867. /****************  The output should be similar to:  ********************
  16868.    The current directory is E:\C_OS2\MIG_XMPS
  16869. */
  16870. }
  16871.  
  16872.  
  16873. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16874.  
  16875. /************************************************************************
  16876. *
  16877. The following program uses _getdcwd to obtain the current working directory of 
  16878. Drive C. 
  16879.  
  16880.                                                                         *
  16881. ************************************************************************/
  16882.  
  16883. #include <stdio.h>
  16884. #include <direct.h>
  16885. #include <errno.h>
  16886. int main(void)
  16887. {
  16888.     char *retBuffer;
  16889.     retBuffer = _getdcwd(3,NULL,0);
  16890.     if ( retBuffer == NULL )
  16891.        printf("An error has occurred, errno is set to %d.\n", errno);
  16892.     else
  16893.        printf("Current working directory of drive C is %s.\n", retBuffer);
  16894.     return 0;
  16895. /***************  The output should be similar to:  *********************
  16896.     Current working directory of drive C is C:\.
  16897. */
  16898. }
  16899.  
  16900.  
  16901. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16902.  
  16903. /************************************************************************
  16904. *
  16905. The following program gets and prints the current working drive number. 
  16906.  
  16907.                                                                         *
  16908. ************************************************************************/
  16909.  
  16910. #include <stdio.h>
  16911. #include <direct.h>
  16912. int main(void)
  16913. {
  16914.    printf("Current working drive is %d.\n", _getdrive() );
  16915.     return 0;
  16916. /********  If the current working drive is E:, then  **************
  16917. ***************  the output should be similar to:  **********************
  16918.    Current working drive is 5.
  16919. */
  16920. }
  16921.  
  16922.  
  16923. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16924.  
  16925. /************************************************************************
  16926. *
  16927. In the following &cpdos. example, pathvar points to the value of the PATH 
  16928. environment variable: 
  16929.  
  16930.                                                                         *
  16931. ************************************************************************/
  16932.  
  16933. #include <stdlib.h>
  16934. int main(void)
  16935. {
  16936.    char *pathvar;
  16937.    pathvar = getenv("PATH");
  16938. }
  16939.  
  16940.  
  16941. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16942.  
  16943. /************************************************************************
  16944. *
  16945. The following program prints the process identifier: 
  16946.  
  16947.                                                                         *
  16948. ************************************************************************/
  16949.  
  16950. #include <process.h>
  16951. #include <string.h>
  16952. #include <stdio.h>
  16953. #include <stdlib.h>
  16954. int main(void)
  16955. {
  16956.     printf("Process identifier is %d\n", _getpid());
  16957.     return 0;
  16958. /****************  The output should be similar to:  ********************
  16959.    Process identifier is 242
  16960. */
  16961. }
  16962.  
  16963.  
  16964. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16965.  
  16966. /************************************************************************
  16967. *
  16968. The following example gets a line of input from stdin: 
  16969.  
  16970.                                                                         *
  16971. ************************************************************************/
  16972.  
  16973. #include <stdio.h>
  16974. #define MAX_LINE 100
  16975. int main(void)
  16976. {
  16977.    char line[MAX_LINE];
  16978.    char *result;
  16979.    if ((result = gets(line)) != NULL)  {
  16980.       if (ferror(stdin))
  16981.         perror("Error");
  16982.    }
  16983. }
  16984.  
  16985.  
  16986. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  16987.  
  16988. /************************************************************************
  16989. *
  16990.  
  16991. The following program prints out all the values in the TIB structure. 
  16992.  
  16993.                                                                         *
  16994. ************************************************************************/
  16995.  
  16996. #define INCL_DOSPROCESS
  16997. #include <os2.h>
  16998. #include <stdio.h>
  16999. #include <builtin.h>
  17000. int main( void )
  17001. {
  17002.    printf( "Values in Thread Information Block are:\n\n" );
  17003.    printf( "Exception chain pointer: %lx\n",
  17004.            _getTIBvalue( offsetof( TIB, tib_pexchain ) ) );
  17005.    printf( "Base stack address: %lx\n",
  17006.            _getTIBvalue( offsetof( TIB, tib_pstack ) ) );
  17007.    printf( "End of stack address: %lx\n",
  17008.            _getTIBvalue( offsetof( TIB, tib_pstacklimit ) ) );
  17009.    printf( "System specific TIB pointer: %p\n",
  17010.            _getTIBvalue( offsetof( TIB, tib_ptib2 ) ) );
  17011.    printf( "Version number: %lu\n",
  17012.            _getTIBvalue( offsetof( TIB, tib_version ) ) );
  17013.    printf( "Ordinal number: %lu\n",
  17014.            _getTIBvalue( offsetof( TIB, tib_ordinal ) ) );
  17015.    return 0;
  17016. }
  17017.  
  17018.  
  17019. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17020.  
  17021. /************************************************************************
  17022. *
  17023. This program uses the gmtime function to adjust a time_t representation to a 
  17024. Coordinated Universal Time character string and then converts it to a printable 
  17025. string using asctime. 
  17026.  
  17027.                                                                         *
  17028. ************************************************************************/
  17029.  
  17030. #include <stdio.h>
  17031. #include <time.h>
  17032. int main(void)
  17033. {
  17034.    time_t ltime;
  17035.    time(<ime);
  17036.    printf ("Coordinated Universal Time is %s\n",
  17037.             asctime(gmtime(<ime)));
  17038. }
  17039.  
  17040. /************************************************************************
  17041. *
  17042.  
  17043. /************************  Output should be similar to:  **********
  17044. Coordinated Universal Time is Wed Aug 18 21:01:44 1993
  17045. */
  17046.  
  17047.                                                                         *
  17048. ************************************************************************/
  17049.  
  17050.  
  17051. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17052.  
  17053. /************************************************************************
  17054. *
  17055. The following example allocates 5000 bytes of storage, and then attempts to 
  17056. write to storage that was not allocated. The call to _heap_check detects the 
  17057. error, generates several messages, and stops the program. 
  17058.  
  17059.                                                                         *
  17060. ************************************************************************/
  17061.  
  17062. #ifndef __DEBUG_ALLOC__      /* this macro could also be defined */
  17063.    #define __DEBUG_ALLOC__   /*      from the command line       */
  17064. #endif
  17065. #include <stdlib.h>
  17066. #include <stdio.h>
  17067. int main(void)
  17068. {
  17069.    char *ptr;
  17070.    if (( ptr = malloc(5000) ) == NULL)
  17071.    {
  17072.       printf("Could not allocate memory block.\n");
  17073.       return EXIT_FAILURE;
  17074.    }
  17075.    *(ptr - 1) = 'a';    /* overwrites storage that was not allocated */
  17076.    _heap_check();
  17077.    printf("_heap_check did not detect that a memory block was overwritten.\n");
  17078.    return EXIT_FAILURE;
  17079.    /* Possible output is:
  17080.       Memory was overwritten before the allocated memory block which starts
  17081.             at address 0x00150010.
  17082.       The first eight bytes of the memory block (in hex) are: 0000000000000000.
  17083.       This memory block was (re)allocated at line number 11 in THPCHK.C.        */
  17084. }
  17085.  
  17086.  
  17087. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17088.  
  17089. /************************************************************************
  17090. *
  17091. The following example shows how to use the _heapmin function. 
  17092.  
  17093.                                                                         *
  17094. ************************************************************************/
  17095.  
  17096. #include <stdio.h>
  17097. #include <stdlib.h>
  17098. int main(void)
  17099. {
  17100.    if ( _heapmin() )
  17101.       printf("_heapmin failed.\n");
  17102.    else
  17103.       printf("_heapmin was successful.\n");
  17104.    return 0;
  17105.    /* The expected output is:
  17106.       _heapmin was successful. */
  17107. }
  17108.  
  17109.  
  17110. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17111.  
  17112. /************************************************************************
  17113. *
  17114. The following example calculates the hypotenuse of a right-angled triangle with 
  17115. sides of 3.0 and 4.0. 
  17116.  
  17117.                                                                         *
  17118. ************************************************************************/
  17119.  
  17120. #include <math.h>
  17121. int main(void)
  17122. {
  17123.    double x, y, z;
  17124.    x = 3.0;
  17125.    y = 4.0;
  17126.    z = hypot(x,y);
  17127.    printf("The hypotenuse of the triangle with sides %lf and %lf"
  17128.           " is %lf\n", x, y, z);
  17129. }
  17130.  
  17131. /************************************************************************
  17132. *
  17133.  
  17134. /********************  Output should be similar to:  **************
  17135. The hypotenuse of the triangle with sides 3.000000 and 4.000000 is 5.000000
  17136. */
  17137.  
  17138.                                                                         *
  17139. ************************************************************************/
  17140.  
  17141.  
  17142. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17143.  
  17144. /************************************************************************
  17145. *
  17146.  
  17147.                                                                         *
  17148. ************************************************************************/
  17149.  
  17150.  
  17151. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17152.  
  17153. /************************************************************************
  17154. *
  17155.  
  17156.                                                                         *
  17157. ************************************************************************/
  17158.  
  17159.  
  17160. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17161.  
  17162. /************************************************************************
  17163. *
  17164.  
  17165.                                                                         *
  17166. ************************************************************************/
  17167.  
  17168.  
  17169. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17170.  
  17171. /************************************************************************
  17172. *
  17173.  
  17174. The following example shows how to call interrupt 3, which is a breakpoint. 
  17175.  
  17176.                                                                         *
  17177. ************************************************************************/
  17178.  
  17179. #include <builtin.h>
  17180. int main( void )
  17181. {
  17182.    /* A breakpoint will occur when running this program */
  17183.    /* within a debugger.                                */
  17184.    _interrupt(3);
  17185.    return 0;
  17186. }
  17187.  
  17188.  
  17189. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17190.  
  17191. /************************************************************************
  17192. *
  17193. The following example analyzes all characters between code 0x0 and code 
  17194. UPPER_LIMIT printing A for alphabetic characters, AN for alphanumerics, U for 
  17195. uppercase, L for lowercase, D for digits, X for hexadecimal digits, S for 
  17196. spaces, PU for punctuation, PR for printable characters, G for graphics 
  17197. characters, and C for control characters.  This example prints the code if 
  17198. printable. 
  17199.  
  17200. The output of this example is a 256-line table showing the characters from 0 to 
  17201. 255 that possess the attributes tested. 
  17202.  
  17203.                                                                         *
  17204. ************************************************************************/
  17205.  
  17206. #include <stdio.h>
  17207. #include <ctype.h>
  17208. #define UPPER_LIMIT   0xFF
  17209. int main(void)
  17210. {
  17211.    int ch;
  17212.    for ( ch = 0; ch <= UPPER_LIMIT; ++ch ) {
  17213.       printf("%3d ", ch);
  17214.       printf("%#04x ", ch);
  17215.       printf("%3s ", isalnum(ch)  ? "AN" : " ");
  17216.       printf("%2s ", isalpha(ch)  ? "A"  : " ");
  17217.       printf("%2s",  iscntrl(ch)  ? "C"  : " ");
  17218.       printf("%2s",  isdigit(ch)  ? "D"  : " ");
  17219.       printf("%2s",  isgraph(ch)  ? "G"  : " ");
  17220.       printf("%2s",  islower(ch)  ? "L"  : " ");
  17221.       printf(" %c",  isprint(ch)  ? ch   : ' ');
  17222.       printf("%3s",  ispunct(ch)  ? "PU" : " ");
  17223.       printf("%2s",  isspace(ch)  ? "S"  : " ");
  17224.       printf("%3s",  isprint(ch)  ? "PR" : " ");
  17225.       printf("%2s",  isupper(ch)  ? "U"  : " ");
  17226.       printf("%2s",  isxdigit(ch) ? "X"  : " ");
  17227.       putchar('\n');
  17228.    }
  17229. }
  17230.  
  17231.  
  17232. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17233.  
  17234. /************************************************************************
  17235. *
  17236. The following program tests the integers from 0x7c to 0x82, and prints the 
  17237. corresponding ASCII character if the integer is within the ASCII range: 
  17238.  
  17239.                                                                         *
  17240. ************************************************************************/
  17241.  
  17242. #include <stdio.h>
  17243. #include <ctype.h>
  17244. int main(void)
  17245. {
  17246.     int ch;
  17247.     for (ch = 0x7c; ch <= 0x82; ch++)
  17248.     {
  17249.         printf("%#04x    ", ch);
  17250.         if (isascii(ch))
  17251.             printf("The ASCII character is %c\n", ch);
  17252.         else
  17253.             printf("Not an ASCII character\n");
  17254.     }
  17255.     return 0;
  17256. /****************  The output should be similar to:  ********************
  17257.    0x7c    The ASCII character is |
  17258.    0x7d    The ASCII character is }
  17259.    0x7e    The ASCII character is ~
  17260.    0x7f    The ASCII character is 
  17261.    0x80    Not an ASCII character
  17262.    0x81    Not an ASCII character
  17263.    0x82    Not an ASCII character
  17264. */
  17265. }
  17266.  
  17267.  
  17268. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17269.  
  17270. /************************************************************************
  17271. *
  17272.  
  17273. This program opens the console and tries to determine if it is a character 
  17274. device: 
  17275.  
  17276.                                                                         *
  17277. ************************************************************************/
  17278.  
  17279. #include <io.h>
  17280. #include <stdio.h>
  17281. #include <fcntl.h>
  17282. #include <sys\stat.h>
  17283. int main(void)
  17284. {
  17285.    int  fh, result;
  17286.    if (-1 == (fh = _open("CON", O_RDWR,(S_IREAD | S_IWRITE))))
  17287.    {
  17288.       perror("Error opening console\n");
  17289.       return 1;
  17290.    }
  17291.    result = _isatty(fh)    ;
  17292.    if (0 != result)
  17293.       printf("CON is a character device.\n");
  17294.    else
  17295.       printf("CON is not a character device.\n");
  17296.    _close (fh);
  17297.    return 0;
  17298. /********************  The expected output is:  *************************
  17299.       CON is a character device.
  17300. */
  17301. }
  17302.  
  17303.  
  17304. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17305.  
  17306. /************************************************************************
  17307. *
  17308. The following program uses _iscsym and _iscsymf to test the characters a, _, 
  17309. and 1. If the character falls within the ASCII set tested for, the macro 
  17310. returns TRUE. Otherwise, it returns FALSE. 
  17311.  
  17312.                                                                         *
  17313. ************************************************************************/
  17314.  
  17315. #include <stdio.h>
  17316. #include <ctype.h>
  17317. int main(void)
  17318. {
  17319.     int ch[3] = {'a', '_', '1'};
  17320.     int i;
  17321.     for (i = 0; i < 3; i++)
  17322.     {
  17323.         printf("_iscsym('%c') returns %s\n",
  17324.                      ch[i], _iscsym(ch[i]) ? "TRUE" : "FALSE");
  17325.         printf("_iscsymf('%c') returns %s\n\n",
  17326.                      ch[i], _iscsymf(ch[i]) ? "TRUE" : "FALSE");
  17327.     }
  17328.     return 0;
  17329. /******************  The output should be similar to:  ******************
  17330.    _iscsym('a') returns TRUE
  17331.    _iscsymf('a') returns TRUE
  17332.    _iscsym('_') returns TRUE
  17333.    _iscsymf('_') returns TRUE
  17334.    _iscsym('1') returns TRUE
  17335.    _iscsymf('1') returns FALSE
  17336. */
  17337. }
  17338.  
  17339.  
  17340. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17341.  
  17342. /************************************************************************
  17343. *
  17344. This example converts the integer value -255 to a decimal, a binary, and a hex 
  17345. number, storing its character representation in the array buffer. 
  17346.  
  17347.                                                                         *
  17348. ************************************************************************/
  17349.  
  17350. #include <stdio.h>
  17351. #include <stdlib.h>
  17352. int main(void)
  17353. {
  17354.     char buffer[35];
  17355.     char *p;
  17356.     p = _itoa(-255, buffer, 10);
  17357.     printf("The result of _itoa(-255) with radix of 10 is %s\n", p);
  17358.     p = _itoa(-255, buffer, 2);
  17359.     printf("The result of _itoa(-255) with radix of 2\n    is %s\n", p);
  17360.     p = _itoa(-255, buffer, 16);
  17361.     printf("The result of _itoa(-255) with radix of 16 is %s\n", p);
  17362.     return 0;
  17363.     /* The expected output is:
  17364.        The result of _itoa(-255) with radix of 10 is -255
  17365.        The result of _itoa(-255) with radix of 2
  17366.            is 11111111111111111111111100000001
  17367.        The result of _itoa(-255) with radix of 16 is ffffff01
  17368.                                                                           */
  17369. }
  17370.  
  17371.  
  17372. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17373.  
  17374. /************************************************************************
  17375. *
  17376.  
  17377. The following program uses _kbhit to test for the pressing of a key on the 
  17378. keyboard and to print a statement with the result of the test. 
  17379.  
  17380.                                                                         *
  17381. ************************************************************************/
  17382.  
  17383.  #include <conio.h>
  17384.  #include <stdio.h>
  17385.  int main(void)
  17386.     {
  17387.     int ch;
  17388.     printf("Type in some letters.\n");
  17389.     printf("If you type in an 'x', the program ends.\n");
  17390.     for (;;)
  17391.        {
  17392.        while (_kbhit() == 0)
  17393.           {
  17394.           /* Processing without waiting for a key to be pressed */
  17395.           }
  17396.        ch = _getch();
  17397.        printf("You have pressed the '%c' key.\n",ch);
  17398.        if (ch == 'x')
  17399.           break;
  17400.        }
  17401.     return 0;
  17402. /*******************  Possible output:  ********************************
  17403.     Type in some letters.
  17404.     If you type in an 'x', the program ends.
  17405.     You have pressed the 'f' key.
  17406.     You have pressed the 'e' key.
  17407.     You have pressed the 'l' key.
  17408.     You have pressed the 'i' key.
  17409.     You have pressed the 'x' key.
  17410. ***********************  Program ends  ********************************/
  17411.     }
  17412.  
  17413.  
  17414. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17415.  
  17416. /************************************************************************
  17417. *
  17418. This example computes y as the absolute value of the long integer -41567. 
  17419.  
  17420.                                                                         *
  17421. ************************************************************************/
  17422.  
  17423. #include <stdlib.h>
  17424. int main(void)
  17425. {
  17426.    long x, y;
  17427.    x = -41567L;
  17428.    y = labs(x);
  17429.    printf("The absolute value of %ld is %ld\n", x, y);
  17430. }
  17431.  
  17432. /************************************************************************
  17433. *
  17434.  
  17435. /********************  Output should be similar to:  **************
  17436. The absolute value of -41567 is 41567
  17437. */
  17438.  
  17439.                                                                         *
  17440. ************************************************************************/
  17441.  
  17442.  
  17443. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17444.  
  17445. /************************************************************************
  17446. *
  17447. The following example computes y as 1.5 times 2 to the fifth power (1.5 * 
  17448. (2**5)): 
  17449.  
  17450.                                                                         *
  17451. ************************************************************************/
  17452.  
  17453. #include <math.h>
  17454. int main(void)
  17455. {
  17456.    double x, y;
  17457.    int p;
  17458.    x = 1.5;
  17459.    p = 5;
  17460.    y = ldexp(x,p);
  17461.    printf("%lf times 2 to the power of %d is %lf\n", x, p, y);
  17462. }
  17463.  
  17464. /************************************************************************
  17465. *
  17466.  
  17467. /********************  Output should be similar to:  **************
  17468. 1.500000 times 2 to the power of 5 is 48.000000
  17469. */
  17470.  
  17471.                                                                         *
  17472. ************************************************************************/
  17473.  
  17474.  
  17475. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17476.  
  17477. #include <stdio.h>
  17478. #include <stdlib.h>
  17479. int main(void)
  17480. {
  17481.    long int num[2] = {45,-45};
  17482.    long int den[2] = {7,-7};
  17483.    ldiv_t ans;   /* ldiv_t is a struct type containing two long ints:
  17484.                     'quot' stores quotient; 'rem' stores remainder */
  17485.    short i,j;
  17486.    printf("Results of long division:\n");
  17487.    for (i = 0; i < 2; i++)
  17488.       for (j = 0; j < 2; j++) {
  17489.          ans = ldiv(num[i], den[j]);
  17490.          printf("Dividend: %6ld  Divisor: %6ld", num[i], den[j]);
  17491.          printf("  Quotient: %6ld  Remainder: %6ld\n", ans.quot, ans.rem);
  17492.       }
  17493. }
  17494.  
  17495. /************************************************************************
  17496. *
  17497.  
  17498. /********************  Expected output:  **************************
  17499. Results of long division:
  17500. Dividend:  45  Divisor:   7  Quotient:   6  Remainder:   3
  17501. Dividend:  45  Divisor:  -7  Quotient:  -6  Remainder:   3
  17502. Dividend: -45  Divisor:   7  Quotient:  -6  Remainder:  -3
  17503. Dividend: -45  Divisor:  -7  Quotient:   6  Remainder:  -3
  17504. */
  17505.  
  17506.                                                                         *
  17507. ************************************************************************/
  17508.  
  17509.  
  17510. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17511.  
  17512. /************************************************************************
  17513. *
  17514. This program uses the _lfind function to search for the keyword PATH in the 
  17515. command-line arguments: 
  17516.  
  17517.                                                                         *
  17518. ************************************************************************/
  17519.  
  17520. #include <search.h>
  17521. #include <string.h>
  17522. #include <stdio.h>
  17523. #define CNT 2
  17524. /* Must declare 'compare' as a function  */
  17525. int compare(const void *, const void *);
  17526. int main(void)
  17527. {
  17528.    char **result;
  17529.    char *key = "PATH";
  17530.    unsigned int num = CNT;
  17531.    char *string[CNT] = {
  17532.                        "PATH = d:\\david\\matthew\\heather\\ed\\simon",
  17533.                        "LIB = PATH\\abc"
  17534.                        };
  17535.    /* The following statement finds the argument that starts with "PATH" */
  17536.    if ((result = (char **)_lfind((char *)&key,
  17537.                                 (char *)string, &num,
  17538.                                 sizeof(char *), compare)) != NULL)
  17539.        printf("%s found\n", *result);
  17540.    else
  17541.        printf("PATH not found \n");
  17542.    return 0;
  17543. }
  17544. /* The following is a sample 'compare' function */
  17545. int compare(const void *arg1, const void *arg2)
  17546. {
  17547.     return(strncmp(*(char **)arg1, *(char **)arg2, strlen(*(char **)arg1)));
  17548. }
  17549. /*****************  The output should be similar to:  *******************
  17550.     PATH = d:\david\matthew\heather\ed\simon found
  17551. */
  17552.  
  17553.  
  17554. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17555.  
  17556. /************************************************************************
  17557. *
  17558. In the following example, _loadmod loads the DLL mark and gets the address of 
  17559. the function PLUS within the DLL.  It then calls that function, which adds two 
  17560. integers passed to it. The types PFN and APIRET, are required to use the OS/2 
  17561. DosQueryProcAddr API, and are defined by including the <os2.h> header file. 
  17562.  
  17563. Note:  To run this program, you must first create mark.dll. Copy the code for 
  17564. the PLUS function into a file called mark.c, and the code for the .DEF file 
  17565. into mark.def.  Eliminate the comments from these two files. Compile with the 
  17566. command: 
  17567.  
  17568.    icc /Ge- mark.c mark.def
  17569. You can then run the example: 
  17570.  
  17571.                                                                         *
  17572. ************************************************************************/
  17573.  
  17574.  
  17575. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17576.  
  17577. /************************************************************************
  17578. *
  17579.  
  17580. This example prints out the default decimal point for your locale and then the 
  17581. decimal point for the LC_C_FRANCE locale. 
  17582.  
  17583.                                                                         *
  17584. ************************************************************************/
  17585.  
  17586. #include <stdio.h>
  17587. #include <locale.h>
  17588. int main(void) {
  17589.   char * string;
  17590.   struct lconv * mylocale;
  17591.   mylocale = localeconv();
  17592.   /* Default decimal point */
  17593.   printf( "Default decimal point is a %s\n", mylocale->decimal_point );
  17594.   string = setlocale(LC_ALL, LC_C_FRANCE );
  17595.   mylocale = localeconv();
  17596.   /* A comma is set to be the decimal point when the locale is LC_C_FRANCE */
  17597.   printf( "France's decimal point is a %s\n", mylocale->decimal_point );
  17598. }
  17599.  
  17600. /************************************************************************
  17601. *
  17602.  
  17603. /********************  Output should be similar to:  **************
  17604. Default decimal point is a .
  17605. France's decimal point is a ,
  17606. */
  17607.  
  17608.                                                                         *
  17609. ************************************************************************/
  17610.  
  17611.  
  17612. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17613.  
  17614. /************************************************************************
  17615. *
  17616. Suppose that the current local time and date is 3 p.m. October 31, 1990. The 
  17617. following example queries the system clock and displays the local time. 
  17618.  
  17619.                                                                         *
  17620. ************************************************************************/
  17621.  
  17622. #include <time.h>
  17623. #include <stdio.h>
  17624. int main(void)
  17625. {
  17626.    struct tm *newtime;
  17627.    time_t ltime;
  17628.    time(<ime);
  17629.    newtime = localtime(<ime);
  17630.    printf("The date and time is %s", asctime(newtime));
  17631. }
  17632.  
  17633. /************************************************************************
  17634. *
  17635.  
  17636. .* Output 
  17637.  
  17638. /********************  Output should be similar to:  **************
  17639. The date and time is Mon May 31 15:00:00 1993
  17640. */
  17641.  
  17642.                                                                         *
  17643. ************************************************************************/
  17644.  
  17645.  
  17646. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17647.  
  17648. /************************************************************************
  17649. *
  17650. The following example calculates the natural logarithm of 1000.0. 
  17651.  
  17652.                                                                         *
  17653. ************************************************************************/
  17654.  
  17655. #include <math.h>
  17656. int main(void)
  17657. {
  17658.    double x = 1000.0, y;
  17659.    y = log(x);
  17660.    printf("The natural logarithm of %lf is %lf\n", x, y);
  17661. }
  17662.  
  17663. /************************************************************************
  17664. *
  17665.  
  17666. /********************  Output should be similar to:  **************
  17667. The natural logarithm of 1000.000000 is 6.907755
  17668. */
  17669.  
  17670.                                                                         *
  17671. ************************************************************************/
  17672.  
  17673.  
  17674. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17675.  
  17676. /************************************************************************
  17677. *
  17678.  
  17679. The following example calculates the base 10 logarithm of 1000.0. 
  17680.  
  17681.                                                                         *
  17682. ************************************************************************/
  17683.  
  17684. #include <math.h>
  17685. int main(void)
  17686. {
  17687.    double x = 1000.0, y;
  17688.    y = log10(x);
  17689.    printf("The base 10 logarithm of %lf is %lf\n", x, y);
  17690. }
  17691.  
  17692. /************************************************************************
  17693. *
  17694.  
  17695. /********************  Output should be similar to:  **************
  17696. The base 10 logarithm of 1000.000000 is 3.000000
  17697. */
  17698.  
  17699.                                                                         *
  17700. ************************************************************************/
  17701.  
  17702.  
  17703. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17704.  
  17705. /************************************************************************
  17706. *
  17707. The following example provides for saving the stack environment at the 
  17708. statement: 
  17709.  
  17710.   if(setjmp(mark) != 0) ...
  17711.  
  17712. When the system first performs the if statement, it saves the environment in 
  17713. mark and sets the condition to FALSE because setjmp returns a 0 when it saves 
  17714. the environment.  The program prints the message: 
  17715.  
  17716.   setjmp has been called
  17717.  
  17718. The subsequent call to function p tests for a local error condition, which can 
  17719. cause it to perform the longjmp function.  Then, control returns to the 
  17720. original setjmp function using the environment saved in mark.  This time the 
  17721. condition is TRUE because -1 is the return value from the longjmp function. The 
  17722. example then performs the statements in the block and prints: 
  17723.  
  17724.   longjmp has been called
  17725.  
  17726. Then, it performs your recover function and leaves the program. 
  17727.  
  17728.                                                                         *
  17729. ************************************************************************/
  17730.  
  17731. #include <stdio.h>
  17732. #include <setjmp.h>
  17733. jmp_buf mark;
  17734. void p(void);
  17735. void recover(void);
  17736. int main(void)
  17737. {
  17738.    if (setjmp(mark) != 0) {
  17739.       printf("longjmp has been called\n");
  17740.       recover();
  17741.       exit(1);
  17742.       }
  17743.    printf("setjmp has been called\n");
  17744.    .
  17745.    .
  17746.    .
  17747.    p();
  17748.    .
  17749.    .
  17750.    .
  17751. }
  17752. void p(void)
  17753. {
  17754.    int error = 0;
  17755.    .
  17756.    .
  17757.    .
  17758.    error = 9;
  17759.    .
  17760.    .
  17761.    .
  17762.    if (error != 0)
  17763.       longjmp(mark, -1);
  17764.    .
  17765.    .
  17766.    .
  17767. }
  17768. void recover(void)
  17769. {
  17770.    .
  17771.    .
  17772.    .
  17773. }
  17774.  
  17775.  
  17776. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17777.  
  17778. /************************************************************************
  17779. *
  17780. This program uses _lrotl and _lrotr with different shift values to rotate the 
  17781. long integer value 0x01234567: 
  17782.  
  17783.                                                                         *
  17784. ************************************************************************/
  17785.  
  17786. #include <stdio.h>
  17787. #include <stdlib.h>
  17788. int main(void)
  17789. {
  17790.     unsigned long val = 0X01234567;
  17791.     printf("The value of 0x%8.8lx rotated 4 bits to the left is 0x%8.8lx\n",
  17792.                                          val,  _lrotl(val, 4));
  17793.     printf("The value of 0x%8.8lx rotated 16 bits to the right is 0x%8.8lx\n",
  17794.                                          val,  _lrotr(val, 16));
  17795.     return 0;
  17796. /*************  The output should be similar to:  ***********************
  17797.    The value of 0x01234567 rotated 4 bits to the left is 0x12345670
  17798.    The value of 0x01234567 rotated 16 bits to the right is 0x45670123
  17799. */
  17800. }
  17801.  
  17802.  
  17803. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17804.  
  17805. /************************************************************************
  17806. *
  17807.  
  17808. The following program opens the file sample.dat and if successful, moves the 
  17809. file pointer to the eighth position in the file. The example then attempts to 
  17810. read bytes from the file, starting at the new pointer position, and reads them 
  17811. into the buffer. 
  17812.  
  17813.                                                                         *
  17814. ************************************************************************/
  17815.  
  17816. #include <io.h>
  17817. #include <stdio.h>
  17818. #include <stdlib.h>
  17819. #include <fcntl.h>
  17820. #include <string.h>
  17821. int main(void)
  17822.    {
  17823.    long length;
  17824.    int  fh;
  17825.    char buffer[20];
  17826.    memset(buffer,'\0',20);  /* Initialize the buffer */
  17827.    printf("\nCreating sample.dat.\n");
  17828.    system("echo Sample Program > sample.dat");
  17829.    if (-1 == (fh = _open("sample.dat",O_RDWR | O_APPEND)))
  17830.       {
  17831.       perror("Unable to open sample.dat.");
  17832.       _exit(1);
  17833.       }
  17834.    if ( -1 == _lseek(fh,7,SEEK_SET) ) /* place the file pointer at the */
  17835.       {                              /* eighth position in the file   */
  17836.       perror("Unable to _lseek");
  17837.       _close(fh);
  17838.       return 1;
  17839.       }
  17840.    if (8 != _read(fh,buffer,8))
  17841.       {
  17842.       perror("Unable to read from sample.dat.");
  17843.       _close(fh);
  17844.       return 1;
  17845.       }
  17846.    printf("Successfully read in the following:\n%s\n ",buffer);
  17847.    _close(fh);
  17848.    return 0;
  17849. /********************  The expected output is:  *************************
  17850.       Creating sample.dat.
  17851.       Successfully read in the following:
  17852.       Program
  17853. */
  17854.    }
  17855.  
  17856.  
  17857. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17858.  
  17859. /************************************************************************
  17860. *
  17861. This example converts the long integer -255L to a decimal, binary, and hex 
  17862. value, and stores its character representation in the array buffer. 
  17863.  
  17864.                                                                         *
  17865. ************************************************************************/
  17866.  
  17867. #include <stdio.h>
  17868. #include <stdlib.h>
  17869. int main(void)
  17870. {
  17871.     char buffer[35];
  17872.     char *p;
  17873.     p = _ltoa(-255L, buffer, 10);
  17874.     printf("The result of _ltoa(-255) with radix of 10 is %s\n", p);
  17875.     p = _ltoa(-255L, buffer, 2);
  17876.     printf("The result of _ltoa(-255) with radix of 2\n    is %s\n", p);
  17877.     p = _ltoa(-255L, buffer, 16);
  17878.     printf("The result of _ltoa(-255) with radix of 16 is %s\n", p);
  17879.     return 0;
  17880.     /* The expected output is:
  17881.        The result of _ltoa(-255) with radix of 10 is -255
  17882.        The result of _ltoa(-255) with radix of 2
  17883.            is 11111111111111111111111100000001
  17884.        The result of _ltoa(-255) with radix of 16 is ffffff01  */
  17885. }
  17886.  
  17887.  
  17888. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17889.  
  17890. /************************************************************************
  17891. *
  17892. This program builds a file name path from the specified components: 
  17893.  
  17894.                                                                         *
  17895. ************************************************************************/
  17896.  
  17897. #include <stdio.h>
  17898. #include <stdlib.h>
  17899. int main(void)
  17900. {
  17901.    char path_buffer [_MAX_PATH];
  17902.    char drive [_MAX_DRIVE];
  17903.    char dir [_MAX_DIR];
  17904.    char fname [_MAX_FNAME];
  17905.    char ext [_MAX_EXT];
  17906.    _makepath (path_buffer, "c", "qc\\bob\\eclibref\\e", "makepath", "c") ;
  17907.    printf ("Path created with _makepath: %s\n\n", path_buffer);
  17908.    _splitpath (path_buffer, drive, dir, fname, ext);
  17909.    printf ("Path extracted with _splitpath:\n");
  17910.    printf ("drive: %s\n", drive);
  17911.    printf ("directory: %s\n", dir);
  17912.    printf ("file name: %s\n", fname);
  17913.    printf ("extension: %s\n", ext);
  17914.    return 0;
  17915. /****************  The output should be similar to:  ********************
  17916.    Path created with _makepath: c:qc\bob\eclibref\e\makepath.c
  17917.    Path extracted with _splitpath:
  17918.    drive: c:
  17919.    directory: qc\bob\eclibref\e\
  17920.    file name: makepath
  17921.    extension: .c
  17922. */
  17923. }
  17924.  
  17925.  
  17926. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17927.  
  17928. /************************************************************************
  17929. *
  17930. The following example prompts for the number of array entries you want and then 
  17931. reserves enough space in storage for the entries. If malloc was successful, the 
  17932. example assigns values to the entries and prints out each entry;  otherwise, it 
  17933. prints out an error. 
  17934.  
  17935.                                                                         *
  17936. ************************************************************************/
  17937.  
  17938. #include <stdio.h>
  17939. #include <stdlib.h>
  17940. int main(void) {
  17941.   long * array;    /* start of the array */
  17942.   long * index;    /* index variable     */
  17943.   int    i;        /* index variable     */
  17944.   int  num;        /* number of entries of the array */
  17945.   printf( "Enter the size of the array\n" );
  17946.   scanf( "%i", &num );
  17947.   /* allocate num entries */
  17948.   if ( (index = array = malloc( num * sizeof( long ))) != NULL ) {
  17949.     for ( i = 0; i < num; ++i )           /* put values in array    */
  17950.        *index++ = i;                      /* using pointer notation */
  17951.     for ( i = 0; i < num; ++i )           /* print the array out    */
  17952.       printf( "array[ %i ] = %i\n", i, array[i] );
  17953.   }
  17954.   else { /* malloc error */
  17955.     perror( "Out of storage" );
  17956.     abort();
  17957.   }
  17958. }
  17959.  
  17960. /************************************************************************
  17961. *
  17962.  
  17963. /********************  Output should be similar to:  **************
  17964. Enter the size of the array
  17965. array[ 0 ] = 0
  17966. array[ 1 ] = 1
  17967. array[ 2 ] = 2
  17968. array[ 3 ] = 3
  17969. array[ 4 ] = 4
  17970. */
  17971.  
  17972.                                                                         *
  17973. ************************************************************************/
  17974.  
  17975.  
  17976. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  17977.  
  17978. /************************************************************************
  17979. *
  17980. The following program is a definition that you can create to handle errors from 
  17981. the log or log10 functions. The arguments to these logarithmic functions must 
  17982. be positive double values. This routine processes a negative value in an 
  17983. argument (a domain error) by returning the log of its absolute value. It 
  17984. suppresses the error message normally displayed when this error occurs. If the 
  17985. error is a zero argument or if some other routine produced the error, the 
  17986. example takes the default actions. 
  17987.  
  17988.                                                                         *
  17989. ************************************************************************/
  17990.  
  17991. /*                                                      */
  17992. /*   Note: Use "icc /Sm /B"/NOE" yourfile.c" to compile */
  17993. /*   and link this example.                             */
  17994. /*                                                      */
  17995. #include <math.h>
  17996. #include <string.h>
  17997. #include <stdio.h>
  17998. int main(void)
  17999. {
  18000.      int value;
  18001.      printf("Trying to evaluate log10(-1000.00) will create a math exception.\n");
  18002.      value = log10(-1000.00);
  18003.      printf("The _matherr() exception handler evaluates the expression to\n");
  18004.      printf("log10(-1000.00) = %d\n", value);
  18005.      return 0;
  18006. }
  18007.  
  18008. int _matherr(struct exception *x)
  18009. {
  18010.     printf("inside _matherr\n");
  18011.     if (x->type == DOMAIN)
  18012.     {
  18013.         if (strcmp(x->name, "log") == 0)
  18014.         {
  18015.             x->retval = log(-(x->arg1));
  18016.             return(1);
  18017.         }
  18018.         else if (strcmp(x->name, "log10") == 0)
  18019.         {
  18020.             x->retval = log10(-(x->arg1));
  18021.             return(1);
  18022.         }
  18023.     }
  18024.     return 0;     /* Use default actions */
  18025. /********************  The output should be similar to:  ****************
  18026.    Trying to evaluate log10(-1000.00) will create a math exception.
  18027.    inside _matherr
  18028.    The _matherr() exception handler evaluates the expression to
  18029.    log10(-1000.00) = 3
  18030. */
  18031. }
  18032.  
  18033.  
  18034. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18035.  
  18036. /************************************************************************
  18037. *
  18038. This program prints the larger of the two values, a and b. 
  18039.  
  18040.                                                                         *
  18041. ************************************************************************/
  18042.  
  18043. #include <stdlib.h>
  18044. #include <stdio.h>
  18045. int main (void)
  18046. {
  18047.     int a = 10;
  18048.     int b = 21;
  18049.     printf ("The larger of %d and %d is %d\n", a, b, max(a, b));
  18050.     return 0;
  18051.     /* The expected output is:
  18052.        The larger of 10 and 21 is 21  */
  18053. }
  18054.  
  18055.  
  18056. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18057.  
  18058. /************************************************************************
  18059. *
  18060. The following example uses mblen and mbtowc to convert a multibyte character 
  18061. into a single wide character. 
  18062.  
  18063.                                                                         *
  18064. ************************************************************************/
  18065.  
  18066. #include <stdio.h>
  18067. #include <stdlib.h>
  18068. int length, temp;
  18069. char string [6] = "w";
  18070. wchar_t arr[6];
  18071. int main(void)
  18072. {
  18073.    /* Set string to point to a multibyte character  */
  18074.    .
  18075.    .
  18076.    .
  18077.    length = mblen(string, MB_CUR_MAX);
  18078.    temp = mbtowc(arr,string,length);
  18079.    printf("wide character string: %ls",arr);
  18080. }
  18081.  
  18082.  
  18083. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18084.  
  18085. /************************************************************************
  18086. *
  18087. The following example uses mblen and mbstowcs to convert a multibyte character 
  18088. string into a wide character string. 
  18089.  
  18090.                                                                         *
  18091. ************************************************************************/
  18092.  
  18093. #include <stdio.h>
  18094. #include <stdlib.h>
  18095. int length, temp;
  18096. char string [80];
  18097. wchar_t arr[80];
  18098. int main(void)
  18099. {
  18100.    /* Set string to point to a multibyte character string. */
  18101.    .
  18102.    .
  18103.    .
  18104.    length = mblen(string, MB_CUR_MAX);
  18105.    temp = mbstowcs(arr,string,length);
  18106.    printf("wide character string: %ls",arr);
  18107. }
  18108.  
  18109.  
  18110. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18111.  
  18112. /************************************************************************
  18113. *
  18114. The following example uses mblen and mbtowc to convert a multibyte character 
  18115. into a single wide character. 
  18116.  
  18117.                                                                         *
  18118. ************************************************************************/
  18119.  
  18120. #include <stdio.h>
  18121. #include <stdlib.h>
  18122. int length, temp;
  18123. char string [6];
  18124. wchar_t arr[6];
  18125. int main(void)
  18126. {
  18127.    /* Set string to point to a multibyte character. */
  18128.    .
  18129.    .
  18130.    .
  18131.    length = mblen(string, MB_CUR_MAX);
  18132.    temp = mbtowc(arr,string,length);
  18133.    printf("wide character string: %ls",arr);
  18134. }
  18135.  
  18136.  
  18137. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18138.  
  18139. /************************************************************************
  18140. *
  18141. The following example copies up to 55 characters, or until it copies the '.' 
  18142. character, from the source to the buffer. 
  18143.  
  18144.                                                                         *
  18145. ************************************************************************/
  18146.  
  18147. #include <stdio.h>
  18148. #include <stdlib.h>
  18149. #include <string.h>
  18150. char source[60];
  18151. char result[60];
  18152. int main(void)
  18153. {
  18154.     memcpy(source,"This is the string. This part won't be copied.", 55);
  18155.     if (memccpy(result, source, '.', 55) == NULL)
  18156.     {
  18157.        printf("Error in copying source.\n");
  18158.        exit(1);
  18159.     }
  18160.     else
  18161.        printf("%s\n", result);
  18162.     return 0;
  18163.     /* The expected output is:
  18164.        This is the string.     */
  18165. }
  18166.  
  18167.  
  18168. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18169.  
  18170. /************************************************************************
  18171. *
  18172. The following example finds the first occurence of "x" in the string that you 
  18173. provide. If it is found, the string which starts with that character is 
  18174. printed. 
  18175.  
  18176.                                                                         *
  18177. ************************************************************************/
  18178.  
  18179. #include <stdio.h>
  18180. #include <string.h>
  18181. int main(int argc, char ** argv) {
  18182.   char * result;
  18183.   if ( argc != 2 )
  18184.     printf( "Usage: %s string\n", argv[0] );
  18185.   else {
  18186.     if ((result = memchr( argv[1], 'x', strlen(argv[1])) ) != NULL)
  18187.       printf( "The string starting with x is %s\n", result );
  18188.     else
  18189.       printf( "The letter x cannot be found in the string\n" );
  18190.   }
  18191. }
  18192.  
  18193. /************************************************************************
  18194. *
  18195.  
  18196. /********************  Output should be similar to:  **************
  18197. The string starting with x is xing
  18198. */
  18199.  
  18200.                                                                         *
  18201. ************************************************************************/
  18202.  
  18203.  
  18204. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18205.  
  18206. /************************************************************************
  18207. *
  18208. The following example compares first and second arguments passed to main to 
  18209. determine which, if either, is greater. 
  18210.  
  18211.                                                                         *
  18212. ************************************************************************/
  18213.  
  18214. #include <stdio.h>
  18215. #include <string.h>
  18216. int main(int argc, char ** argv) {
  18217.   int  len;
  18218.   int  result;
  18219.   if ( argc != 3 ) {
  18220.      printf( "Usage: %s string1 string2\n", argv[0] );
  18221.   }
  18222.   else {
  18223.      /* Determine the length to be used for comparison */
  18224.      if (strlen( argv[1] ) < strlen( argv[2] ))
  18225.        len = strlen( argv[1] );
  18226.      else
  18227.        len = strlen( argv[2] );
  18228.      result = memcmp( argv[1], argv[2], len );
  18229.      printf( "When the first %i characters are compared,\n", len );
  18230.      if ( result == 0 )
  18231.        printf( "\"%s\" is identical to \"%s\"\n", argv[1], argv[2] );
  18232.      else if ( result < 0 )
  18233.        printf( "\"%s\" is less than \"%s\"\n", argv[1], argv[2] );
  18234.      else
  18235.        printf( "\"%s\" is greater than \"%s\"\n", argv[1], argv[2] );
  18236.   }
  18237. }
  18238.  
  18239. /************************************************************************
  18240. *
  18241.  
  18242. /****************  If the program is passed the arguments  **************
  18243. *************  firststring and secondstring,  *****
  18244. ********************  output should be:  *************************
  18245. When the first 11 characters are compared,
  18246. "firststring" is less than "secondstring"
  18247. */
  18248.  
  18249.                                                                         *
  18250. ************************************************************************/
  18251.  
  18252.  
  18253. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18254.  
  18255. /************************************************************************
  18256. *
  18257.  
  18258. The following example copies the contents of source to target. 
  18259.  
  18260.                                                                         *
  18261. ************************************************************************/
  18262.  
  18263. #include <string.h>
  18264. #include <stdio.h>
  18265. #define MAX_LEN 80
  18266. char source[ MAX_LEN ] = "This is the source string";
  18267. char target[ MAX_LEN ] = "This is the target string";
  18268. int main(void) {
  18269.   printf( "Before memcpy, target is \"%s\"\n", target );
  18270.   memcpy( target, source, sizeof(source));
  18271.   printf( "After memcpy, target becomes \"%s\"\n", target );
  18272. }
  18273.  
  18274. /************************************************************************
  18275. *
  18276.  
  18277. /*********************  Expected output:  ************************
  18278. Before memcpy, target is "This is the target string"
  18279. After memcpy, target becomes "This is the source string"
  18280. */
  18281.  
  18282.                                                                         *
  18283. ************************************************************************/
  18284.  
  18285.  
  18286. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18287.  
  18288. /************************************************************************
  18289. *
  18290. The following example copies two strings that each contain a substring of 29 
  18291. characters that are the same except for case. The example then compares the 
  18292. first 29 bytes without regard to case. 
  18293.  
  18294.                                                                         *
  18295. ************************************************************************/
  18296.  
  18297. #include <stdio.h>
  18298. #include <string.h>
  18299. char first[100], second[100];
  18300. int main(void)
  18301. {
  18302.     int result;
  18303.     strcpy(first, "Those Who Will Not Learn From History");
  18304.     strcpy(second,"THOSE WHO WILL NOT LEARN FROM their mistakes");
  18305.     printf("Comparing the first 29 characters of two strings.\n");
  18306.     result = memicmp(first, second, 29);
  18307.     printf("The first 29 characters of String 1 are ");
  18308.     if (result < 0)
  18309.        printf("less than String 2.\n");
  18310.     else
  18311.        if (result == 0)
  18312.           printf("equal to String 2.\n");
  18313.        else
  18314.           printf("greater than String 2.\n");
  18315.     return 0;
  18316.     /* The expected output is:
  18317.        Comparing the first 29 characters of two strings.
  18318.        The first 29 characters of String 1 are equal to String 2  */
  18319. }
  18320.  
  18321.  
  18322. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18323.  
  18324. /************************************************************************
  18325. *
  18326.  
  18327. The following example copies the word shiny from position target + 2 to 
  18328. position target + 8. 
  18329.  
  18330.                                                                         *
  18331. ************************************************************************/
  18332.  
  18333. #include <string.h>
  18334. #include <stdio.h>
  18335. #define SIZE    21
  18336. char target[SIZE] = "a shiny white sphere";
  18337. int main( void ) {
  18338.   char * p = target + 8;  /* p points at the starting character
  18339.                           of the word we want to replace */
  18340.   char * source = target + 2; /* start of "shiny" */
  18341.   printf( "Before memmove, target is \"%s\"\n", target );
  18342.   memmove( p, source, 5 );
  18343.   printf( "After memmove, target becomes \"%s\"\n", target );
  18344. }
  18345.  
  18346. /************************************************************************
  18347. *
  18348.  
  18349. /*********************  Expected output:  ************************
  18350. Before memmove, target is "a shiny white sphere"
  18351. After memmove, target becomes "a shiny shiny sphere"
  18352. */
  18353.  
  18354.                                                                         *
  18355. ************************************************************************/
  18356.  
  18357.  
  18358. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18359.  
  18360. /************************************************************************
  18361. *
  18362. The following example sets 10 bytes of the buffer to "A" and the next 10 bytes 
  18363. to "B". 
  18364.  
  18365.                                                                         *
  18366. ************************************************************************/
  18367.  
  18368. #include <string.h>
  18369. #include <stdio.h>
  18370. #define  BUF_SIZE  20
  18371. int main(void)
  18372. {
  18373.    char buffer[BUF_SIZE + 1];
  18374.    char *string;
  18375.    memset(buffer, 0, sizeof(buffer));
  18376.    string = memset(buffer,'A', 10);
  18377.    printf("\nBuffer contents: %s\n", string);
  18378.    memset(buffer+10, 'B', 10);
  18379.    printf("\nBuffer contents: %s\n", buffer);
  18380. }
  18381.  
  18382. /************************************************************************
  18383. *
  18384.  
  18385. /*******************  Output should be similar to:  ***************
  18386. Buffer contents: AAAAAAAAAA
  18387. Buffer contents: AAAAAAAAAABBBBBBBBBB
  18388. */
  18389.  
  18390.                                                                         *
  18391. ************************************************************************/
  18392.  
  18393.  
  18394. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18395.  
  18396. /************************************************************************
  18397. *
  18398. This program prints the smaller of the two values, a and b. 
  18399.  
  18400.                                                                         *
  18401. ************************************************************************/
  18402.  
  18403. #include <stdlib.h>
  18404. #include <stdio.h>
  18405. int main(void)
  18406. {
  18407.     int a = 10;
  18408.     int b = 21;
  18409.     printf ("The smaller of %d and %d is %d\n", a, b, min (a, b));
  18410.     return 0;
  18411.     /* The expected output is:
  18412.        The smaller of 10 and 21 is 10  */
  18413. }
  18414.  
  18415.  
  18416. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18417.  
  18418. /************************************************************************
  18419. *
  18420. The following program creates two new directories:  one at the root on drive 
  18421. B:, and one in the tmp subdirectory of the current working directory. 
  18422.  
  18423.                                                                         *
  18424. ************************************************************************/
  18425.  
  18426. #include <stdio.h>
  18427. #include <direct.h>
  18428. #include <string.h>
  18429. int main(void)
  18430. {
  18431.     char *dir1, *dir2;
  18432. /*  Create the directory "aleng" in the root directory of the C: drive. */
  18433.     dir1 = "c:\\aleng";
  18434.     if ((_mkdir(dir1)) == 0)
  18435.         printf("%s directory was created.\n",dir1);
  18436.     else
  18437.         printf("%s directory was not created.\n",dir1);
  18438.  
  18439. /*  Create the subdirectory "simon" in the current directory. */
  18440.     dir2 = "simon";
  18441.     if ((_mkdir(dir2)) == 0)
  18442.         printf("%s directory was created.\n",dir2);
  18443.     else
  18444.         printf("%s directory was not created.\n",dir2);
  18445. /*  Remove the directory "aleng" from the root directory of the C: drive. */
  18446.     printf("Removing directory 'aleng' from the root directory.\n");
  18447.     if (_rmdir(dir1))
  18448.        perror(NULL);
  18449.     else
  18450.        printf("%s directory was removed.\n",dir1);
  18451. /*  Remove the subdirectory "simon" from the current directory. */
  18452.     printf("Removing subdirectory 'simon' from the current directory.\n");
  18453.     if (_rmdir(dir2))
  18454.        perror(NULL);
  18455.     else
  18456.        printf("%s directory was removed.\n",dir2);
  18457.     return 0;
  18458. /*************** The output should be similar to:  ********************
  18459.    c:\aleng directory was created.
  18460.    simon directory was created.
  18461.    Removing directory 'aleng' from the root directory.
  18462.    c:\aleng directory was removed.
  18463.    Removing subdirectory 'simon' from the current directory.
  18464.    simon directory was removed.
  18465. */
  18466. }
  18467.  
  18468.  
  18469. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18470.  
  18471. /************************************************************************
  18472. *
  18473.  
  18474. The following example prints the day of the week that is 40 days and 16 hours 
  18475. from the current date. 
  18476.  
  18477.                                                                         *
  18478. ************************************************************************/
  18479.  
  18480. #include <stdio.h>
  18481. #include <time.h>
  18482. char *wday[] = { "Sunday", "Monday", "Tuesday", "Wednesday",
  18483.                  "Thursday", "Friday", "Saturday" };
  18484. int main(void)
  18485. {
  18486.   time_t t1, t3;
  18487.   struct tm *t2;
  18488.   t1 = time(NULL);
  18489.   t2 = localtime(&t1);
  18490.   t2 -> tm_mday += 40;
  18491.   t2 -> tm_hour += 16;
  18492.   t3 = mktime(t2);
  18493.   printf("40 days and 16 hours from now, it will be a %s \n",
  18494.           wday[t2 -> tm_wday]);
  18495. }
  18496.  
  18497. /************************************************************************
  18498. *
  18499.  
  18500. /*******************  Output should be similar to:  ***************
  18501. 40 days and 16 hours from now, it will be a Sunday
  18502. */
  18503.  
  18504.                                                                         *
  18505. ************************************************************************/
  18506.  
  18507.  
  18508. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18509.  
  18510. /************************************************************************
  18511. *
  18512. The following example breaks the floating-point number -14.876 into its 
  18513. fractional and integral components: 
  18514.  
  18515.                                                                         *
  18516. ************************************************************************/
  18517.  
  18518. #include <math.h>
  18519. int main(void)
  18520. {
  18521.    double x, y, d;
  18522.    x = -14.876;
  18523.    y = modf(x, &d);
  18524.    printf("x = %lf\n", x);
  18525.    printf("Integral part = %lf\n", d);
  18526.    printf("Fractional part = %lf\n", y);
  18527. }
  18528.  
  18529. /************************************************************************
  18530. *
  18531.  
  18532. /****************  Output should be similar to:  ******************
  18533. x = -14.876000
  18534. Integral part = -14.000000
  18535. Fractional part = -0.876000
  18536. */
  18537.  
  18538.                                                                         *
  18539. ************************************************************************/
  18540.  
  18541.  
  18542. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18543.  
  18544. /************************************************************************
  18545. *
  18546. This program specifies and defines four distinct functions that run 
  18547. consecutively at the completion of main: 
  18548.  
  18549.                                                                         *
  18550. ************************************************************************/
  18551.  
  18552. #include <stdio.h>
  18553. #include <stdlib.h>
  18554. int fn1(void)
  18555. {
  18556.     printf("next.\n");
  18557. }
  18558. int fn2(void)
  18559. {
  18560.     printf("run ");
  18561. }
  18562. int fn3(void)
  18563. {
  18564.     printf("is ");
  18565. }
  18566. int fn4(void)
  18567. {
  18568.     printf("This ");
  18569. }
  18570. int main(void)
  18571. {
  18572.     _onexit(fn1);
  18573.     _onexit(fn2);
  18574.     _onexit(fn3);
  18575.     _onexit(fn4);
  18576.     printf("This is run first.\n");
  18577.     return 0;
  18578. /*****************  The output should be similar to:  *******************
  18579.    This is run first.
  18580.    This is run next.
  18581. */
  18582. }
  18583.  
  18584.  
  18585. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18586.  
  18587. /************************************************************************
  18588. *
  18589.  
  18590. This program tries to open the file edopen.dat by creating it as a new file, 
  18591. truncating it if it exists and opening it so it can be read and written to. The 
  18592. open command issued also grants permission to read from and written to. 
  18593.  
  18594.                                                                         *
  18595. ************************************************************************/
  18596.  
  18597. #include <io.h>
  18598. #include <stdio.h>
  18599. #include <fcntl.h>
  18600. #include <sys\stat.h>
  18601. int main(void)
  18602. {
  18603.    int fh;
  18604.    if ( -1 == (fh = _open("edopen.dat",
  18605.       O_CREAT | O_TRUNC | O_RDWR,
  18606.       S_IREAD | S_IWRITE)))
  18607.    {
  18608.       perror("Unable to open edopen.dat");
  18609.       return 1;
  18610.    }
  18611.    printf("File was successfully opened.\n");
  18612.    if (-1 == _close(fh))
  18613.    {
  18614.       perror("close error");
  18615.       return 1;
  18616.    }
  18617.    return 0;
  18618.    /* The expected ouptut is:
  18619.       File was successfully opened.  */
  18620. }
  18621.  
  18622.  
  18623. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18624.  
  18625. /************************************************************************
  18626. *
  18627.  
  18628.                                                                         *
  18629. ************************************************************************/
  18630.  
  18631.  
  18632. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18633.  
  18634. /************************************************************************
  18635. *
  18636.  
  18637.                                                                         *
  18638. ************************************************************************/
  18639.  
  18640.  
  18641. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18642.  
  18643. /************************************************************************
  18644. *
  18645.  
  18646.                                                                         *
  18647. ************************************************************************/
  18648.  
  18649.  
  18650. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18651.  
  18652. /************************************************************************
  18653. *
  18654.  
  18655. The following example shows two versions of an API that prints out messages. 
  18656. The second version uses __parmdwords to determine whether the call was intended 
  18657. for the original or the updated version. 
  18658.  
  18659.                                                                         *
  18660. ************************************************************************/
  18661.  
  18662. #include <stdlib.h>
  18663. #include <stdio.h>
  18664. #pragma linkage(ErrorHandler, system)
  18665. int ErrorHandler(int MessageNum, int Severity); /* Extended version of API */
  18666. /* Old version API prototype --  int ErrorHandler(int MessageNum); */
  18667. #define MESSAGE1 1
  18668. #define MESSAGE2 2
  18669. #define INFORMATIONAL 3
  18670. #define WARNING       2
  18671. #define ERROR         1
  18672. #define FATAL         0
  18673. int ErrorHandler(int MessageNum, int Severity)
  18674. {
  18675.    int rc = 0;
  18676.    switch ((int)__parmdwords())
  18677.    {
  18678.    case 2: /* Extended version with Severity parameter */
  18679.       switch (Severity)
  18680.       {
  18681.          case FATAL:
  18682.             printf("Fatal Error:");
  18683.             break;
  18684.          case ERROR:
  18685.             printf("Error:");
  18686.             break;
  18687.          case WARNING:
  18688.             printf("Warning:");
  18689.             break;
  18690.          case INFORMATIONAL:
  18691.             printf("Informational:");
  18692.             break;
  18693.          default:
  18694.             rc = 1;
  18695.             printf("Bad Severity Number");
  18696.       }
  18697.       /* intentional fall through */
  18698.    case 1: /* Old version of API without Severity parameter */
  18699.       switch (MessageNum)
  18700.       {
  18701.          case MESSAGE1:
  18702.             printf("Some immensely profound message\n");
  18703.             break;
  18704.          case MESSAGE2:
  18705.             printf("Some other immensely profound message\n");
  18706.             break;
  18707.          default:
  18708.             printf("Very trivial message, why not try MESSAGE1 or MESSAGE2?\n");
  18709.             rc = 1;
  18710.       }
  18711.    }
  18712.    return rc;
  18713. }
  18714. /* Old version of main:
  18715.      int main(void)
  18716.      {
  18717.         return ErrorHandler(MESSAGE1);
  18718.      }                               */
  18719.      /* The expected output from the old version is:
  18720.         Some immensely profound message              */
  18721. /* New version of main:  */
  18722. int main(void)
  18723. {
  18724.    return ErrorHandler(MESSAGE1, FATAL);
  18725.    /* The expected output is:
  18726.       Fatal Error:Some immensely profound message  */
  18727. }
  18728.  
  18729.  
  18730. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18731.  
  18732. /************************************************************************
  18733. *
  18734. The following example tries to open a stream.  If the fopen function fails, the 
  18735. example prints a message and ends the program. 
  18736.  
  18737.                                                                         *
  18738. ************************************************************************/
  18739.  
  18740. #include <stdio.h>
  18741. #include <stdlib.h>
  18742. int main(void)
  18743. {
  18744.    FILE *fh;
  18745.    if ((fh = fopen("myfile.dat","r")) == NULL)
  18746.    {
  18747.       perror("Could not open data file");
  18748.       abort();
  18749.    }
  18750. }
  18751.  
  18752.  
  18753. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18754.  
  18755. /************************************************************************
  18756. *
  18757. The following example calculates the value of 2**3. 
  18758.  
  18759.                                                                         *
  18760. ************************************************************************/
  18761.  
  18762. #include <math.h>
  18763. int main(void)
  18764. {
  18765.    double x, y, z;
  18766.    x = 2.0;
  18767.    y = 3.0;
  18768.    z = pow(x,y);
  18769.    printf("%lf to the power of %lf is %lf\n", x, y, z);
  18770. }
  18771.  
  18772. /************************************************************************
  18773. *
  18774.  
  18775. /*****************  Output should be similar to:  *****************
  18776. 2.000000 to the power of 3.000000 is 8.000000
  18777. */
  18778.  
  18779.                                                                         *
  18780. ************************************************************************/
  18781.  
  18782.  
  18783. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18784.  
  18785. /************************************************************************
  18786. *
  18787. The following example prints data in a variety of formats: 
  18788.  
  18789.                                                                         *
  18790. ************************************************************************/
  18791.  
  18792. #include <stdio.h>
  18793. int main(void)
  18794. {
  18795.    char ch = 'h', *string = "computer";
  18796.    int count = 234, hex = 0x10, oct = 010, dec = 10;
  18797.    double fp = 251.7366;
  18798.    printf("%d   %+d    %06d     %X    %x     %o\n\n",
  18799.       count, count, count, count, count, count);
  18800.    printf("1234567890123%n4567890123456789\n\n", &count);
  18801.    printf("Value of count should be 13; count = %d\n\n", count);
  18802.    printf("%10c%5c\n\n", ch, ch);
  18803.    printf("%25s\n%25.4s\n\n", string, string);
  18804.    printf("%f    %.2f    %e    %E\n\n", fp, fp, fp, fp);
  18805.    printf("%i    %i     %i\n\n", hex, oct, dec);
  18806. }
  18807.  
  18808. /************************************************************************
  18809. *
  18810.  
  18811. /*****************  Output should be similar to:  *****************
  18812. 234   +234    000234     EA    ea     352
  18813. 12345678901234567890123456789
  18814. Value of count should be 13; count = 13
  18815.          h    h
  18816.                  computer
  18817.                      comp
  18818. 251.736600    251.74    2.517366e+02    2.517366E+02
  18819. 16    8     10
  18820. */
  18821.  
  18822.                                                                         *
  18823. ************************************************************************/
  18824.  
  18825.  
  18826. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18827.  
  18828. /************************************************************************
  18829. *
  18830. The following example writes the contents of a buffer to a data stream.  In 
  18831. this example, the body of the for statement is null because the example carries 
  18832. out the writing operation in the test expression. 
  18833.  
  18834.                                                                         *
  18835. ************************************************************************/
  18836.  
  18837. #include <stdio.h>
  18838. #define  LENGTH 80
  18839. int main(void)
  18840. {
  18841.    FILE *stream = stdout;
  18842.    int i, ch;
  18843.    char buffer[LENGTH + 1] = "Hello world";
  18844.    /* This could be replaced by using the fwrite routine */
  18845.    for ( i = 0;
  18846.         (i < sizeof(buffer)) && ((ch = putc(buffer[i], stream)) != EOF);
  18847.          ++i);
  18848. }
  18849.  
  18850. /************************************************************************
  18851. *
  18852.  
  18853. /********************  Expected output:  **************************
  18854. Hello world
  18855. */
  18856.  
  18857.                                                                         *
  18858. ************************************************************************/
  18859.  
  18860.  
  18861. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18862.  
  18863. /************************************************************************
  18864. *
  18865. The following program defines a function gchar that is similar to _getche using 
  18866. the _putch and _getch functions: 
  18867.  
  18868.                                                                         *
  18869. ************************************************************************/
  18870.  
  18871. #include <conio.h>
  18872. int gchar(void)
  18873. {
  18874.    int ch;
  18875.    ch = _getch();
  18876.    _putch(ch);
  18877.    return(ch);
  18878. }
  18879.  
  18880.  
  18881. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18882.  
  18883. /************************************************************************
  18884. *
  18885. The following example tries to change the environment variable PATH, and then 
  18886. uses getenv to get the current path. If the call to _putenv fails, the example 
  18887. writes an error message. 
  18888.  
  18889.                                                                         *
  18890. ************************************************************************/
  18891.  
  18892. #include <stdlib.h>
  18893. #include <stdio.h>
  18894. int main(void)
  18895. {
  18896.     char *pathvar;
  18897.     if ( _putenv("PATH=a:\\bin;b:\\andy") == -1 )
  18898.     {
  18899.         printf("_putenv failed - out of memory\n");
  18900.         exit(-1);
  18901.     }
  18902.     /* getting and printing the current environment path  */
  18903.     pathvar = getenv("PATH");
  18904.     printf("The current path is: %s\n", pathvar);
  18905.     return 0;
  18906.     /* The expected output is:
  18907.        The current path is: a:\bin;b:\andy   */
  18908. }
  18909.  
  18910.  
  18911. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18912.  
  18913. /************************************************************************
  18914. *
  18915. The following example writes Hello World to stdout: 
  18916.  
  18917.                                                                         *
  18918. ************************************************************************/
  18919.  
  18920. #include <stdio.h>
  18921. int main(void) {
  18922.   if ( puts("Hello World") == EOF )
  18923.     printf( "Error in puts\n" );
  18924. }
  18925.  
  18926. /************************************************************************
  18927. *
  18928.  
  18929. /************************  Expected output:  *********************
  18930. Hello World
  18931. */
  18932.  
  18933.                                                                         *
  18934. ************************************************************************/
  18935.  
  18936.  
  18937. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18938.  
  18939. /************************************************************************
  18940. *
  18941. The following statement sorts the arguments (argv) in ascending lexical 
  18942. sequence, using the comparison function compare() supplied in the example. 
  18943.  
  18944.                                                                         *
  18945. ************************************************************************/
  18946.  
  18947. #include <stdio.h>
  18948. #include <stdlib.h>
  18949. #include <string.h>
  18950.                /* Declaration of compare() as a function */
  18951. int compare(const void *, const void *);
  18952. int main (int argc, char *argv[ ])
  18953. {
  18954.    int i;
  18955.    argv++;
  18956.    argc--;
  18957.    qsort((char *)argv, argc, sizeof(char *), compare);
  18958.    for (i = 0; i < argc; ++i)
  18959.       printf("%s\n", argv[i]);
  18960.    return 0;
  18961. }
  18962. int compare (const void *arg1, const void *arg2)
  18963. {
  18964.                /* Compare all of both strings */
  18965.    return(strcmp(*(char **)arg1, *(char **)arg2));
  18966. }
  18967.  
  18968. /************************************************************************
  18969. *
  18970.  
  18971. /***********  If the program is passed the arguments:  ************
  18972. ************  Does, this, really, sort, the, arguments, correctly?,  ****
  18973. ****************  then the expected output is:  *******************
  18974. arguments
  18975. correctly?
  18976. really
  18977. sort
  18978. the
  18979. this
  18980. Does
  18981. */
  18982.  
  18983.                                                                         *
  18984. ************************************************************************/
  18985.  
  18986.  
  18987. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  18988.  
  18989. /************************************************************************
  18990. *
  18991. The following example establishes a signal handler called sig_hand for the 
  18992. signal SIGUSR1. The signal handler is called whenever the SIGUSR1 signal is 
  18993. raised and will ignore the first 9 occurrences of the signal.  On the tenth 
  18994. raised signal, it exits the program with an error code of 10.  Note that the 
  18995. signal handler must be reestablished each time it is called. 
  18996.  
  18997.                                                                         *
  18998. ************************************************************************/
  18999.  
  19000. #include <signal.h>
  19001. #include <stdio.h>
  19002. void sig_hand(int);  /* declaration of sig_hand() as a function */
  19003. int main(void)
  19004. {
  19005.    signal(SIGUSR1, sig_hand); /* set up handler for SIGUSR1 */
  19006.    .
  19007.    .
  19008.    .
  19009.    raise(SIGUSR1);   /* signal SIGUSR1 is raised */
  19010.                      /* sig_hand() is called     */
  19011. }
  19012. void sig_hand(int sig)
  19013. {
  19014.    static int count = 0;  /* initialized only once */
  19015.    count++;
  19016.    if (count == 10)  /* ignore the first 9 occurrences of this signal */
  19017.       exit(10);
  19018.    else
  19019.       signal(SIGUSR1, sig_hand);  /* set up the handler again */
  19020. }
  19021.  
  19022.  
  19023. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19024.  
  19025. /************************************************************************
  19026. *
  19027. The following example prints the first 10 random numbers generated. 
  19028.  
  19029.                                                                         *
  19030. ************************************************************************/
  19031.  
  19032. #include <stdlib.h>
  19033. #include <stdio.h>
  19034. int main(void)
  19035. {
  19036.    int x;
  19037.    for (x = 1; x <= 10; x++)
  19038.       printf("iteration %d, rand=%d\n", x, rand());
  19039. }
  19040.  
  19041. /************************************************************************
  19042. *
  19043.  
  19044. /*********************  Output should be similar to:  ************
  19045. iteration 1, rand=16838
  19046. iteration 2, rand=5758
  19047. iteration 3, rand=10113
  19048. iteration 4, rand=17515
  19049. iteration 5, rand=31051
  19050. iteration 6, rand=5627
  19051. iteration 7, rand=23010
  19052. iteration 8, rand=7419
  19053. iteration 9, rand=16212
  19054. iteration 10, rand=4086
  19055. */
  19056.  
  19057.                                                                         *
  19058. ************************************************************************/
  19059.  
  19060.  
  19061. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19062.  
  19063. /************************************************************************
  19064. *
  19065.  
  19066. The following program opens the file sample.dat and attempts to read from it: 
  19067.  
  19068.                                                                         *
  19069. ************************************************************************/
  19070.  
  19071. #include <io.h>
  19072. #include <stdio.h>
  19073. #include <stdlib.h>
  19074. #include <fcntl.h>
  19075. #include <string.h>
  19076. int main(void)
  19077. {
  19078.    int  fh;
  19079.    char buffer[20];
  19080.    memset(buffer,'\0',20);
  19081.    printf("\nCreating sample.dat.\n");
  19082.    system("echo Sample Program > sample.dat");
  19083.    if (-1 == (fh = _open("sample.dat",O_RDWR | O_APPEND)))
  19084.    {
  19085.       perror("Unable to open sample.dat.");
  19086.       return 1;
  19087.    }
  19088.    if (7 != _read(fh,buffer,7))
  19089.    {
  19090.       perror("Unable to read from sample.dat.");
  19091.       _close(fh);
  19092.       return 1;
  19093.    }
  19094.    printf("Successfully read in the following:\n%s\n ",buffer);
  19095.    _close(fh);
  19096.    return 0;
  19097. /*****************  The expected output is:  ****************************
  19098.       Creating sample.dat.
  19099.       Successfully read in the following:
  19100.       Sample
  19101. */
  19102. }
  19103.  
  19104.  
  19105. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19106.  
  19107. /************************************************************************
  19108. *
  19109. The following example allocates storage for the prompted size of array and then 
  19110. uses realloc to reallocate the block to hold the new size of the array. The 
  19111. contents of the array are printed after each allocation. 
  19112.  
  19113.                                                                         *
  19114. ************************************************************************/
  19115.  
  19116. #include <stdio.h>
  19117. #include <stdlib.h>
  19118. int main(void) {
  19119.   long * array;    /* start of the array */
  19120.   long * ptr;      /* pointer to array   */
  19121.   int    i;        /* index variable     */
  19122.   int  num1, num2; /* number of entries of the array */
  19123.   void print_array( long *ptr_array, int size);
  19124.   printf( "Enter the size of the array\n" );
  19125.   scanf( "%i", &num1 );
  19126.   /* allocate num1 entries using malloc() */
  19127.   if ( (array = malloc( num1 * sizeof( long ))) != NULL ) {
  19128.      for ( ptr = array, i = 0; i < num1 ; ++i ) /* assign values */
  19129.         *ptr++ = i;
  19130.      print_array( array, num1 );
  19131.      printf("\n");
  19132.   }
  19133.   else { /*  malloc error  */
  19134.     perror( "Out of storage" );
  19135.     abort();
  19136.   }
  19137.   /* Change the size of the array ... */
  19138.   printf( "Enter the size of the new array\n" );
  19139.   scanf( "%i", &num2);
  19140.   if ( (array = realloc( array, num2* sizeof( long ))) != NULL ) {
  19141.      for ( ptr = array + num1, i = num1; i <= num2; ++i )
  19142.         *ptr++ = i + 2000;  /* assign values to new elements */
  19143.      print_array( array, num2 );
  19144.   }
  19145.   else { /* realloc error */
  19146.     perror( "Out of storage" );
  19147.     abort();
  19148.   }
  19149. }
  19150. void print_array( long  * ptr_array, int size ) {
  19151.   int i;
  19152.   long * index = ptr_array;
  19153.   printf("The array of size %d is:\n", size);
  19154.   for ( i = 0; i < size; ++i )           /* print the array out    */
  19155.     printf( "  array[ %i ] = %li\n", i, ptr_array[i] );
  19156. }
  19157.  
  19158. /************************************************************************
  19159. *
  19160.  
  19161. /******************  If the initial value entered  *********************
  19162. **************  is 2 and the second value entered is 4,  ****************
  19163. *******************  then the expected output is:  ****************
  19164. Enter the size of the array
  19165. The array of size 2 is:
  19166.   array[ 0 ] = 0
  19167.   array[ 1 ] = 1
  19168. Enter the size of the new array
  19169. The array of size 4 is:
  19170.   array[ 0 ] = 0
  19171.   array[ 1 ] = 1
  19172.   array[ 2 ] = 2002
  19173.   array[ 3 ] = 2003
  19174. */
  19175.  
  19176.                                                                         *
  19177. ************************************************************************/
  19178.  
  19179.  
  19180. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19181.  
  19182. /************************************************************************
  19183. *
  19184. When you invoke the following example with a file name, the program will 
  19185. attempt to remove that file. It will issue a message if an error occurs. 
  19186.  
  19187.                                                                         *
  19188. ************************************************************************/
  19189.  
  19190. #include <stdio.h>
  19191. int main(int argc, char ** argv) {
  19192.   if ( argc != 2 )
  19193.     printf( "Usage: %s fn\n", argv[0] );
  19194.   else
  19195.     if ( remove( argv[1] ) != 0 )
  19196.       perror( "Could not remove file" );
  19197. }
  19198.  
  19199.  
  19200. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19201.  
  19202. /************************************************************************
  19203. *
  19204. When you pass two file names to this example, it will try to change the file 
  19205. name from the first name to the second using rename. 
  19206.  
  19207.                                                                         *
  19208. ************************************************************************/
  19209.  
  19210. #include <stdio.h>
  19211. int main(int argc, char ** argv ) {
  19212.   if ( argc != 3 )
  19213.     printf( "Usage: %s old_fn new_fn\n", argv[0] );
  19214.   else if ( rename( argv[1], argv[2] ) != 0 )
  19215.     perror ( "Could not rename file" );
  19216. }
  19217.  
  19218.  
  19219. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19220.  
  19221. /************************************************************************
  19222. *
  19223. This program first opens a file myfile for input and output.  It writes 
  19224. integers to the file, uses rewind to reposition the file pointer to the 
  19225. beginning of the file, and then reads the data back in. 
  19226.  
  19227.                                                                         *
  19228. ************************************************************************/
  19229.  
  19230. #include <stdio.h>
  19231. FILE *stream;
  19232. int data1, data2, data3, data4;
  19233. int main(void)
  19234. {
  19235.    data1 = 1; data2 = -37;
  19236.       /* Place data in the file */
  19237.    stream = fopen("myfile.dat", "w+");
  19238.    fprintf(stream, "%d %d\n", data1, data2);
  19239.       /* Now read the data file */
  19240.    rewind(stream);
  19241.    fscanf(stream, "%d", &data3);
  19242.    fscanf(stream, "%d", &data4);
  19243.    printf("The values read back in are: %d and %d\n",
  19244.        data3, data4);
  19245. }
  19246.  
  19247. /************************************************************************
  19248. *
  19249.  
  19250. /********************  Output should be similar to:  **************
  19251. The values read back in are: 1 and -37
  19252. */
  19253.  
  19254.                                                                         *
  19255. ************************************************************************/
  19256.  
  19257.  
  19258. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19259.  
  19260. /************************************************************************
  19261. *
  19262. The following program deletes two directories. One is in the root directory and 
  19263. the other one in the current working directory: 
  19264.  
  19265.                                                                         *
  19266. ************************************************************************/
  19267.  
  19268. #include <stdio.h>
  19269. #include <direct.h>
  19270. #include <string.h>
  19271. int main(void)
  19272. {
  19273.     char *dir1, *dir2;
  19274. /*  Create the directory "aleng" in the root directory of the C: drive. */
  19275.     dir1 = "c:\\aleng";
  19276.     if ((_mkdir(dir1)) == 0)
  19277.         printf("%s directory was created.\n",dir1);
  19278.     else
  19279.         printf("%s directory was not created.\n",dir1);
  19280.  
  19281. /*  Create the subdirectory "simon" in the current directory. */
  19282.     dir2 = "simon";
  19283.     if ((_mkdir(dir2)) == 0)
  19284.         printf("%s directory was created.\n",dir2);
  19285.     else
  19286.         printf("%s directory was not created.\n",dir2);
  19287. /*  Remove the directory "aleng" from the root directory of the C: drive. */
  19288.     printf("Removing directory 'aleng' from the root directory.\n");
  19289.     if (_rmdir(dir1))
  19290.        perror(NULL);
  19291.     else
  19292.        printf("%s directory was removed.\n",dir1);
  19293. /*  Remove the subdirectory "simon" from the current directory. */
  19294.     printf("Removing subdirectory 'simon' from the current directory.\n");
  19295.     if (_rmdir(dir2))
  19296.        perror(NULL);
  19297.     else
  19298.        printf("%s directory was removed.\n",dir2);
  19299.     return 0;
  19300. /*************** The output should be similar to:  ********************
  19301.    c:\aleng directory was created.
  19302.    simon directory was created.
  19303.    Removing directory 'aleng' from the root directory.
  19304.    c:\aleng directory was removed.
  19305.    Removing subdirectory 'simon' from the current directory.
  19306.    simon directory was removed.
  19307. */
  19308. }
  19309.  
  19310.  
  19311. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19312.  
  19313. /************************************************************************
  19314. *
  19315. The following example uses _rmtmp to remove a number of temporary files. 
  19316.  
  19317.                                                                         *
  19318. ************************************************************************/
  19319.  
  19320. #include <stdio.h>
  19321. int main(void)
  19322. {
  19323.     int num;
  19324.     FILE *stream;
  19325.     if ( (stream = tmpfile()) == NULL )
  19326.         printf("Could not open new temporary file\n");
  19327.     else
  19328.     {
  19329.         num = _rmtmp();
  19330.         printf("Number of temporary files removed = %d\n", num);
  19331.     }
  19332.     return 0;
  19333.     /* The expected output is:
  19334.        Number of temporary files removed = 1   */
  19335. }
  19336.  
  19337.  
  19338. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19339.  
  19340. /************************************************************************
  19341. *
  19342. This program uses _rotr and _rotl with different shift values to rotate the 
  19343. integer value 0x01234567: 
  19344.  
  19345.                                                                         *
  19346. ************************************************************************/
  19347.  
  19348. #include <stdio.h>
  19349. #include <stdlib.h>
  19350. int main(void)
  19351. {
  19352.     unsigned int val = 0X01234567;
  19353.     printf("The value of 0x%8.8lx rotated 4 bits to the left is 0x%8.8lx\n",
  19354.                                         val, _rotl(val, 4));
  19355.     printf("The value of 0x%8.8lx rotated 16 bits to the right is 0x%8.8lx\n",
  19356.                                          val, _rotr(val, 16));
  19357.     return 0;
  19358. /***************  The output should be similar to:  ********************
  19359.    The value of 0x01234567 rotated 4 bits to the left is 0x12345670
  19360.    The value of 0x01234567 rotated 16 bits to the right is 0x45670123
  19361. */
  19362. }
  19363.  
  19364.  
  19365. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19366.  
  19367. /************************************************************************
  19368. *
  19369. The following example scans various types of data: 
  19370.  
  19371.                                                                         *
  19372. ************************************************************************/
  19373.  
  19374. #include <stdio.h>
  19375. int main(void)
  19376. {
  19377.    int i;
  19378.    float fp;
  19379.    char c, s[81];
  19380.    printf("Enter an integer, a real number, a character "
  19381.           "and a string : \n");
  19382.    if (scanf("%d %f %c %s", &i, &fp, &c, s) != 4)
  19383.       printf("Not all of the fields were not assigned\n");
  19384.    else {
  19385.       printf("integer = %d\n", i);
  19386.       printf("real number = %f\n", fp);
  19387.       printf("character = %c\n", c);
  19388.       printf("string = %s\n",s);
  19389.    }
  19390. }
  19391.  
  19392. /************************************************************************
  19393. *
  19394.  
  19395. /*****************  If input is: 12 2.5 a yes,  *******************
  19396. **************  then output should be similar to:  ****************
  19397. Enter an integer, a real number, a character and a string :
  19398. integer = 12
  19399. real number = 2.500000
  19400. character = a
  19401. string = yes
  19402. */
  19403.  
  19404.                                                                         *
  19405. ************************************************************************/
  19406.  
  19407. /************************************************************************
  19408. *
  19409. The following example converts a hexadecimal integer to a decimal integer.  The 
  19410. while loop ends if the input value is not a hexadecimal integer. 
  19411.  
  19412.                                                                         *
  19413. ************************************************************************/
  19414.  
  19415. #include <stdio.h>
  19416. int main(void)
  19417. {
  19418.    int number;
  19419.    printf("Enter a hexadecimal number or anything else to quit:\n");
  19420.    while (scanf("%x",&number))
  19421.       {
  19422.       printf("Hexadecimal Number = %x\n",number);
  19423.       printf("Decimal Number     = %d\n",number);
  19424.       }
  19425. }
  19426.  
  19427. /************************************************************************
  19428. *
  19429.  
  19430. /***************  If input is: 0x231 0xf5e 0x1 q,  ****************
  19431. ****************  then output should be similar to:  **************
  19432. Enter a hexadecimal number or anything else to quit:
  19433. Hexadecimal Number = 231
  19434. Decimal Number     = 561
  19435. Hexadecimal Number = f5e
  19436. Decimal Number     = 3934
  19437. Hexadecimal Number = 1
  19438. Decimal Number     = 1
  19439. */
  19440.  
  19441.                                                                         *
  19442. ************************************************************************/
  19443.  
  19444.  
  19445. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19446.  
  19447. /************************************************************************
  19448. *
  19449.  
  19450. The following program searches for the files searchen.c and cmd.exe: 
  19451.  
  19452.                                                                         *
  19453. ************************************************************************/
  19454.  
  19455. #include <stdio.h>
  19456. #include <stdlib.h>
  19457. int main(void)
  19458. {
  19459.     char path_buffer [_MAX_PATH];
  19460.     _searchenv ("cmd.exe", "PATH", path_buffer);
  19461.     printf ("path: %s\n", path_buffer);
  19462.     _searchenv ("searchen.c", "DPATH", path_buffer);
  19463.     printf ("path: %s\n", path_buffer);
  19464.     return 0;
  19465. /***********************  Output  ***************************************
  19466. *  If the first path that contains cmd.exe is in the C: environment and *
  19467. *  this program is not run from another directory with a cmd.exe file,  *
  19468. *  the first line of the output should be similar to:                   *
  19469.    path: C:\OS2\cmd.exe                                                    */
  19470. *  Assuming the file searchen.c does not exist in the current directory *
  19471. *  or any of the directories in the environment,                        *
  19472. *  the next line of the output should be similar to:                    *
  19473.    path:
  19474. */
  19475. }
  19476.  
  19477.  
  19478. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19479.  
  19480. /************************************************************************
  19481. *
  19482. The following example opens the file myfile for writing. It then calls the 
  19483. setbuf function to establish a buffer of length BUFSIZ. When string is written 
  19484. to the stream, the buffer buf is used and contains the string before it is 
  19485. flushed to the file. 
  19486.  
  19487.                                                                         *
  19488. ************************************************************************/
  19489.  
  19490. #include <stdio.h>
  19491. int main(void)
  19492. {
  19493.    char buf[BUFSIZ];
  19494.    char string[] = "hello world";
  19495.    FILE *stream;
  19496.    memset(buf,'\0',BUFSIZ);  /* initialize buf to null characters */
  19497.    stream = fopen("myfile.dat", "wb");
  19498.    setbuf(stream,buf);       /* set up buffer */
  19499.    fwrite(string, sizeof(string), 1, stream);
  19500.    printf("%s\n",buf);       /* string is found in buf now */
  19501.    fclose(stream);           /* buffer is flushed out to myfile.dat */
  19502. }
  19503.  
  19504.  
  19505. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19506.  
  19507. /************************************************************************
  19508. *
  19509. The following saves the stack environment at the statement: 
  19510.  
  19511.   if(setjmp(mark) != 0) ...
  19512.  
  19513. When the system first performs the if statement, it saves the environment in 
  19514. mark and sets the condition to FALSE because setjmp returns a 0 when it saves 
  19515. the environment. The program prints the message: 
  19516.  
  19517.   setjmp has been called
  19518.  
  19519. The subsequent call to function p tests for a local error condition, which can 
  19520. cause it to perform the longjmp function.  Then, control returns to the 
  19521. original setjmp function using the environment saved in mark.  This time the 
  19522. condition is TRUE because -1 is the return value from the longjmp function. The 
  19523. program then performs the statements in the block and prints: 
  19524.  
  19525.   longjmp has been called
  19526.  
  19527. Then the program performs your recover function and exits. 
  19528.  
  19529.                                                                         *
  19530. ************************************************************************/
  19531.  
  19532. #include <stdio.h>
  19533. #include <setjmp.h>
  19534. jmp_buf mark;
  19535. void p(void);
  19536. void recover(void);
  19537. int main(void)
  19538. {
  19539.    if (setjmp(mark) != 0) {
  19540.       printf("longjmp has been called\n");
  19541.       recover();
  19542.       exit(1);
  19543.       }
  19544.    printf("setjmp has been called\n");
  19545.    .
  19546.    .
  19547.    .
  19548.    p();
  19549.    .
  19550.    .
  19551.    .
  19552. }
  19553. void p(void)
  19554. {
  19555.    int error = 0;
  19556.    .
  19557.    .
  19558.    .
  19559.    error = 9;
  19560.    .
  19561.    .
  19562.    .
  19563.    if (error != 0)
  19564.       longjmp(mark, -1);
  19565.    .
  19566.    .
  19567.    .
  19568. }
  19569. void recover(void)
  19570. {
  19571.    .
  19572.    .
  19573.    .
  19574. }
  19575.  
  19576.  
  19577. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19578.  
  19579. /************************************************************************
  19580. *
  19581.  
  19582. This example sets the locale of the program to be LC_C_FRANCE and prints the 
  19583. string that is associated with the locale. 
  19584.  
  19585.                                                                         *
  19586. ************************************************************************/
  19587.  
  19588. #include <stdio.h>
  19589. #include <locale.h>
  19590. char *string;
  19591. int main(void)
  19592. {
  19593.    string = setlocale(LC_ALL, LC_C_FRANCE);
  19594.    if (string != NULL)
  19595.       printf(" %s \n",string);
  19596. }
  19597.  
  19598.  
  19599. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19600.  
  19601. /************************************************************************
  19602. *
  19603.  
  19604. The following program uses open to create the file SETMODE.DAT and writes to 
  19605. it. The program then uses _setmode to change the translation mode of 
  19606. SETMODE.DAT from binary to text. 
  19607.  
  19608.                                                                         *
  19609. ************************************************************************/
  19610.  
  19611. #include <stdio.h>
  19612. #include <stdlib.h>
  19613. #include <fcntl.h>
  19614. #include <io.h>
  19615. #include <sys\stat.h>
  19616. #define FILENAME "SETMODE.DAT"
  19617. /* routine to validate return codes */
  19618. void ckrc(rc) {
  19619.    if ((rc) == -1) {
  19620.       printf("Unexpected return code = -1\n");
  19621.       _exit(1);
  19622.    }
  19623. }
  19624. int main(void) {
  19625.    int h;
  19626.    int xfer;
  19627.    int mode;
  19628.    char rbuf[256];
  19629.    char wbuf[] = "123\n456\n";
  19630.    ckrc(h =  _open(FILENAME,
  19631.     O_CREAT | O_RDWR |
  19632.     O_TRUNC | O_TEXT,
  19633.     S_IREAD | S_IWRITE));
  19634.    ckrc(_write(h,wbuf,sizeof(wbuf)));   /* write the file (text) */
  19635.    ckrc(_lseek(h,0,SEEK_SET)); /* seek back to the start of the file */
  19636.    ckrc(xfer = _read(h,rbuf,5));        /* read the file text */
  19637.    printf("Read in %d characters (4 expected)\n",xfer);
  19638.  
  19639.    ckrc(mode = _setmode(h,O_BINARY));
  19640.    if (mode == O_TEXT) printf("Mode changed from binary to text\n");
  19641.    else printf("Previous mode was not text (unexpected)\n");
  19642.    ckrc(xfer = _read(h,rbuf,5));        /* read the file (binary) */
  19643.    printf("Read in %d characters (5 expected)\n",xfer);
  19644.    ckrc(_close(h));
  19645.    remove (FILENAME);
  19646.    return 0;
  19647. /****************  The expected output is:  *****************************
  19648.       Read in 4 characters (4 expected)
  19649.       Mode changed from binary to text
  19650.       Read in 5 characters (5 expected)
  19651. */
  19652. }
  19653.  
  19654.  
  19655. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19656.  
  19657. /************************************************************************
  19658. *
  19659.  
  19660. The following example sets up a buffer of buf for stream1 and specifies that 
  19661. input to stream2 is to be unbuffered. 
  19662.  
  19663.                                                                         *
  19664. ************************************************************************/
  19665.  
  19666. #include <stdio.h>
  19667. #define  BUF_SIZE  1024
  19668. char buf[BUF_SIZE];
  19669. FILE *stream1, *stream2;
  19670. int main(void)
  19671. {
  19672.    stream1 = fopen("myfile1.dat", "r");
  19673.    stream2 = fopen("myfile2.dat", "r");
  19674.    /* stream1 uses a user-assigned buffer of BUF_SIZE bytes */
  19675.    if (setvbuf(stream1, buf, _IOFBF, sizeof(buf)) != 0)
  19676.       printf("Incorrect type or size of buffer\n");
  19677.    /* stream2 is unbuffered                                  */
  19678.    if (setvbuf(stream2, NULL, _IONBF, 0) != 0)
  19679.       printf("Incorrect type or size of buffer\n");
  19680.    .
  19681.    .
  19682.    .
  19683. }
  19684.  
  19685.  
  19686. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19687.  
  19688. /************************************************************************
  19689. *
  19690. In the following example, the call to signal in main establishes the function 
  19691. handler to process the interrupt signal raised by abort.  An error value 
  19692. returned from this call to signal causes the program to end with a printed 
  19693. error message. 
  19694.  
  19695.                                                                         *
  19696. ************************************************************************/
  19697.  
  19698. #include <stdio.h>
  19699. #include <signal.h>
  19700. #include <stdlib.h>
  19701. void handler(int sig)
  19702. {
  19703.     printf("Registered signal type for abort = %d\n", sig);
  19704.     printf("Abort should not flush this line");
  19705. }
  19706. int main(void)
  19707. {
  19708.     if (signal(SIGABRT, handler) == SIG_ERR)
  19709.     {
  19710.         perror("Could not set SIGABRT");
  19711.         exit(-1);
  19712.     }
  19713.     abort();   /* signal raised by abort */
  19714.     /* The expected output is:
  19715.        Registered signal type for abort = 5   */
  19716. }
  19717.  
  19718.  
  19719. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19720.  
  19721. /************************************************************************
  19722. *
  19723. The following example computes y as the sine of ╤â/2: 
  19724.  
  19725.                                                                         *
  19726. ************************************************************************/
  19727.  
  19728. #include <math.h>
  19729. int main(void)
  19730. {
  19731.    double pi, x, y;
  19732.    pi = 3.1415926535;
  19733.    x = pi/2;
  19734.    y = sin(x);
  19735.    printf("sin( %lf ) = %lf\n", x, y);
  19736. }
  19737.  
  19738. /************************************************************************
  19739. *
  19740.  
  19741. /*********************  Output should be similar to:  *************
  19742. sin( 1.570796 ) = 1.000000
  19743. */
  19744.  
  19745.                                                                         *
  19746. ************************************************************************/
  19747.  
  19748.  
  19749. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19750.  
  19751. /************************************************************************
  19752. *
  19753. The following example computes y as the hyperbolic sine of ╤â/2: 
  19754.  
  19755.                                                                         *
  19756. ************************************************************************/
  19757.  
  19758. #include <math.h>
  19759. int main(void)
  19760. {
  19761.    double pi, x, y;
  19762.    pi = 3.1415926535;
  19763.    x = pi/2;
  19764.    y = sinh(x);
  19765.    printf("sinh( %lf ) = %lf\n", x, y);
  19766. }
  19767.  
  19768. /************************************************************************
  19769. *
  19770.  
  19771. /*********************  Output should be similar to:  *************
  19772. sinh( 1.570796 ) = 2.301299
  19773. */
  19774.  
  19775.                                                                         *
  19776. ************************************************************************/
  19777.  
  19778.  
  19779. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19780.  
  19781. /************************************************************************
  19782. *
  19783.  
  19784. The following program opens the file sample.dat for shared reading and writing 
  19785. using sopen. It then opens the file for shared reading. 
  19786.  
  19787.                                                                         *
  19788. ************************************************************************/
  19789.  
  19790. #include <io.h>
  19791. #include <stdio.h>
  19792. #include <stdlib.h>
  19793. #include <fcntl.h>
  19794. #include <share.h>
  19795. int main(void)
  19796. {
  19797.    int  fh1, fh2;
  19798.    printf("\nCreating sample.dat.\n");
  19799.    system("echo Sample Program > sample.dat");
  19800.    /* share open the file for reading and writing */
  19801.    if (-1 == (fh1 = _sopen("sample.dat",O_RDWR,SH_DENYNO) ))
  19802.    {
  19803.       perror("_sopen failed");
  19804.       return 1;
  19805.    }
  19806.    /* share open the file for reading only */
  19807.    if (-1 == (fh2 = _sopen("sample.dat",O_RDONLY,SH_DENYNO) ))
  19808.    {
  19809.       perror("_sopen failed");
  19810.       _close(fh1);
  19811.       return 1;
  19812.    }
  19813.    printf("File sample.dat successfully opened for sharing.\n");
  19814.    _close(fh1);
  19815.    _close(fh2);
  19816.    return 0;
  19817. /*****************  The expected output is:  ****************************
  19818.       Creating sample.dat.
  19819.       File sample.dat successfully opened for sharing.
  19820. */
  19821. }
  19822.  
  19823.  
  19824. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19825.  
  19826. /************************************************************************
  19827. *
  19828. This program shows calls to four of the eight _spawn routines.  When called 
  19829. without arguments from the command line, the program first runs the code for 
  19830. case PARENT.  It spawns a copy of itself, waits for its child to run, then 
  19831. spawns a second child.  The instructions for the child are blocked to run only 
  19832. if argv[0] and one parameter were passed (case CHILD).  In its turn, each child 
  19833. spawns a grandchild as a copy of the same program.  The grandchild instructions 
  19834. are blocked by the existence of two passed parameters. The grandchild is 
  19835. permitted to overlay the child.  Each of the processes prints a message 
  19836. identifying itself. 
  19837.  
  19838.                                                                         *
  19839. ************************************************************************/
  19840.  
  19841. #include  <stdio.h>
  19842. #include  <process.h>
  19843. #define   PARENT        1
  19844. #define   CHILD         2
  19845. #define   GRANDCHILD    3
  19846. int main(int argc, char **argv, char **envp)
  19847. {
  19848.    int    result;
  19849.    char   *args[4];
  19850.    switch(argc)
  19851.    {
  19852.       case PARENT:     /* no argument was passed:  spawn child and wait */
  19853.          result = _spawnle(P_WAIT, argv[0], argv[0], "one", NULL, envp);
  19854.          if (result)
  19855.              abort();
  19856.          args[0] = argv[0];
  19857.          args[1] = "two";
  19858.          args[2] = NULL;
  19859.          /* spawn another child, and wait for it */
  19860.          result = _spawnve(P_WAIT, argv[0], args, envp);
  19861.          if (result)
  19862.              abort();
  19863.          printf("Parent process ended\n");
  19864.          _exit(0);
  19865.  
  19866.       case CHILD:     /* one argument passed:  allow grandchild to overlay */
  19867.          printf("child process %s began\n", argv[1]);
  19868.          if (*argv[1] == 'o')            /* child one? */
  19869.          {
  19870.             _spawnl(P_OVERLAY, argv[0], argv[0], "one", "two", NULL);
  19871.             abort();       /* not executed because child was overlaid */
  19872.          }
  19873.          if (*argv[1] == 't')            /* child two? */
  19874.          {
  19875.              args[0] = argv[0];
  19876.              args[1] = "two";
  19877.              args[2] = "one";
  19878.              args[3] = NULL;
  19879.              _spawnv(P_OVERLAY, argv[0], args);
  19880.              abort();       /* not executed because child was overlaid */
  19881.          }
  19882.          abort();       /* argument not valid */
  19883.      case GRANDCHILD:   /* two arguments passed */
  19884.         printf("grandchild %s ran\n", argv[1]);
  19885.         _exit(0);
  19886.    }
  19887. /****************  The output should be similar to:  *******************
  19888.     child process one began
  19889.     grandchild one ran
  19890.     child process two began
  19891.     Parent process ended
  19892.     grandchild two ran
  19893. */
  19894. }
  19895.  
  19896.  
  19897. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19898.  
  19899. /************************************************************************
  19900. *
  19901.  
  19902. This program builds a file name path from the specified components, and then 
  19903. extracts the individual components: 
  19904.  
  19905.                                                                         *
  19906. ************************************************************************/
  19907.  
  19908. #include <stdio.h>
  19909. #include <stdlib.h>
  19910. int main(void)
  19911. {
  19912.    char path_buffer [_MAX_PATH];
  19913.    char drive [_MAX_DRIVE];
  19914.    char dir [_MAX_DIR];
  19915.    char fname [_MAX_FNAME];
  19916.    char ext [_MAX_EXT];
  19917.    _makepath (path_buffer, "c", "qc\\bob\\eclibref\\e", "makepath", "c") ;
  19918.    printf ("Path created with _makepath: %s\n\n", path_buffer);
  19919.    _splitpath (path_buffer, drive, dir, fname, ext);
  19920.    printf ("Path extracted with _splitpath:\n");
  19921.    printf ("drive: %s\n", drive);
  19922.    printf ("directory: %s\n", dir);
  19923.    printf ("file name: %s\n", fname);
  19924.    printf ("extension: %s\n", ext);
  19925.    return 0;
  19926. /****************  The output should be similar to:  ********************
  19927.    Path created with _makepath: c:qc\bob\eclibref\e\makepath.c
  19928.    Path extracted with _splitpath:
  19929.    drive: c:
  19930.    directory: qc\bob\eclibref\e\
  19931.    file name: makepath
  19932.    extension: .c
  19933. */
  19934. }
  19935.  
  19936.  
  19937. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19938.  
  19939. #include <stdio.h>
  19940. char buffer[200];
  19941. int i, j;
  19942. double fp;
  19943. char *s = "baltimore";
  19944. char c;
  19945. int main(void)
  19946. {
  19947.    c = 'l';
  19948.    i = 35;
  19949.    fp = 1.7320508;
  19950.    /* Format and print various data */
  19951.    j = sprintf(buffer, "%s\n", s);
  19952.    j += sprintf(buffer+j, "%c\n", c);
  19953.    j += sprintf(buffer+j, "%d\n", i);
  19954.    j += sprintf(buffer+j, "%f\n", fp);
  19955.    printf("string:\n%s\ncharacter count = %d\n", buffer, j);
  19956. }
  19957.  
  19958. /************************************************************************
  19959. *
  19960.  
  19961. /*********************  Output should be similar to:  *************
  19962. string:
  19963. baltimore
  19964. l
  19965. 35
  19966. 1.732051
  19967. character count = 24
  19968. */
  19969.  
  19970.                                                                         *
  19971. ************************************************************************/
  19972.  
  19973.  
  19974. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  19975.  
  19976. /************************************************************************
  19977. *
  19978. The following example computes the square root of the quantity passed as the 
  19979. first argument to main.  It prints an error message if you pass a negative 
  19980. value. 
  19981.  
  19982.                                                                         *
  19983. ************************************************************************/
  19984.  
  19985. #include <stdio.h>
  19986. #include <stdlib.h>
  19987. #include <math.h>
  19988. int main(int argc, char ** argv) {
  19989.   char * rest;
  19990.   double value;
  19991.   if ( argc != 2 )
  19992.     printf( "Usage: %s value\n", argv[0] );
  19993.   else {
  19994.     value = strtod( argv[1], &rest );
  19995.     if ( value < 0.0 )
  19996.        perror( "sqrt of a negative number" );
  19997.     else
  19998.        printf("sqrt( %f ) = %f\n", value, sqrt( value ));
  19999.   }
  20000. }
  20001.  
  20002. /************************************************************************
  20003. *
  20004.  
  20005. /********************  If the input is 45,  *****************************
  20006. ****************  then the output should be similar to:  **********
  20007. sqrt( 45.000000 ) = 6.708204
  20008. */
  20009.  
  20010.                                                                         *
  20011. ************************************************************************/
  20012.  
  20013.  
  20014. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20015.  
  20016. /************************************************************************
  20017. *
  20018. First, this program calls srand with a value other than 1 to initiate the 
  20019. random value sequence.  Then the program computes 5 random values for the array 
  20020. of integers called ranvals. 
  20021.  
  20022.                                                                         *
  20023. ************************************************************************/
  20024.  
  20025. #include <stdlib.h>
  20026. #include <stdio.h>
  20027. int main(void)
  20028. {
  20029.    int i, ranvals[5];
  20030.    srand(17);
  20031.    for (i = 0; i < 5; i++) {
  20032.       ranvals[i] = rand();
  20033.       printf("Iteration %d ranvals [%d] = %d\n", i+1, i, ranvals[i]);
  20034.    }
  20035. }
  20036.  
  20037. /************************************************************************
  20038. *
  20039.  
  20040. /******************  Output should be similar to:  ****************
  20041. Iteration 1 ranvals [0] = 24107
  20042. Iteration 2 ranvals [1] = 16552
  20043. Iteration 3 ranvals [2] = 12125
  20044. Iteration 4 ranvals [3] = 9427
  20045. Iteration 5 ranvals [4] = 13152
  20046. */
  20047.  
  20048.                                                                         *
  20049. ************************************************************************/
  20050.  
  20051.  
  20052. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20053.  
  20054. /************************************************************************
  20055. *
  20056. This program uses sscanf to read various data from the string tokenstring, and 
  20057. then displays it. 
  20058.  
  20059.                                                                         *
  20060. ************************************************************************/
  20061.  
  20062. #include <stdio.h>
  20063. #define  SIZE  81
  20064. char *tokenstring = "15 12 14";
  20065. int i;
  20066. float fp;
  20067. char s[SIZE];
  20068. char c;
  20069. int main(void)
  20070. {
  20071.    /* Input various data                              */
  20072.    sscanf(tokenstring, "%s %c%d%f", s, &c, &i, &fp);
  20073.    /* If there were no space between %s and %c,       */
  20074.    /* sscanf would read the first character following */
  20075.    /* the string, which is a blank space.             */
  20076.    /* Display the data */
  20077.    printf("string = %s\n",s);
  20078.    printf("character = %c\n",c);
  20079.    printf("integer = %d\n",i);
  20080.    printf("floating-point number = %f\n",fp);
  20081. }
  20082.  
  20083. /************************************************************************
  20084. *
  20085.  
  20086. /*****************  Output should be similar to:  *****************
  20087. string = 15
  20088. character = 1
  20089. integer = 2
  20090. floating-point number = 14.000000
  20091. */
  20092.  
  20093.                                                                         *
  20094. ************************************************************************/
  20095.  
  20096.  
  20097. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20098.  
  20099. /************************************************************************
  20100. *
  20101.  
  20102. The following program requests that the status information for the file 
  20103. test.exe be placed into the structure buf.  If the request is successful and 
  20104. the file is executable, the example runs test.exe. 
  20105.  
  20106.                                                                         *
  20107. ************************************************************************/
  20108.  
  20109. #include <sys\types.h>
  20110. #include <sys\stat.h>
  20111. #include <process.h>
  20112. #include <stdio.h>
  20113. int main(void)
  20114. {
  20115.     struct stat buf;
  20116.     if (_stat("test.exe", &buf) == 0)
  20117.     {
  20118.         if ( (buf.st_mode & S_IFREG) && (buf.st_mode & S_IEXEC) )
  20119.             _execl("test.exe", "test", NULL);      /* file is executable */
  20120.     }
  20121.     else
  20122.         printf("File could not be found\n");
  20123.     return 0;
  20124.         /* The source for test.exe                                             */
  20125.         /*                                                                     */
  20126.         /*  #include <stdio.h>                                                 */
  20127.         /*  int main(void)                                                     */
  20128.         /*  {                                                                  */
  20129.         /*      puts("test.exe is an executable file");                        */
  20130.         /*  }                                                                  */
  20131.         /*                                                                     */
  20132. /***************  The output should be similar to:  *********************
  20133.    test.exe is an executable file
  20134. */
  20135. }
  20136.  
  20137.  
  20138. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20139.  
  20140. /************************************************************************
  20141. *
  20142.  
  20143. The following example uses _status87 to get the value of the floating-point 
  20144. status word. 
  20145.  
  20146.                                                                         *
  20147. ************************************************************************/
  20148.  
  20149. #include <stdio.h>
  20150. #include <float.h>
  20151. double a = 1e-40, b;
  20152. float x, y;
  20153. int main(void)
  20154. {
  20155.     printf("status = 0x%.4x - clear\n", _status87( ));
  20156.    /* change control word to mask all exceptions */
  20157.     _control87(0x037f,0xffff);
  20158.     y = a;         /* store into y is inexact and causes underflow */
  20159.     printf("status = 0x%.4X - inexact, underflow\n", _status87( ));
  20160.    /* reinitialize the floating point unit */
  20161.     _fpreset();
  20162.    /* change control word to mask all exceptions */
  20163.     _control87(0x037f,0xffff);
  20164.     b = y;         /* y is denormal */
  20165.     printf("status = 0x%.4X - denormal\n", _status87());
  20166.    /* reinitialize the floating point unit */
  20167.     _fpreset();
  20168.    return 0;
  20169.    /* The expected output is:
  20170.       status = 0x0000 - clear
  20171.       status = 0x0030 - inexact, underflow
  20172.       status = 0x0002 - denormal                */
  20173. }
  20174.  
  20175.  
  20176. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20177.  
  20178. /************************************************************************
  20179. *
  20180. This program creates the string "computer program" using strcat. 
  20181.  
  20182.                                                                         *
  20183. ************************************************************************/
  20184.  
  20185. #include <stdio.h>
  20186. #include <string.h>
  20187. #define SIZE 40
  20188. int main(void) {
  20189.   char buffer1[SIZE] = "computer";
  20190.   char * ptr;
  20191.   ptr = strcat( buffer1, " program" );
  20192.   printf( "buffer1 = %s\n", buffer1 );
  20193. }
  20194.  
  20195. /************************************************************************
  20196. *
  20197.  
  20198. /*****************  Output should be similar to:  *****************
  20199. computer program
  20200. */
  20201.  
  20202.                                                                         *
  20203. ************************************************************************/
  20204.  
  20205.  
  20206. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20207.  
  20208. /************************************************************************
  20209. *
  20210. This program finds the first occurrence of the character p in "computer 
  20211. program". 
  20212.  
  20213.                                                                         *
  20214. ************************************************************************/
  20215.  
  20216. #include <stdio.h>
  20217. #include <string.h>
  20218. #define SIZE 40
  20219. int main(void) {
  20220.   char buffer1[SIZE] = "computer program";
  20221.   char * ptr;
  20222.   int    ch = 'p';
  20223.   ptr = strchr( buffer1, ch );
  20224.   printf( "The first occurrence of %c in '%s' is '%s'\n", ch, buffer1, ptr );
  20225. }
  20226.  
  20227. /************************************************************************
  20228. *
  20229.  
  20230. /*****************  Output should be similar to:  *****************
  20231. The first occurrence of p in 'computer program' is 'puter program'
  20232. */
  20233.  
  20234.                                                                         *
  20235. ************************************************************************/
  20236.  
  20237.  
  20238. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20239.  
  20240. /************************************************************************
  20241. *
  20242. This program compares the two strings passed to main using strcmp. 
  20243.  
  20244.                                                                         *
  20245. ************************************************************************/
  20246.  
  20247. #include <stdio.h>
  20248. #include <string.h>
  20249. int main(int argc, char ** argv) {
  20250.   int  result;
  20251.   if ( argc != 3 ) {
  20252.     printf( "Usage: %s string1 string2\n", argv[0] );
  20253.   }
  20254.   else {
  20255.     result = strcmp( argv[1], argv[2] );
  20256.     if ( result == 0 )
  20257.       printf( "\"%s\" is identical to \"%s\"\n", argv[1], argv[2] );
  20258.     else if ( result < 0 )
  20259.       printf( "\"%s\" is less than \"%s\"\n", argv[1], argv[2] );
  20260.     else
  20261.       printf( "\"%s\" is greater than \"%s\"\n", argv[1], argv[2] );
  20262.   }
  20263. }
  20264.  
  20265. /************************************************************************
  20266. *
  20267.  
  20268. /****************  If the input is the strings  *************************
  20269. ***********  "is this first?" and "is this before that one?",  **********
  20270. ******************  then the expected output is:  *****************
  20271. "is this first?" is greater than "is this before that one?"
  20272. */
  20273.  
  20274.                                                                         *
  20275. ************************************************************************/
  20276.  
  20277.  
  20278. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20279.  
  20280. /************************************************************************
  20281. *
  20282.  
  20283. This program uses strcmpi to compare two strings: 
  20284.  
  20285.                                                                         *
  20286. ************************************************************************/
  20287.  
  20288. #include <stdio.h>
  20289. #include <string.h>
  20290. int main(void)
  20291. {
  20292.     /* Compare two strings without regard to case */
  20293.     if (0 == strcmpi("hello","HELLO"))
  20294.        printf("The strings are equivalent.\n");
  20295.     else
  20296.        printf("The strings are not equivalent.\n");
  20297.     return 0;
  20298. /***************  The output should be similar to:  *********************
  20299.      The strings are equivalent.
  20300. */
  20301. }
  20302.  
  20303.  
  20304. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20305.  
  20306. /************************************************************************
  20307. *
  20308. This program compares the two strings passed to main. 
  20309.  
  20310.                                                                         *
  20311. ************************************************************************/
  20312.  
  20313. #include <stdio.h>
  20314. #include <string.h>
  20315. int main(int argc, char ** argv) {
  20316.   int  result;
  20317.   if ( argc != 3 ) {
  20318.     printf( "Usage: %s string1 string2\n", argv[0] );
  20319.   }
  20320.   else {
  20321.     result = strcoll( argv[1], argv[2] );
  20322.     if ( result == 0 )
  20323.       printf( "\"%s\" is identical to \"%s\"\n", argv[1], argv[2] );
  20324.     else if ( result < 0 )
  20325.       printf( "\"%s\" is less than \"%s\"\n", argv[1], argv[2] );
  20326.     else
  20327.       printf( "\"%s\" is greater than \"%s\"\n", argv[1], argv[2] );
  20328.   }
  20329. }
  20330.  
  20331. /************************************************************************
  20332. *
  20333.  
  20334. /******************  If the input is the strings  ***********************
  20335. ****************  "firststring" and "secondstring",  ********************
  20336. ******************  then the expected output is:  *****************
  20337. "firststring" is less than "secondstring"
  20338. */
  20339.  
  20340.                                                                         *
  20341. ************************************************************************/
  20342.  
  20343.  
  20344. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20345.  
  20346. /************************************************************************
  20347. *
  20348. This program copies the contents of source to destination. 
  20349.  
  20350.                                                                         *
  20351. ************************************************************************/
  20352.  
  20353. #include <stdio.h>
  20354. #include <string.h>
  20355. #define SIZE    40
  20356. int main(void) {
  20357.   char source[ SIZE ] = "This is the source string";
  20358.   char destination[ SIZE ] = "And this is the destination string";
  20359.   char * return_string;
  20360.   printf( "destination is originally = \"%s\"\n", destination );
  20361.   return_string = strcpy( destination, source );
  20362.   printf( "After strcpy, destination becomes \"%s\"\n", destination );
  20363. }
  20364.  
  20365. /************************************************************************
  20366. *
  20367.  
  20368. /*****************  Output should be similar to:  *****************
  20369. destination is originally = "And this is the destination string"
  20370. After strcpy, destination becomes "This is the source string"
  20371. */
  20372.  
  20373.                                                                         *
  20374. ************************************************************************/
  20375.  
  20376.  
  20377. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20378.  
  20379. /************************************************************************
  20380. *
  20381. This program uses strcspn to find the first occurrence of any of the characters 
  20382. a, x, l or e in string. 
  20383.  
  20384.                                                                         *
  20385. ************************************************************************/
  20386.  
  20387. #include <stdio.h>
  20388. #include <string.h>
  20389. #define SIZE    40
  20390. int main(void) {
  20391.   char string[ SIZE ] = "This is the source string";
  20392.   char * substring = "axle";
  20393.   printf( "The first %i characters in the string \"%s\" are not in the "
  20394.           "string \"%s\" \n", strcspn( string, substring), string, substring );
  20395. }
  20396.  
  20397. /************************************************************************
  20398. *
  20399.  
  20400. /*****************  Output should be similar to:  *****************
  20401. The first 10 characters in the string "This is the source string" are not
  20402. in the string "axle"
  20403. */
  20404.  
  20405.                                                                         *
  20406. ************************************************************************/
  20407.  
  20408.  
  20409. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20410.  
  20411. /************************************************************************
  20412. *
  20413. This program prints the current date: 
  20414.  
  20415.                                                                         *
  20416. ************************************************************************/
  20417.  
  20418. #include <stdio.h>
  20419. #include <time.h>
  20420. int main(void)
  20421. {
  20422.     char buffer [9];
  20423.     printf("The current date is %s \n", _strdate(buffer));
  20424.     return 0;
  20425. /**************  The output should be similar to:  **********************
  20426.      The current date is 03/21/93
  20427. */
  20428. }
  20429.  
  20430.  
  20431. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20432.  
  20433. /************************************************************************
  20434. *
  20435.  
  20436. The following example uses strdup to duplicate a string and print the copy. 
  20437.  
  20438.                                                                         *
  20439. ************************************************************************/
  20440.  
  20441. #include <stdio.h>
  20442. #include <string.h>
  20443. int main(void)
  20444. {
  20445.     char *string = "this is a copy";
  20446.     char *newstr;
  20447.     /* Make newstr point to a duplicate of str3 */
  20448.     if ( (newstr = strdup(string)) != NULL )
  20449.         printf("The new string is: %s\n", newstr);
  20450.     return 0;
  20451.     /* The expected ouput:
  20452.        The new string is: this is a copy  */
  20453. }
  20454.  
  20455.  
  20456. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20457.  
  20458. /************************************************************************
  20459. *
  20460. The following example opens a file and prints a runtime error message if an 
  20461. error occurs. 
  20462.  
  20463.                                                                         *
  20464. ************************************************************************/
  20465.  
  20466. #include <stdio.h>
  20467. #include <string.h>
  20468. #include <errno.h>
  20469. int main(void)
  20470. {
  20471.    FILE *stream;
  20472.    .
  20473.    .
  20474.    .
  20475.    if ((stream = fopen("myfile.dat", "r")) == NULL)
  20476.       printf(" %s \n", strerror(errno));
  20477. }
  20478.  
  20479.  
  20480. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20481.  
  20482. /************************************************************************
  20483. *
  20484.  
  20485. The following program shows how _strerror can be used with the fopen function: 
  20486.  
  20487.                                                                         *
  20488. ************************************************************************/
  20489.  
  20490. #include <string.h>
  20491. #include <stdio.h>
  20492. int main(void)
  20493. {
  20494.     FILE *fh1, *fh2;
  20495.     fh1 = fopen("data1","r");
  20496.     if (fh1 == NULL)
  20497.     /*  the error message goes through stdout not stderr  */
  20498.         printf(_strerror("Open failed on input file"));
  20499.     fh2 = fopen("data2","w+");
  20500.     if (fh2 == NULL)
  20501.        printf(_strerror("Open failed on output file"));
  20502.     else
  20503.        printf("Open on output file was successful.\n");
  20504.     if (fh1 != NULL)
  20505.        fclose(fh1);
  20506.     if (fh2 != NULL)
  20507.        fclose(fh2);
  20508.     return 0;
  20509. /***************  The output should be similar to:  *********************
  20510.    Open failed on input file: The file cannot be found.
  20511.    Open on output file was successful.
  20512. */
  20513. }
  20514.  
  20515.  
  20516. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20517.  
  20518. #include <stdio.h>
  20519. #include <time.h>
  20520. int main(void)
  20521. {
  20522.   char dest[70];
  20523.   int ch;
  20524.   time_t temp;
  20525.   struct tm *timeptr;
  20526.   temp = time(NULL);
  20527.   timeptr = localtime(&temp);
  20528.   ch = strftime(dest,sizeof(dest)-1,"Today is %A,"
  20529.               " %b %d. \n Time: %I:%M %p", timeptr);
  20530.   printf("%d characters placed in string to make: \n \n %s", ch, dest);
  20531. }
  20532.  
  20533. /************************************************************************
  20534. *
  20535.  
  20536. /*****************  Output should be similar to:  *****************
  20537. 44 characters placed in string to make:
  20538.  Today is Wednesday, Oct 23.
  20539.  Time: 03:07 PM
  20540. */
  20541.  
  20542.                                                                         *
  20543. ************************************************************************/
  20544.  
  20545.  
  20546. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20547.  
  20548. /************************************************************************
  20549. *
  20550. The following example uses stricmp to compare two strings. 
  20551.  
  20552.                                                                         *
  20553. ************************************************************************/
  20554.  
  20555. #include <stdio.h>
  20556. #include <string.h>
  20557. int main(void)
  20558. {
  20559.     char *str1 = "this is a string";
  20560.     char *str2 = "THIS IS A STRING";
  20561.     /* Compare two strings without regard to case */
  20562.     if ( stricmp( str1,str2 ) )
  20563.        printf("str1 is not the same as str2\n");
  20564.     else
  20565.        printf("str1 is the same as str2\n");
  20566.     return 0;
  20567.     /* The expected output is:
  20568.        str 1 is the same as str 2   */
  20569. }
  20570.  
  20571.  
  20572. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20573.  
  20574. /************************************************************************
  20575. *
  20576. The following example determines the length of the string which is passed to 
  20577. main. 
  20578.  
  20579.                                                                         *
  20580. ************************************************************************/
  20581.  
  20582. #include <stdio.h>
  20583. #include <string.h>
  20584. int main(int argc, char ** argv) {
  20585.   if ( argc != 2 )
  20586.     printf( "Usage: %s string\n", argv[0] );
  20587.   else
  20588.     printf( "Input string has a length of %i\n", strlen( argv[1] ));
  20589. }
  20590.  
  20591. /************************************************************************
  20592. *
  20593.  
  20594. /******************  If the input is the string  ***********************
  20595. *****************"How long is this string?", ******************
  20596. ******************  then the expected output is:  *****************
  20597. Input string has a length of 24
  20598. */
  20599.  
  20600.                                                                         *
  20601. ************************************************************************/
  20602.  
  20603.  
  20604. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20605.  
  20606. /************************************************************************
  20607. *
  20608.  
  20609. This example makes a copy in all lowercase of the string "General Assembly", 
  20610. and then prints the copy. 
  20611.  
  20612.                                                                         *
  20613. ************************************************************************/
  20614.  
  20615. #include <string.h>
  20616. #include <stdio.h>
  20617. int main(void)
  20618. {
  20619.     char *string="General Assembly";
  20620.     char *copy;
  20621.     copy = strlwr(strdup(string));
  20622.     printf("Expected result: general assembly\n");
  20623.     printf("strlwr returned: %s\n", copy);
  20624.     return 0;
  20625.     /* The expected output is:
  20626.        Expected result: general assembly
  20627.        strlwr returned: general assembly  */
  20628. }
  20629.  
  20630.  
  20631. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20632.  
  20633. /************************************************************************
  20634. *
  20635. This program demonstrates the difference between strcat and strncat.  strcat 
  20636. appends the entire second string to the first whereas strncat appends only the 
  20637. specified number of characters in the second string to the first. 
  20638.  
  20639.                                                                         *
  20640. ************************************************************************/
  20641.  
  20642. #include <stdio.h>
  20643. #include <string.h>
  20644. #define SIZE 40
  20645. int main(void) {
  20646.   char buffer1[SIZE] = "computer";
  20647.   char * ptr;
  20648.   /* Call strcat with buffer1 and " program" */
  20649.   ptr = strcat( buffer1, " program" );
  20650.   printf( "strcat : buffer1 = \"%s\"\n", buffer1 );
  20651.   /* Reset buffer1 to contain just the string "computer" again */
  20652.   memset( buffer1, '\0', sizeof( buffer1 ));
  20653.   ptr = strcpy( buffer1, "computer" );
  20654.   /* Call strncat with buffer1 and " program" */
  20655.   ptr = strncat( buffer1, " program", 3 );
  20656.   printf( "strncat: buffer1 = \"%s\"\n", buffer1 );
  20657. }
  20658.  
  20659. /************************************************************************
  20660. *
  20661.  
  20662. /*****************  Output should be similar to:  *****************
  20663. strcat : buffer1 = "computer program"
  20664. strncat: buffer1 = "computer pr"
  20665. */
  20666.  
  20667.                                                                         *
  20668. ************************************************************************/
  20669.  
  20670.  
  20671. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20672.  
  20673. /************************************************************************
  20674. *
  20675. This program demonstrates the difference between strcmp and strncmp. 
  20676.  
  20677.                                                                         *
  20678. ************************************************************************/
  20679.  
  20680. #include <stdio.h>
  20681. #include <string.h>
  20682. #define SIZE 10
  20683. int main(void) {
  20684.   int  result;
  20685.   int  index = 3;
  20686.   char buffer1[SIZE] = "abcdefg";
  20687.   char buffer2[SIZE] = "abcfg";
  20688.   void print_result( int, char *, char * );
  20689.   result = strcmp( buffer1, buffer2 );
  20690.   printf( "Comparison of each character\n" );
  20691.   printf( "  strcmp: " );
  20692.   print_result( result, buffer1, buffer2 );
  20693.   result = strncmp( buffer1, buffer2, index);
  20694.   printf( "\nComparison of only the first %i characters\n", index );
  20695.   printf( "  strncmp: " );
  20696.   print_result( result, buffer1, buffer2 );
  20697. }
  20698. void print_result( int res, char * p_buffer1, char * p_buffer2 ) {
  20699.   if ( res == 0 )
  20700.     printf( "\"%s\" is identical to \"%s\"\n", p_buffer1, p_buffer2);
  20701.   else if ( res < 0 )
  20702.     printf( "\"%s\" is less than \"%s\"\n", p_buffer1, p_buffer2 );
  20703.   else
  20704.     printf( "\"%s\" is greater than \"%s\"\n", p_buffer1, p_buffer2 );
  20705. }
  20706.  
  20707. /************************************************************************
  20708. *
  20709.  
  20710. /*****************  Output should be similar to:  *****************
  20711. Comparison of each character
  20712.   strcmp: "abcdefg" is less than "abcfg"
  20713. Comparison of only the first 3 characters
  20714.   strncmp: "abcdefg" is identical to "abcfg"
  20715. */
  20716.  
  20717.                                                                         *
  20718. ************************************************************************/
  20719.  
  20720.  
  20721. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20722.  
  20723. /************************************************************************
  20724. *
  20725. This program demonstrates the difference between strcpy and strncpy. 
  20726.  
  20727.                                                                         *
  20728. ************************************************************************/
  20729.  
  20730. #include <stdio.h>
  20731. #include <string.h>
  20732. #define SIZE    40
  20733. int main(void) {
  20734.   char source[ SIZE ] = "123456789";
  20735.   char source1[ SIZE ] = "123456789";
  20736.   char destination[ SIZE ] = "abcdefg";
  20737.   char destination1[ SIZE ] = "abcdefg";
  20738.   char * return_string;
  20739.   int    index = 5;
  20740.   /* This is how strcpy works */
  20741.   printf( "destination is originally = '%s'\n", destination );
  20742.   return_string = strcpy( destination, source );
  20743.   printf( "After strcpy, destination becomes '%s'\n\n", destination );
  20744.   /* This is how strncpy works */
  20745.   printf( "destination1 is originally = '%s'\n", destination1 );
  20746.   return_string = strncpy( destination1, source1, index );
  20747.   printf( "After strncpy, destination1 becomes '%s'\n", destination1 );
  20748. }
  20749.  
  20750. /************************************************************************
  20751. *
  20752.  
  20753. /*****************  Output should be similar to:  *****************
  20754. destination is originally = 'abcdefg'
  20755. After strcpy, destination becomes '123456789'
  20756. destination1 is originally = 'abcdefg'
  20757. After strncpy, destination1 becomes '12345fg'
  20758. */
  20759.  
  20760.                                                                         *
  20761. ************************************************************************/
  20762.  
  20763.  
  20764. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20765.  
  20766. /************************************************************************
  20767. *
  20768. This program uses strnicmp to compare two strings. 
  20769.  
  20770.                                                                         *
  20771. ************************************************************************/
  20772.  
  20773. #include <string.h>
  20774. #include <stdio.h>
  20775. int main(void)
  20776. {
  20777.     char *str1 = "THIS IS THE FIRST STRING";
  20778.     char *str2 = "This is the second string";
  20779.     int numresult;
  20780.     /* Compare the first 11 characters of
  20781.        str1 and str2 without regard to case */
  20782.     numresult = strnicmp(str1, str2, 11);
  20783.     if (numresult < 0)
  20784.        printf("String 1 is less than string2.\n");
  20785.     else
  20786.        if (numresult > 0)
  20787.           printf("String 1 is greater than string2.\n");
  20788.        else
  20789.           printf("The two strings are equivalent.\n");
  20790.     return 0;
  20791.     /* The expected output is:
  20792.        The two strings are equivalent. */
  20793. }
  20794.  
  20795.  
  20796. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20797.  
  20798. /************************************************************************
  20799. *
  20800. In the following program, the strnset function sets not more than 4 characters 
  20801. of a string to the character 'x'. Then the strset function changes any non-null 
  20802. characters of a string to the character 'k'. 
  20803.  
  20804.                                                                         *
  20805. ************************************************************************/
  20806.  
  20807. #include <stdio.h>
  20808. #include <string.h>
  20809. int main(void)
  20810. {
  20811.     char *str = "abcdefghi";
  20812.     printf("This is the string: %s\n",str);
  20813.     printf("This is the string after strnset: %s\n", strnset(str, 'x', 4));
  20814.     printf("This is the string after strset: %s\n", strset(str, 'k'));
  20815.     return 0;
  20816. /****************  The output should be similar to:  ********************
  20817.    This is the string: abcdefghi
  20818.    This is the string after strnset: xxxxefghi
  20819.    This is the string after strset: kkkkkkkkk
  20820. */
  20821. }
  20822.  
  20823.  
  20824. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20825.  
  20826. /************************************************************************
  20827. *
  20828. The following example returns a pointer to the first occurrence in the array 
  20829. string of either a or b. 
  20830.  
  20831.                                                                         *
  20832. ************************************************************************/
  20833.  
  20834. #include <stdio.h>
  20835. #include <string.h>
  20836. int main(void)
  20837. {
  20838.    char *result, *string = "A Blue Danube";
  20839.    char *chars = "ab";
  20840.    result = strpbrk(string, chars);
  20841.    printf("The first occurrence of any of the characters \"%s\" in "
  20842.           "\"%s\" is \"%s\"\n", chars, string, result);
  20843. }
  20844.  
  20845. /************************************************************************
  20846. *
  20847.  
  20848. /*****************  Output should be similar to:  *****************
  20849. The first occurrence of any of the characters "ab" in "The Blue Danube" is "anube"
  20850. */
  20851.  
  20852.                                                                         *
  20853. ************************************************************************/
  20854.  
  20855.  
  20856. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20857.  
  20858. /************************************************************************
  20859. *
  20860. The following example compares the use of strchr and strrchr.  It searches the 
  20861. string for the first and last occurrence of p in the string. 
  20862.  
  20863.                                                                         *
  20864. ************************************************************************/
  20865.  
  20866. #include <stdio.h>
  20867. #include <string.h>
  20868. #define SIZE 40
  20869. int main(void) {
  20870.   char buf[SIZE] = "computer program";
  20871.   char * ptr;
  20872.   int    ch = 'p';
  20873.   /* This illustrates strchr */
  20874.   ptr = strchr( buf, ch );
  20875.   printf( "The first occurrence of %c in '%s' is '%s'\n", ch, buf, ptr );
  20876.   /* This illustrates strrchr */
  20877.   ptr = strrchr( buf, ch );
  20878.   printf( "The last occurrence of %c in '%s' is '%s'\n", ch, buf, ptr );
  20879. }
  20880.  
  20881. /************************************************************************
  20882. *
  20883.  
  20884. /*****************  Output should be similar to:  *****************
  20885. The first occurrence of p in 'computer program' is 'puter program'
  20886. The last occurrence of p in 'computer program' is 'program'
  20887. */
  20888.  
  20889.                                                                         *
  20890. ************************************************************************/
  20891.  
  20892.  
  20893. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20894.  
  20895. /************************************************************************
  20896. *
  20897. The following program determines if a string is a palindrome.  A palindrome is 
  20898. a string that reads the same forward and backward. 
  20899.  
  20900.                                                                         *
  20901. ************************************************************************/
  20902.  
  20903. #include <stdio.h>
  20904. #include <string.h>
  20905. int palindrome(char *string)
  20906. {
  20907.     char *string2;
  20908.     /* Duplicate string for comparison */
  20909.     if (( string2 = strdup(string) ) == NULL)  {
  20910.         printf ("Storage could not be reserved for string\n");
  20911.         _exit(-1);
  20912.     }
  20913.     /* If result equals 0, the string is a palindrome */
  20914.     return (strcmp(string, strrev(string2)));
  20915. }
  20916. int main(void)
  20917. {
  20918.     char string[81];
  20919.     printf("Please enter a string.\n");
  20920.     scanf("%80s", string);
  20921.     if (palindrome(string))
  20922.        printf("The string is not a palindrome.\n");
  20923.     else
  20924.        printf("The string is a palindrome.\n");
  20925.     return 0;
  20926. /**************  The output should be similar to:  **********************
  20927.    Please enter a string.
  20928.    level
  20929.    The string is a palindrome.
  20930. ** ... or ... **
  20931.    Please enter a string.
  20932.    bolton
  20933.    The string is not a palindrome.
  20934. */
  20935. }
  20936.  
  20937.  
  20938. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20939.  
  20940. /************************************************************************
  20941. *
  20942. The following example finds the first occurrence in the array string of a 
  20943. character that is neither an a, b, nor c.  Because the string in this example 
  20944. is cabbage, strspn returns 5, the length of the segment of cabbage before a 
  20945. character that is not an a, b or c. 
  20946.  
  20947.                                                                         *
  20948. ************************************************************************/
  20949.  
  20950. #include <stdio.h>
  20951. #include <string.h>
  20952. int main(void) {
  20953.   char * string = "cabbage";
  20954.   char * source = "abc";
  20955.   int index;
  20956.   index = strspn( string, "abc" );
  20957.   printf( "The first %d characters of \"%s\" are found in \"%s\"\n",
  20958.               index, string, source );
  20959. }
  20960.  
  20961. /************************************************************************
  20962. *
  20963.  
  20964. /*****************  Output should be similar to:  *****************
  20965. The first 5 characters of "cabbage" are found in "abc"
  20966. */
  20967.  
  20968.                                                                         *
  20969. ************************************************************************/
  20970.  
  20971.  
  20972. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  20973.  
  20974. /************************************************************************
  20975. *
  20976. The following example locates the string haystack in the string "needle in a 
  20977. haystack": 
  20978.  
  20979.                                                                         *
  20980. ************************************************************************/
  20981.  
  20982. #include <string.h>
  20983. int main(void)
  20984. {
  20985.    char *string1 = "needle in a haystack";
  20986.    char *string2 = "haystack";
  20987.    char *result;
  20988.   result = strstr(string1,string2);
  20989.      /* Result = a pointer to "haystack" */
  20990.   printf("%s\n", result);
  20991. }
  20992.  
  20993. /************************************************************************
  20994. *
  20995.  
  20996. /*****************  Output should be similar to:  *****************
  20997. haystack
  20998. */
  20999.  
  21000.                                                                         *
  21001. ************************************************************************/
  21002.  
  21003.  
  21004. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21005.  
  21006. /************************************************************************
  21007. *
  21008. This program prints the current time: 
  21009.  
  21010.                                                                         *
  21011. ************************************************************************/
  21012.  
  21013. #include <stdio.h>
  21014. #include <time.h>
  21015. int main(void)
  21016. {
  21017.     char buffer[9];
  21018.     printf("The current time is %s \n", _strtime(buffer));
  21019.     return 0;
  21020. /*****************  The output should be similar to:  *******************
  21021.    The current time is 16:09:22                                            */
  21022. /*
  21023. }
  21024.  
  21025.  
  21026. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21027.  
  21028. /************************************************************************
  21029. *
  21030.  
  21031. The following example converts the strings to a double value.  It prints out 
  21032. the converted value and the substring that stopped the conversion. 
  21033.  
  21034.                                                                         *
  21035. ************************************************************************/
  21036.  
  21037. #include <stdlib.h>
  21038. #include <stdio.h>
  21039. int main(void)
  21040. {
  21041.    char *string, *stopstring;
  21042.    double x;
  21043.    string = "3.1415926This stopped it";
  21044.    x = strtod(string, &stopstring);
  21045.    printf("string = %s\n", string);
  21046.    printf("   strtod = %f\n", x);
  21047.    printf("   Stopped scan at %s\n\n", stopstring);
  21048.    string = "100ergs";
  21049.    x = strtod(string, &stopstring);
  21050.    printf("string = \"%s\"\n", string);
  21051.    printf("   strtod = %f\n", x);
  21052.    printf("   Stopped scan at \"%s\"\n\n", stopstring);
  21053. }
  21054.  
  21055. /************************************************************************
  21056. *
  21057.  
  21058. /*****************  Output should be similar to:  *****************
  21059. string = 3.1415926This stopped it
  21060.    strtod = 3.141593
  21061.    Stopped scan at This stopped it
  21062. string = 100ergs
  21063.    strtod = 100.000000
  21064.    Stopped scan at ergs
  21065. */
  21066.  
  21067.                                                                         *
  21068. ************************************************************************/
  21069.  
  21070.  
  21071. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21072.  
  21073. /************************************************************************
  21074. *
  21075. Using a loop, the following example gathers tokens, separated by blanks or 
  21076. commas, from a string until no tokens are left.  After processing the tokens 
  21077. (not shown), the example returns the pointers to the tokens a, string, of, and 
  21078. tokens.  The next call to strtok returns NULL and the loop ends. 
  21079.  
  21080.                                                                         *
  21081. ************************************************************************/
  21082.  
  21083. #include <stdio.h>
  21084. #include <string.h>
  21085. int main(void)
  21086. {
  21087.    char *token, *string = "a string, of, ,tokens\0,after null terminator";
  21088.    /* the string pointed to by string is broken up into the tokens
  21089.       "a string", " of", " ", and "tokens" ; the null terminator (\0)
  21090.       is encountered and execution stops after the token "tokens"     */
  21091.    token = strtok(string, ",");
  21092.    do
  21093.    {
  21094.       printf("token: %s\n", token);
  21095.    }
  21096.    while (token = strtok(NULL, ","));
  21097. }
  21098.  
  21099. /************************************************************************
  21100. *
  21101.  
  21102. /*****************  Output should be similar to:  *****************
  21103. token: a string
  21104. token:  of
  21105. token:
  21106. token: tokens
  21107. */
  21108.  
  21109.                                                                         *
  21110. ************************************************************************/
  21111.  
  21112.  
  21113. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21114.  
  21115. /************************************************************************
  21116. *
  21117.  
  21118. The following example converts the strings to a long value.  It prints out the 
  21119. converted value and the substring that stopped the conversion. 
  21120.  
  21121.                                                                         *
  21122. ************************************************************************/
  21123.  
  21124. #include <stdlib.h>
  21125. #include <stdio.h>
  21126. int main(void)
  21127. {
  21128.    char *string, *stopstring;
  21129.    long l;
  21130.    int bs;
  21131.    string = "10110134932";
  21132.    printf("string = %s\n", string);
  21133.    for (bs = 2; bs <= 8; bs *= 2) {
  21134.       l = strtol(string, &stopstring, bs);
  21135.       printf("   strtol = %ld (base %d)\n", l, bs);
  21136.       printf("   Stopped scan at %s\n\n", stopstring);
  21137.       }
  21138. }
  21139.  
  21140. /************************************************************************
  21141. *
  21142.  
  21143. /*****************  Output should be similar to:  *****************
  21144. string = 10110134932
  21145.    strtol = 45 (base 2)
  21146.    Stopped scan at 34932
  21147.    strtol = 4423 (base 4)
  21148.    Stopped scan at 4932
  21149.    strtol = 2134108 (base 8)
  21150.    Stopped scan at 932
  21151. */
  21152.  
  21153.                                                                         *
  21154. ************************************************************************/
  21155.  
  21156.  
  21157. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21158.  
  21159. /************************************************************************
  21160. *
  21161.  
  21162. The following example uses strtold to convert two strings, " 
  21163. -001234.5678e10end of string" and "NaNQthis cannot be converted" to their 
  21164. corresponding long double values.  It also prints out the part of the string 
  21165. that cannot be converted. 
  21166.  
  21167.                                                                         *
  21168. ************************************************************************/
  21169.  
  21170. #include <stdlib.h>
  21171. #include <stdio.h>
  21172. int main(void)
  21173. {
  21174.    char *nptr;
  21175.    char *endptr;
  21176.    nptr = "  -001234.5678e10end of string";
  21177.    printf("strtold = %.10Le\n", strtold(nptr, &endptr) );
  21178.    printf("end pointer at = %s\n\n", endptr);
  21179.    nptr = "NaNthis cannot be converted";
  21180.    printf("strtold = %.10Le\n", strtold(nptr, &endptr) );
  21181.    printf("end pointer at = %s\n\n", endptr);
  21182.    return 0;
  21183.    /* The expected output is:
  21184.       strtold = -1.2345678000e+13
  21185.       end pointer at = end of string
  21186.       strtold = nan
  21187.       end pointer at = this cannot be converted */
  21188. }
  21189.  
  21190.  
  21191. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21192.  
  21193. /************************************************************************
  21194. *
  21195.  
  21196. The following example converts the string to an unsigned long value.  It prints 
  21197. out the converted value and the substring that stopped the conversion. 
  21198.  
  21199.                                                                         *
  21200. ************************************************************************/
  21201.  
  21202. #include <stdio.h>
  21203. #include <stdlib.h>
  21204. #define BASE 2
  21205. int main(void)
  21206. {
  21207.    char *string, *stopstring;
  21208.    unsigned long ul;
  21209.    string = "1000e13 e";
  21210.    printf("string = %s\n", string);
  21211.    ul = strtoul(string, &stopstring, BASE);
  21212.    printf("   strtoul = %ld (base %d)\n", ul, BASE);
  21213.    printf("   Stopped scan at %s\n\n", stopstring);
  21214. }
  21215.  
  21216. /************************************************************************
  21217. *
  21218.  
  21219. /*****************  Output should be similar to:  *****************
  21220. string = 1000e13 e
  21221.    strtoul = 8 (base 2)
  21222.    Stopped scan at e13 e
  21223. */
  21224.  
  21225.                                                                         *
  21226. ************************************************************************/
  21227.  
  21228.  
  21229. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21230.  
  21231. /************************************************************************
  21232. *
  21233. This example makes a copy in all-uppercase of the string "DosWrite", and then 
  21234. prints the copy. 
  21235.  
  21236.                                                                         *
  21237. ************************************************************************/
  21238.  
  21239. #include <string.h>
  21240. #include <stdio.h>
  21241. int main(void)
  21242. {
  21243.     char *string = "DosWrite";
  21244.     char *copy;
  21245.     copy=strupr(strdup(string));
  21246.     printf("This is a copy of the string\n");
  21247.     printf("with all letters capitalized: %s\n",copy);
  21248.     return 0;
  21249.     /* The expected output is:
  21250.        This is a copy of the string
  21251.        with all letters capitalized: DOSWRITE */
  21252. }
  21253.  
  21254.  
  21255. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21256.  
  21257. #include <stdio.h>
  21258. #include <string.h>
  21259. int main(void)
  21260. {
  21261.    char *string1, buffer[80];
  21262.    int length;
  21263.    printf("Type in a string of characters.\n ");
  21264.    string1 = gets(buffer);
  21265.    length = strxfrm(NULL, string1, 0);
  21266.    printf("You would need a %d element array to hold the string\n",length);
  21267.    printf("\n\n%s\n\n transformed according",string1);
  21268.    printf(" to this program's locale. \n");
  21269. }
  21270.  
  21271.  
  21272. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21273.  
  21274. /************************************************************************
  21275. *
  21276. The following program copies n bytes from one location to another, swapping 
  21277. each pair of adjacent bytes: 
  21278.  
  21279.                                                                         *
  21280. ************************************************************************/
  21281.  
  21282. #include <stdlib.h>
  21283. #include <stdio.h>
  21284. /* This array is not a string because it does not end with a null character */
  21285. char from[20] = "hTsii  s atsirgn..x ";
  21286. char to[20];
  21287. int main(void)
  21288. {
  21289.     _swab(from, to, 19);
  21290.     printf("%s\n", to);    /* Because swab appends a null character, */
  21291.                            /* the array is now a string              */
  21292.     return 0;
  21293. /***************  The output should be similar to:  *********************
  21294.    This is a string..
  21295. */
  21296. }
  21297.  
  21298.  
  21299. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21300.  
  21301. /************************************************************************
  21302. *
  21303. The following example shows how to use system to execute the OS/2 command dir 
  21304. c:\ : 
  21305.  
  21306.                                                                         *
  21307. ************************************************************************/
  21308.  
  21309. #include <stdlib.h>
  21310. int main(void)
  21311. {
  21312.     int rc;
  21313.     rc = system("dir c:\\");
  21314.     exit(rc);
  21315.     /* The expected output is a listing of files
  21316.          on the root directory of the c: drive   */
  21317. }
  21318.  
  21319.  
  21320. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21321.  
  21322. /************************************************************************
  21323. *
  21324. The following example computes x as the tangent of ╤â/4. 
  21325.  
  21326.                                                                         *
  21327. ************************************************************************/
  21328.  
  21329. #include <math.h>
  21330. int main(void)
  21331. {
  21332.    double pi, x;
  21333.    pi = 3.1415926;
  21334.    x = tan(pi/4.0);
  21335.    printf("tan( %lf ) is %lf\n", pi/4, x);
  21336. }
  21337.  
  21338. /************************************************************************
  21339. *
  21340.  
  21341. /******************  Output should be similar to:  ****************
  21342. tan( 0.785398 ) is 1.000000
  21343. */
  21344.  
  21345.                                                                         *
  21346. ************************************************************************/
  21347.  
  21348.  
  21349. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21350.  
  21351. /************************************************************************
  21352. *
  21353. The following example computes x as the hyperbolic tangent of ╤â/4. 
  21354.  
  21355.                                                                         *
  21356. ************************************************************************/
  21357.  
  21358. #include <math.h>
  21359. int main(void)
  21360. {
  21361.    double pi, x;
  21362.    pi = 3.1415926;
  21363.    x = tanh(pi/4);
  21364.    printf("tanh( %lf ) = %lf\n", pi/4, x);
  21365. }
  21366.  
  21367. /************************************************************************
  21368. *
  21369.  
  21370. /******************  Output should be similar to:  ****************
  21371. tanh( 0.785398 ) = 0.655794
  21372. */
  21373.  
  21374.                                                                         *
  21375. ************************************************************************/
  21376.  
  21377.  
  21378. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21379.  
  21380. /************************************************************************
  21381. *
  21382.  
  21383. The following program opens the file sample.dat. It then gets the current 
  21384. position of the file pointer, using _tell, and reports if it is successful or 
  21385. unsuccessful. The program then closes sample.dat using fh. 
  21386.  
  21387.                                                                         *
  21388. ************************************************************************/
  21389.  
  21390. #include <io.h>
  21391. #include <stdio.h>
  21392. #include <stdlib.h>
  21393. #include <fcntl.h>
  21394. int main(void)
  21395. {
  21396.    long filePtrPos;
  21397.    int  fh;
  21398.    printf("\nCreating sample.dat.\n");
  21399.    system("echo Sample Program > sample.dat");
  21400.    if (-1 == (fh = _open("sample.dat",O_RDWR | O_APPEND)))
  21401.    {
  21402.       perror("Unable to open sample.dat");
  21403.       return 1;
  21404.    }
  21405.    /* Get the current file pointer position. */
  21406.    if ( -1 == (filePtrPos = _tell(fh)))
  21407.    {
  21408.       perror("Unable to _tell");
  21409.       _close(fh);
  21410.       return 1;
  21411.    }
  21412.    printf("File pointer is at position %d.\n",filePtrPos);
  21413.    _close(fh);
  21414.    return 0;
  21415. /*******************  The expected output is:  **************************
  21416.       Creating sample.dat.
  21417.       File pointer is at position 0.
  21418. */
  21419. }
  21420.  
  21421.  
  21422. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21423.  
  21424. /***************************************************************************
  21425. *                                                                          *
  21426. This program creates a temporary file name using the directory a:\tmp: 
  21427.  
  21428.                                                                         *
  21429. ************************************************************************/
  21430.  
  21431. #include <stdio.h>
  21432. int main(void)
  21433. {
  21434.     char *name1;
  21435.     if((name1 = _tempnam("a:\\tmp","stq")) != NULL)
  21436.         printf("%s is safe to use as a temporary file.\n", name1);
  21437.     else
  21438.         printf("Cannot create unique filename\n");
  21439.     return 0;
  21440. /*****************  The output should be similar to:  *******************
  21441.    D:\stqU3CP2.C2T is safe to use as a temporary file.
  21442. */
  21443. }
  21444.  
  21445.  
  21446. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21447.  
  21448. /************************************************************************
  21449. *
  21450. The following example gets the time and assigns it to ltime.  It then uses the 
  21451. ctime function to convert the number of seconds to the current date and time. 
  21452. This example then prints a message giving the current time. 
  21453.  
  21454.                                                                         *
  21455. ************************************************************************/
  21456.  
  21457. #include <time.h>
  21458. #include <stdio.h>
  21459. int main(void)
  21460. {
  21461.    time_t ltime;
  21462.    time(<ime);
  21463.    printf("The time is %s\n", ctime(<ime));
  21464. }
  21465.  
  21466. /************************************************************************
  21467. *
  21468.  
  21469. /******************  Output should be similar to:  ****************
  21470. The time is Mon Mar 22 19:01:41 1993
  21471. */
  21472.  
  21473.                                                                         *
  21474. ************************************************************************/
  21475.  
  21476.  
  21477. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21478.  
  21479. /************************************************************************
  21480. *
  21481.  
  21482. The following program creates a temporary file and if successful, writes 
  21483. tmpstring to it.  At program termination, the file is removed. 
  21484.  
  21485.                                                                         *
  21486. ************************************************************************/
  21487.  
  21488. #include <stdio.h>
  21489. FILE *stream;
  21490. char tmpstring[ ] = "This is the string to be temporarily written";
  21491. int main(void)
  21492. {
  21493.    if((stream = tmpfile( )) == NULL)
  21494.       perror("Cannot make a temporary file");
  21495.    else
  21496.       fprintf(stream, "%s", tmpstring);
  21497. }
  21498.  
  21499.  
  21500. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21501.  
  21502. /************************************************************************
  21503. *
  21504.  
  21505. The following program calls tmpnam to produce a valid file name. 
  21506.  
  21507.                                                                         *
  21508. ************************************************************************/
  21509.  
  21510. #include <stdio.h>
  21511. int main(void)
  21512. {
  21513.    char *name1;
  21514.    if ((name1 = tmpnam(NULL)) !=NULL)
  21515.       printf("%s can be used as a file name.\n", name1);
  21516.    else printf("Cannot create a unique file name\n");
  21517. }
  21518.  
  21519.  
  21520. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21521.  
  21522. /************************************************************************
  21523. *
  21524. This program prints four sets of characters.  The first set is the ASCII 
  21525. characters having graphic images, which range from 0x21 through 0x7e.  The 
  21526. second set takes integers 0x7f21 through 0x7f7e and applies the _toascii macro 
  21527. to them, yielding the same set of printable characters.  The third set is the 
  21528. characters with all lowercase letters converted to uppercase.  The fourth set 
  21529. is the characters with all uppercase letters converted to lowercase. 
  21530.  
  21531.                                                                         *
  21532. ************************************************************************/
  21533.  
  21534. #include <stdio.h>
  21535. #include <ctype.h>
  21536. int main(void)
  21537. {
  21538.    int ch;
  21539.    printf("Characters 0x01 to 0x03, and integers 0x7f01 to 0x7f03 mapped to\n");
  21540.    printf("ASCII by _toascii() both yield the same graphic characters.\n\n");
  21541.    for (ch = 0x01; ch <= 0x03; ch++)  {
  21542.       printf("char 0x%.4X: %c    ", ch, ch);
  21543.       printf("char _toascii(0x%.4X): %c\n", ch+0x7f00, ch+0x7f00);
  21544.    }
  21545.    printf("\nCharacters A, B and C converted to lower case and\n");
  21546.    printf("Characters a, b and c converted to upper case.\n\n");
  21547.    for (ch = 0x41; ch <= 0x43; ch++)  {
  21548.       printf("_tolower(%c) = %c   ", ch, _tolower(ch) );
  21549.       printf("_toupper(%c) = %c\n", ch+0x20, _toupper(ch+0x20) );
  21550.    }
  21551.     return 0;
  21552. /*************  The output should be similar to:  ***********************
  21553.    Characters 0x01 to 0x03, and integers 0x7f01 to 0x7f03 mapped to
  21554.    ASCII by _/toascii() both yield the same graphic characters.
  21555.    char 0x0001:     char _toascii(0x7F01):                            */
  21556.    char 0x0002:     char _toascii(0x7F02):                            */
  21557.    char 0x0003:     char _toascii(0x7F03):                            */
  21558.    Characters A, B and C converted to lower case and
  21559.    Characters a, b and c converted to upper case.
  21560.    _tolower(A) = a   _toupper(a) = A
  21561.    _tolower(B) = b   _toupper(b) = B
  21562.    _tolower(C) = c   _toupper(c) = C
  21563. */
  21564. }
  21565.  
  21566.  
  21567. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21568.  
  21569. /************************************************************************
  21570. *
  21571. The following example uses the toupper and tolower functions to modify 
  21572. characters between code 0 and code 7f. 
  21573.  
  21574.                                                                         *
  21575. ************************************************************************/
  21576.  
  21577. #include <stdio.h>
  21578. #include <ctype.h>
  21579. int main(void)
  21580. {
  21581.    int ch;
  21582.    for (ch = 0; ch <= 0x7f; ch++) {
  21583.       printf("toupper=%#04x\n", toupper(ch));
  21584.       printf("tolower=%#04x\n", tolower(ch));
  21585.       putchar('\n');
  21586.       }
  21587. }
  21588.  
  21589.  
  21590. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21591.  
  21592. /************************************************************************
  21593. *
  21594. The following example uses the _putenv and _tzset functions to set the time 
  21595. zone to Central Time. 
  21596.  
  21597.                                                                         *
  21598. ************************************************************************/
  21599.  
  21600. #include <time.h>
  21601. #include <stdio.h>
  21602. int main(void)
  21603. {
  21604.    time_t currentTime;
  21605.    struct tm  * ts;
  21606.    /* Get the current time */
  21607.    (void)time(¤tTime);
  21608.    printf( "The GMT time is %s\n", asctime(gmtime(¤tTime)) );
  21609.    ts = localtime(¤tTime);
  21610.    if (ts->tm_isdst > 0)   /* check if Daylight Saving Time is in effect */
  21611.    {
  21612.       printf("The local time is %s", asctime(ts));
  21613.       printf("Daylight Saving Time is in effect.\n");
  21614.    }
  21615.    else
  21616.    {
  21617.       printf("The local time is %s",asctime(ts));
  21618.       printf("Daylight Saving Time is not in effect.\n\n");
  21619.    }
  21620.    printf("**** Changing to Central Time **** \n\n");
  21621.    _putenv("TZ=CST6CDT");
  21622.    _tzset();
  21623.    ts = localtime(¤tTime);
  21624.    if (ts->tm_isdst > 0)   /* check if Daylight Saving Time is in effect */
  21625.    {
  21626.       printf("The local time is %s",asctime(ts));
  21627.       printf("Daylight Saving Time is in effect.\n");
  21628.    }
  21629.    else
  21630.    {
  21631.       printf("The local time is %s",asctime(ts));
  21632.       printf("Daylight Saving Time is not in effect.\n");
  21633.    }
  21634.    /*  Possible output could be:
  21635.        The GMT time is Thu Sep  3 11:55:04 1991
  21636.        The local time is Thu Sep  3 07:55:04 1991
  21637.        Daylight Saving Time is in effect.
  21638.        **** Changing to Central Time ****
  21639.        The local time is Thu Sep  3 06:55:04 1991
  21640.        Daylight Saving Time is in effect.      */
  21641. }
  21642.  
  21643.  
  21644. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21645.  
  21646. /************************************************************************
  21647. *
  21648. The following example converts the digits of the value 255 to decimal, binary 
  21649. and hexadecimal representations: 
  21650.  
  21651.                                                                         *
  21652. ************************************************************************/
  21653.  
  21654. #include <stdio.h>
  21655. #include <stdlib.h>
  21656. int main(void)
  21657. {
  21658.     char buffer[10];
  21659.     char *p;
  21660.     p = _ultoa(255UL, buffer, 10);
  21661.     printf("The result of _ultoa(255) with radix of 10 is %s\n", p);
  21662.     p = _ultoa(255UL, buffer, 2);
  21663.     printf("The result of _ultoa(255) with radix of 2 is %s\n", p);
  21664.     p = _ultoa(255UL, buffer, 16);
  21665.     printf("The result of _ultoa(255) with radix of 16 is %s\n", p);
  21666.     return 0;
  21667.     /* The expected output is:
  21668.        The result of _ultoa(255) with radix of 10 is 255
  21669.        The result of _ultoa(255) with radix of 2 is 11111111
  21670.        The result of _ultoa(255) with radix of 16 is ff      */
  21671. }
  21672.  
  21673.  
  21674. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21675.  
  21676. /************************************************************************
  21677. *
  21678.  
  21679. The following program sets the permission mask to create a write-only file. 
  21680.  
  21681.                                                                         *
  21682. ************************************************************************/
  21683.  
  21684. #include <sys\stat.h>
  21685. #include <io.h>
  21686. #include <stdio.h>
  21687. int main(void)
  21688. {
  21689.    int oldMask;
  21690.    oldMask = _umask(S_IWRITE);
  21691.    printf("\nDefault system startup mask is %d.\n",oldMask);
  21692.    return 0;
  21693. /******************  The expected output is:  ***************************
  21694.       Default system startup mask is 0.
  21695. */
  21696. }
  21697.  
  21698.  
  21699. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21700.  
  21701. /************************************************************************
  21702. *
  21703. In the following example, the while statement reads decimal digits from an 
  21704. input data stream by using arithmetic statements to compose the numeric values 
  21705. of the numbers as it reads them.  When a nondigit character appears before the 
  21706. end of the file, ungetc replaces it in the input stream so that later input 
  21707. functions can process it. 
  21708.  
  21709.                                                                         *
  21710. ************************************************************************/
  21711.  
  21712. #include <stdio.h>
  21713. #include <ctype.h>
  21714. int main(void)
  21715. {
  21716.    FILE *stream;
  21717.    int ch;
  21718.    unsigned int result = 0;
  21719.    .
  21720.    .
  21721.    .
  21722.    while ((ch = getc(stream)) != EOF && isdigit(ch))
  21723.       result = result * 10 + ch - '0';
  21724.    if (ch != EOF)
  21725.       ungetc(ch,stream);
  21726.          /* Put the nondigit character back */
  21727. }
  21728.  
  21729.  
  21730. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21731.  
  21732. /************************************************************************
  21733. *
  21734.  
  21735. This program uses _getch to read a string delimited by the character 'x'.  It 
  21736. then calls _ungetch to return the delimiter to the keyboard buffer. Other input 
  21737. routines can then process the delimiter. 
  21738.  
  21739.                                                                         *
  21740. ************************************************************************/
  21741.  
  21742. #include <conio.h>
  21743. #include <stdio.h>
  21744. int main(void)
  21745. {
  21746.    int ch;
  21747.    _cprintf("\nType in some letters.");
  21748.    printf("\n");
  21749.    _cprintf("If you type in an 'x', the program ends.\n");
  21750.    printf("\n");
  21751.    for(;;)
  21752.    {
  21753.       ch = _getch();
  21754.       if (ch == 'x') {
  21755.          _ungetch(ch);
  21756.          break;
  21757.       }
  21758.       _putch(ch);
  21759.    }
  21760.    ch=_getch();
  21761.    printf("\n");
  21762.    _cprintf("\nThe last character was '%c'.", ch);
  21763.    return 0;
  21764. /**************  The output should be similar to:  **********************
  21765.    Type in some letters.
  21766.    If you type in an 'x', the program ends.
  21767.    One Two Three Four Five Si
  21768.    The last character was 'x'.
  21769. */
  21770. }
  21771.  
  21772.  
  21773. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21774.  
  21775. /************************************************************************
  21776. *
  21777. The following program deletes the file tmpfile from the system or prints an 
  21778. error message if unable to delete it: 
  21779.  
  21780.                                                                         *
  21781. ************************************************************************/
  21782.  
  21783. #include <stdio.h>
  21784. int main(void)
  21785. {
  21786.     if (_unlink("tmpfile") == -1)
  21787.         perror("Cannot delete tmpfile");
  21788.     else
  21789.         printf("tmpfile has been successfully deleted\n");
  21790.     return 0;
  21791. /*****************  The output should be similar to:  *******************
  21792.    tmpfile has been successfully deleted
  21793. */
  21794. }
  21795.  
  21796.  
  21797. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21798.  
  21799. /************************************************************************
  21800. *
  21801. The following program tries to set the last modification time of file \TMP\DATA 
  21802. to the current time.  It prints an error message if it cannot. 
  21803.  
  21804.                                                                         *
  21805. ************************************************************************/
  21806.  
  21807. #include <sys\types.h>
  21808. #include <sys\utime.h>
  21809. #include <sys\stat.h>
  21810. #include <stdio.h>
  21811. int main(void)
  21812. {
  21813.     struct utimbuf ubuf;
  21814.     struct stat statbuf;
  21815.                               /* seconds to current date from 1970 Jan 1 */
  21816.     ubuf.modtime = 946702799;  /*  Sat Dec 31 23:59:59 1999  */
  21817.     /* changing file modification time  */
  21818.     if (_utime("\\tmp\\data", &ubuf ) == -1)  {
  21819.        perror("_utime failed");
  21820.        _exit(-1);
  21821.     }
  21822.     /* display the modification time  */
  21823.     if (_stat("\\tmp\\data", &statbuf) == 0)
  21824.         printf("The file modification time is %s", ctime(&statbuf.st_mtime));
  21825.     else
  21826.         printf("File could not be found\n");
  21827.     return 0;
  21828. /**************  The output should be similar to:  **********************
  21829.    The file modification time is Fri Dec 31 23:59:58 1999
  21830. */
  21831. }
  21832.  
  21833.  
  21834. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21835.  
  21836. /************************************************************************
  21837. *
  21838. The following example passes a variable number of arguments to a function, 
  21839. stores each argument in an array, and prints each argument. 
  21840.  
  21841.                                                                         *
  21842. ************************************************************************/
  21843.  
  21844. #include <stdio.h>
  21845. #include <stdarg.h>
  21846. int vout(int max, ...);
  21847. int main(void)
  21848. {
  21849.    vout(3, "Sat", "Sun", "Mon");
  21850.    printf("\n");
  21851.    vout(5, "Mon", "Tues", "Wed", "Thurs", "Fri");
  21852. }
  21853. int vout(int max, ...)
  21854. {
  21855.    va_list arg_ptr;
  21856.    int args = 0;
  21857.    char *days[7];
  21858.    va_start(arg_ptr, max);
  21859.    while(args < max) {
  21860.       days[args] = va_arg(arg_ptr, char *);
  21861.       printf("Day:  %s  \n", days[args++]);
  21862.       }
  21863.    va_end(arg_ptr);
  21864. }
  21865.  
  21866. /************************************************************************
  21867. *
  21868. Output 
  21869.  
  21870. /******************  Output should be similar to:  ****************
  21871. Day:  Sat
  21872. Day:  Sun
  21873. Day:  Mon
  21874. Day:  Mon
  21875. Day:  Tues
  21876. Day:  Wed
  21877. Day:  Thurs
  21878. Day:  Fri
  21879. */
  21880.  
  21881.                                                                         *
  21882. ************************************************************************/
  21883.  
  21884.  
  21885. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21886.  
  21887. /************************************************************************
  21888. *
  21889. This example prints out a variable number of strings to the file myfile.dat. 
  21890.  
  21891.                                                                         *
  21892. ************************************************************************/
  21893.  
  21894. #include <stdarg.h>
  21895. #include <stdio.h>
  21896. void vout(FILE *stream, char *fmt, ...);
  21897. char fmt1 [] = "%s  %s  %s\n";
  21898. int main(void)
  21899. {
  21900.    FILE *stream;
  21901.    stream = fopen("myfile.dat", "w");
  21902.    vout(stream, fmt1, "Sat", "Sun", "Mon");
  21903. }
  21904. void vout(FILE *stream, char *fmt, ...)
  21905. {
  21906.    va_list arg_ptr;
  21907.    va_start(arg_ptr, fmt);
  21908.    vfprintf(stream, fmt, arg_ptr);
  21909.    va_end(arg_ptr);
  21910. }
  21911.  
  21912. /************************************************************************
  21913. *
  21914. Output to myfile.dat 
  21915.  
  21916. /******************  Output should be similar to:  ****************
  21917. Sat  Sun  Mon
  21918. */
  21919.  
  21920.                                                                         *
  21921. ************************************************************************/
  21922.  
  21923.  
  21924. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21925.  
  21926. /************************************************************************
  21927. *
  21928. This example prints out a variable number of strings to stdout. 
  21929.  
  21930.                                                                         *
  21931. ************************************************************************/
  21932.  
  21933. #include <stdarg.h>
  21934. #include <stdio.h>
  21935. void vout(char *fmt, ...);
  21936. char fmt1 [] = "%s  %s  %s   %s   %s \n";
  21937. int main(void)
  21938. {
  21939.    FILE *stream;
  21940.    stream = fopen("myfile.dat", "w");
  21941.    vout(fmt1, "Mon", "Tues", "Wed", "Thurs", "Fri");
  21942. }
  21943. void vout(char *fmt, ...)
  21944. {
  21945.    va_list arg_ptr;
  21946.    va_start(arg_ptr, fmt);
  21947.    vprintf(fmt, arg_ptr);
  21948.    va_end(arg_ptr);
  21949. }
  21950.  
  21951. /************************************************************************
  21952. *
  21953. Output 
  21954.  
  21955. /******************  Output should be similar to:  ****************
  21956. Mon  Tues  Wed   Thurs   Fri
  21957. */
  21958.  
  21959.                                                                         *
  21960. ************************************************************************/
  21961.  
  21962.  
  21963. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  21964.  
  21965. /************************************************************************
  21966. *
  21967. This example assigns a variable number of strings to string and prints the 
  21968. resultant string. 
  21969.  
  21970.                                                                         *
  21971. ************************************************************************/
  21972.  
  21973. #include <stdarg.h>
  21974. #include <stdio.h>
  21975. void vout(char *string, char *fmt, ...);
  21976. char fmt1 [] = "%s  %s  %s\n";
  21977. int main(void)
  21978. {
  21979.    char string[100];
  21980.    vout(string, fmt1, "Sat", "Sun", "Mon");
  21981.    printf("The string is:  %s\n", string);
  21982. }
  21983. void vout(char *string, char *fmt, ...)
  21984. {
  21985.    va_list arg_ptr;
  21986.    va_start(arg_ptr, fmt);
  21987.    vsprintf(string, fmt, arg_ptr);
  21988.    va_end(arg_ptr);
  21989. }
  21990.  
  21991. /************************************************************************
  21992. *
  21993. Output 
  21994.  
  21995. /******************  Output should be similar to:  ****************
  21996. The string is:  Sat  Sun  Mon
  21997. */
  21998.  
  21999.                                                                         *
  22000. ************************************************************************/
  22001.  
  22002.  
  22003. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22004.  
  22005. /************************************************************************
  22006. *
  22007. The following program creates a new process called CHILD.EXE, specifying 
  22008. P_NOWAIT when the child process is called. The parent process calls _wait and 
  22009. waits for the child process to stop running. The parent process then displays 
  22010. the return information of the child process in hexadecimal. 
  22011.  
  22012.                                                                         *
  22013. ************************************************************************/
  22014.  
  22015. #include <stdio.h>
  22016. #include <process.h>
  22017. int stat_child;
  22018. int main(void)
  22019. {
  22020.     int pid;
  22021.     _spawnl(P_NOWAIT,"child2.exe", "child2.exe", NULL);
  22022.     if ( (pid=_wait(&stat_child)) == -1 )
  22023.         perror(NULL);       /* Display error status message, if any */
  22024.     else
  22025.         printf("child process %d just ran.\n",pid);
  22026.     /* Display the word returned when child ended. */
  22027.     printf("return information was 0x%X\n",stat_child);
  22028.     return 0;
  22029. /* If the source for child2.exe is:                                    */
  22030. /*                                                                     */
  22031. /*  #include <stdio.h>                                                 */
  22032. /*  int main(void)                                                     */
  22033. /*  {                                                                  */
  22034. /*      puts("child2.exe is an executable file");                      */
  22035. /*  }                                                                  */
  22036. /*                                                                     */
  22037. /*  Then the ouput should be similar to:              */
  22038. /* child process 24 just ran.                         */
  22039. /* return information was 0x0                         */
  22040. }
  22041.  
  22042.  
  22043. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22044.  
  22045. /*************************************************************************
  22046. *
  22047. This program creates the wide character string "computer program" using wcscat. 
  22048.  
  22049.                                                                         *
  22050. ************************************************************************/
  22051.  
  22052. #include <stdio.h>
  22053. #include <wcstr.h>
  22054. #define SIZE 40
  22055. int main(void) {
  22056.   wchar_t buffer1[SIZE] = L"computer";
  22057.   wchar_t * string      = L" program";
  22058.   wchar_t * ptr;
  22059.   ptr = wcscat( buffer1, string );
  22060.   printf( "buffer1 = %ls\n", buffer1 );
  22061. }
  22062.  
  22063. /************************************************************************
  22064. *
  22065.  
  22066. /****************  Output should be similar to:  ******************
  22067. buffer1 = computer program
  22068. */
  22069.  
  22070.                                                                         *
  22071. ************************************************************************/
  22072.  
  22073.  
  22074. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22075.  
  22076. /*************************************************************************
  22077. *
  22078. This program finds the first occurrence of the character p in the wide 
  22079. character string "computer program". 
  22080.  
  22081.                                                                         *
  22082. ************************************************************************/
  22083.  
  22084. #include <stdio.h>
  22085. #include <wcstr.h>
  22086. #define SIZE 40
  22087. int main(void) {
  22088.   wchar_t buffer1[SIZE] = L"computer program";
  22089.   wchar_t * ptr;
  22090.   wchar_t ch = L'p';
  22091.   ptr = wcschr( buffer1, ch );
  22092.   printf( "The first occurrence of %lc in '%ls' is '%ls'\n",
  22093.                           ch, buffer1, ptr );
  22094. }
  22095.  
  22096. /************************************************************************
  22097. *
  22098.  
  22099. /****************  Output should be similar to:  ******************
  22100. The first occurrence of p in 'computer program' is 'puter program'
  22101. */
  22102.  
  22103.                                                                         *
  22104. ************************************************************************/
  22105.  
  22106.  
  22107. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22108.  
  22109. /*************************************************************************
  22110. *
  22111.  
  22112. The following example compares the wide character string string1 to string2 
  22113. using wcscmp. 
  22114.  
  22115.                                                                         *
  22116. ************************************************************************/
  22117.  
  22118. #include <stdio.h>
  22119. #include <wcstr.h>
  22120. int main(void) {
  22121.   int  result;
  22122.   wchar_t string1[] = L"abcdef";
  22123.   wchar_t string2[] = L"abcdefg";
  22124.   result = wcscmp( string1, string2 );
  22125.   if ( result == 0 )
  22126.     printf( "\"%ls\" is identical to \"%ls\"\n", string1, string2);
  22127.   else if ( result < 0 )
  22128.     printf( "\"%ls\" is less than \"%ls\"\n", string1, string2 );
  22129.   else
  22130.     printf( "\"%ls\" is greater than \"%ls\"\n", string1, string2);
  22131. }
  22132.  
  22133. /************************************************************************
  22134. *
  22135.  
  22136. /****************  Output should be similar to:  ******************
  22137. "abcdef" is less than "abcdefg"
  22138. */
  22139.  
  22140.                                                                         *
  22141. ************************************************************************/
  22142.  
  22143.  
  22144. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22145.  
  22146. /*************************************************************************
  22147. *
  22148. This program copies the contents of source to destination. 
  22149.  
  22150.                                                                         *
  22151. ************************************************************************/
  22152.  
  22153. #include <stdio.h>
  22154. #include <wcstr.h>
  22155. #define SIZE    40
  22156. int main(void) {
  22157.   wchar_t source[ SIZE ] = L"This is the source string";
  22158.   wchar_t destination[ SIZE ] = L"And this is the destination string";
  22159.   wchar_t * return_string;
  22160.   printf( "destination is originally = \"%ls\"\n", destination );
  22161.   return_string = wcscpy( destination, source );
  22162.   printf( "After wcscpy, destination becomes \"%ls\"\n", destination );
  22163. }
  22164.  
  22165. /************************************************************************
  22166. *
  22167.  
  22168. /****************  Output should be similar to:  ******************
  22169. destination is originally = "And this is the destination string"
  22170. After wcscpy, destination becomes "This is the source string"
  22171. */
  22172.  
  22173.                                                                         *
  22174. ************************************************************************/
  22175.  
  22176.  
  22177. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22178.  
  22179. /*************************************************************************
  22180. *
  22181. This program uses wcscspn to find the first occurrence of any of the characters 
  22182. a, x, l or e in string. 
  22183.  
  22184.                                                                         *
  22185. ************************************************************************/
  22186.  
  22187. #include <stdio.h>
  22188. #include <wcstr.h>
  22189. #define SIZE    40
  22190. int main(void) {
  22191.   wchar_t string[ SIZE ] = L"This is the source string";
  22192.   wchar_t * substring = L"axle";
  22193.   printf( "The first %i characters in the string \"%ls\" are not in the "
  22194.           "string \"%ls\" \n", wcscspn( string, substring), string, substring );
  22195. }
  22196.  
  22197. /************************************************************************
  22198. *
  22199.  
  22200. /****************  Output should be similar to:  ******************
  22201. The first 10 characters in the string "This is the source string" are not
  22202. in the string "axle"
  22203. */
  22204.  
  22205.                                                                         *
  22206. ************************************************************************/
  22207.  
  22208.  
  22209. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22210.  
  22211. /*************************************************************************
  22212. *
  22213. This example computes the length of a wchar_t string. 
  22214.  
  22215.                                                                         *
  22216. ************************************************************************/
  22217.  
  22218. #include <stdio.h>
  22219. #include <wcstr.h>
  22220. int main(void) {
  22221.   wchar_t * string = L"abcdef";
  22222.   printf( "Length of \"%ls\" is %i\n", string, wcslen( string ));
  22223. }
  22224.  
  22225. /************************************************************************
  22226. *
  22227.  
  22228. /****************  Output should be similar to:  ******************
  22229. Length of "abcdef" is 6
  22230. */
  22231.  
  22232.                                                                         *
  22233. ************************************************************************/
  22234.  
  22235.  
  22236. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22237.  
  22238. /*************************************************************************
  22239. *
  22240. This program demonstrates the difference between wcscat and wcsncat.  wcscat 
  22241. appends the entire second string to the first whereas wcsncat appends only the 
  22242. specified number of characters in the second string to the first. 
  22243.  
  22244.                                                                         *
  22245. ************************************************************************/
  22246.  
  22247. #include <stdio.h>
  22248. #include <wcstr.h>
  22249. #define SIZE 40
  22250. int main(void) {
  22251.   wchar_t buffer1[SIZE] = L"computer";
  22252.   wchar_t * ptr;
  22253.   /* Call wcscat with buffer1 and " program" */
  22254.   ptr = wcscat( buffer1, L" program" );
  22255.   printf( "wcscat : buffer1 = \"%ls\"\n", buffer1 );
  22256.   /* Reset buffer1 to contain just the string "computer" again */
  22257.   memset( buffer1, L'\0', sizeof( buffer1 ));
  22258.   ptr = wcscpy( buffer1, L"computer" );
  22259.   /* Call wcsncat with buffer1 and " program" */
  22260.   ptr = wcsncat( buffer1, L" program", 3 );
  22261.   printf( "wcsncat: buffer1 = \"%ls\"\n", buffer1 );
  22262. }
  22263.  
  22264. /************************************************************************
  22265. *
  22266.  
  22267. /****************  Output should be similar to:  ******************
  22268. wcscat : buffer1 = "computer program"
  22269. wcsncat: buffer1 = "computer pr"
  22270. */
  22271.  
  22272.                                                                         *
  22273. ************************************************************************/
  22274.  
  22275.  
  22276. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22277.  
  22278. /*************************************************************************
  22279. *
  22280. This program demonstrates the difference between wcscmp and wcsncmp. 
  22281.  
  22282.                                                                         *
  22283. ************************************************************************/
  22284.  
  22285. #include <stdio.h>
  22286. #include <wcstr.h>
  22287. #define SIZE 10
  22288. int main(void) {
  22289.   int  result;
  22290.   int  index = 3;
  22291.   wchar_t buffer1[SIZE] = L"abcdefg";
  22292.   wchar_t buffer2[SIZE] = L"abcfg";
  22293.   void print_result( int, wchar_t *, wchar_t * );
  22294.   result = wcscmp( buffer1, buffer2 );
  22295.   printf( "Comparison of each character\n" );
  22296.   printf( "  wcscmp: " );
  22297.   print_result( result, buffer1, buffer2 );
  22298.   result = wcsncmp( buffer1, buffer2, index);
  22299.   printf( "\nComparison of only the first %i characters\n", index );
  22300.   printf( "  wcsncmp: " );
  22301.   print_result( result, buffer1, buffer2 );
  22302. }
  22303. void print_result( int res, wchar_t * p_buffer1, wchar_t * p_buffer2 ) {
  22304.   if ( res == 0 )
  22305.     printf( "\"%ls\" is identical to \"%ls\"\n", p_buffer1, p_buffer2);
  22306.   else if ( res < 0 )
  22307.     printf( "\"%ls\" is less than \"%ls\"\n", p_buffer1, p_buffer2 );
  22308.   else
  22309.     printf( "\"%ls\" is greater than \"%ls\"\n", p_buffer1, p_buffer2 );
  22310. }
  22311.  
  22312. /************************************************************************
  22313. *
  22314.  
  22315. /****************  Output should be similar to:  ******************
  22316. Comparison of each character
  22317.   wcscmp: "abcdefg" is less than "abcfg"
  22318. Comparison of only the first 3 characters
  22319.   wcsncmp: "abcdefg" is identical to "abcfg"
  22320. */
  22321.  
  22322.                                                                         *
  22323. ************************************************************************/
  22324.  
  22325.  
  22326. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22327.  
  22328. /*************************************************************************
  22329. *
  22330. This program demonstrates the difference between wcscpy and wcsncpy. 
  22331.  
  22332.                                                                         *
  22333. ************************************************************************/
  22334.  
  22335. #include <stdio.h>
  22336. #include <wcstr.h>
  22337. #define SIZE    40
  22338. int main(void) {
  22339.   wchar_t source[ SIZE ] = L"123456789";
  22340.   wchar_t source1[ SIZE ] = L"123456789";
  22341.   wchar_t destination[ SIZE ] = L"abcdefg";
  22342.   wchar_t destination1[ SIZE ] = L"abcdefg";
  22343.   wchar_t * return_string;
  22344.   int    index = 5;
  22345.   /* This is how wcscpy works */
  22346.   printf( "destination is originally = '%ls'\n", destination );
  22347.   return_string = wcscpy( destination, source );
  22348.   printf( "After wcscpy, destination becomes '%ls'\n\n", destination );
  22349.   /* This is how wcsncpy works */
  22350.   printf( "destination1 is originally = '%ls'\n", destination1 );
  22351.   return_string = wcsncpy( destination1, source1, index );
  22352.   printf( "After wcsncpy, destination1 becomes '%ls'\n", destination1 );
  22353. }
  22354.  
  22355. /************************************************************************
  22356. *
  22357.  
  22358. /****************  Output should be similar to:  ******************
  22359. destination is originally = 'abcdefg'
  22360. After wcscpy, destination becomes '123456789'
  22361. destination1 is originally = 'abcdefg'
  22362. After wcsncpy, destination1 becomes '12345fg'
  22363. */
  22364.  
  22365.                                                                         *
  22366. ************************************************************************/
  22367.  
  22368.  
  22369. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22370.  
  22371. /************************************************************************
  22372. *
  22373. The following example returns a pointer to the first occurrence in the array 
  22374. string of either a or b. 
  22375.  
  22376.                                                                         *
  22377. ************************************************************************/
  22378.  
  22379. #include <stdio.h>
  22380. #include <wcstr.h>
  22381. int main(void) {
  22382.   wchar_t * result;
  22383.   wchar_t * string = L"A Blue Danube";
  22384.   wchar_t *chars = L"ab";
  22385.   result = wcspbrk( string, chars);
  22386.    printf("The first occurrence of any of the characters \"%ls\" in "
  22387.           "\"%ls\" is \"%ls\"\n", chars, string, result);
  22388. }
  22389.  
  22390. /************************************************************************
  22391. *
  22392.  
  22393. /****************  Output should be similar to:  ******************
  22394. The first occurrence of any of the characters "ab" in "A Blue Danube" is "anube"
  22395. */
  22396.  
  22397.                                                                         *
  22398. ************************************************************************/
  22399.  
  22400.  
  22401. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22402.  
  22403. /************************************************************************
  22404. *
  22405. The following example compares the use of wcschr and wcsrchr.  It searches the 
  22406. string for the first and last occurrence of p in the wide character string. 
  22407.  
  22408.                                                                         *
  22409. ************************************************************************/
  22410.  
  22411. #include <stdio.h>
  22412. #include <wcstr.h>
  22413. #define SIZE 40
  22414. int main(void) {
  22415.   wchar_t buf[SIZE] = L"computer program";
  22416.   wchar_t * ptr;
  22417.   int    ch = 'p';
  22418.   /* This illustrates wcschr */
  22419.   ptr = wcschr( buf, ch );
  22420.   printf( "The first occurrence of %c in '%ls' is '%ls'\n", ch, buf, ptr );
  22421.   /* This illustrates wscrchr */
  22422.   ptr = wcsrchr( buf, ch );
  22423.   printf( "The last occurrence of %c in '%ls' is '%ls'\n",  ch, buf, ptr );
  22424. }
  22425.  
  22426. /************************************************************************
  22427. *
  22428.  
  22429. /****************  Output should be similar to:  ******************
  22430. The first occurrence of p in 'computer program' is 'puter program'
  22431. The last occurrence of p in 'computer program' is 'program'
  22432. */
  22433.  
  22434.                                                                         *
  22435. ************************************************************************/
  22436.  
  22437.  
  22438. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22439.  
  22440. /************************************************************************
  22441. *
  22442. The following example finds the first occurrence in the array string of a 
  22443. character that is neither an a, b, nor c.  Because the string in this example 
  22444. is cabbage, wcsspn returns 5, the index of the segment of cabbage before a 
  22445. character that is not an a, b or c. 
  22446.  
  22447.                                                                         *
  22448. ************************************************************************/
  22449.  
  22450. #include <stdio.h>
  22451. #include <wcstr.h>
  22452. int main(void) {
  22453.   wchar_t * string = L"cabbage";
  22454.   wchar_t * source = L"abc";
  22455.   int index;
  22456.   index = wcsspn( string, L"abc" );
  22457.   printf( "The first %d characters of \"%ls\" are found in \"%ls\"\n",
  22458.               index, string, source );
  22459. }
  22460.  
  22461. /************************************************************************
  22462. *
  22463.  
  22464. /****************  Output should be similar to:  ******************
  22465. The first 5 characters of "cabbage" are found in "abc"
  22466. */
  22467.  
  22468.                                                                         *
  22469. ************************************************************************/
  22470.  
  22471.  
  22472. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22473.  
  22474. /*************************************************************************
  22475. *
  22476. In the following example, a wchar_t string is converted to a char string twice. 
  22477. The first call converts the entire string while the second call only converts 3 
  22478. characters. The results are printed each time. 
  22479.  
  22480.                                                                         *
  22481. ************************************************************************/
  22482.  
  22483. #include <stdio.h>
  22484. #include <stdlib.h>
  22485. #include <string.h>
  22486. #define SIZE 20
  22487. int main(void) {
  22488.   char dest[SIZE];
  22489.   wchar_t * dptr = L"string";
  22490.   size_t count = SIZE;
  22491.   size_t length;
  22492.   length = wcstombs( dest, dptr, count );
  22493.   printf( "%d characters were converted.\n", length );
  22494.   printf( "The converted string is \"%s\"\n\n", dest );
  22495.   /* Reset the destination buffer */
  22496.   memset( dest, '\0', sizeof(dest));
  22497.   /* Now convert only 3 characters */
  22498.   length = wcstombs( dest, dptr, 3 );
  22499.   printf( "%d characters were converted.\n", length );
  22500.   printf( "The converted string is \"%s\"\n", dest );
  22501. }
  22502.  
  22503. /************************************************************************
  22504. *
  22505.  
  22506. /****************  Output should be similar to:  ******************
  22507. 6 characters were converted.
  22508. The converted string is "string"
  22509. 3 characters were converted.
  22510. The converted string is "str"
  22511. */
  22512.  
  22513.                                                                         *
  22514. ************************************************************************/
  22515.  
  22516.  
  22517. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22518.  
  22519. /*************************************************************************
  22520. *
  22521. The following example finds the first occurrence of the wide character string 
  22522. pr in buffer1. 
  22523.  
  22524.                                                                         *
  22525. ************************************************************************/
  22526.  
  22527. #include <stdio.h>
  22528. #include <wcstr.h>
  22529. #define SIZE 40
  22530. int main(void) {
  22531.   wchar_t buffer1[SIZE] = L"computer program";
  22532.   wchar_t * ptr;
  22533.   wchar_t * wch = L"pr";
  22534.   ptr = wcswcs( buffer1, wch );
  22535.   printf( "The first occurrence of %ls in '%ls' is '%ls'\n",
  22536.                           wch, buffer1, ptr );
  22537. }
  22538.  
  22539. /************************************************************************
  22540. *
  22541.  
  22542. /****************  Output should be similar to:  ******************
  22543. The first occurrence of pr in 'computer program' is 'program'
  22544. */
  22545.  
  22546.                                                                         *
  22547. ************************************************************************/
  22548.  
  22549.  
  22550. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22551.  
  22552. /*************************************************************************
  22553. *
  22554. The following example converts the wide character c to a character. 
  22555.  
  22556.                                                                         *
  22557. ************************************************************************/
  22558.  
  22559. #include <stdio.h>
  22560. #include <stdlib.h>
  22561. #define SIZE 40
  22562. int main(void) {
  22563.   static char  buffer[ SIZE ];
  22564.   wchar_t wch = L'c';
  22565.   int length;
  22566.   length = wctomb( buffer, wch );
  22567.   printf( "The number of bytes that comprise the multibyte "
  22568.              "character is %i\n", length );
  22569.   printf( "And the converted string is \"%s\"\n", buffer );
  22570. }
  22571.  
  22572. /************************************************************************
  22573. *
  22574.  
  22575. /****************  Output should be similar to:  ******************
  22576. The number of bytes that comprise the multibyte character is 1
  22577. And the converted string is "c"
  22578. */
  22579.  
  22580.                                                                         *
  22581. ************************************************************************/
  22582.  
  22583.  
  22584. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  22585.  
  22586. /************************************************************************
  22587. *
  22588.  
  22589. The following program writes the contents of the character array buffer to the 
  22590. output file whose handle is fh. 
  22591.  
  22592.                                                                         *
  22593. ************************************************************************/
  22594.  
  22595. #include <io.h>
  22596. #include <stdio.h>
  22597. #include <stdlib.h>
  22598. #include <fcntl.h>
  22599. #include <string.h>
  22600. int main(void)
  22601.    {
  22602.    int  fh;
  22603.    char buffer[20];
  22604.    memset(buffer,'a',20);  /* initialize storage  */
  22605.    printf("\nCreating sample.dat.\n");
  22606.    system("echo Sample Program > sample.dat");
  22607.    if (-1 == (fh = _open("sample.dat",O_RDWR | O_APPEND)))
  22608.       {
  22609.       perror("Unable to open sample.dat");
  22610.       return 1;
  22611.       }
  22612.    if (5 != _write(fh,buffer,5) )
  22613.       {
  22614.       perror("Unable to write to sample.dat");
  22615.       _close(fh);
  22616.       return 1;
  22617.       }
  22618.    printf("Successfully appended 5 characters.\n");
  22619.    _close(fh);
  22620.    return 0;
  22621. /******************  The expected output is:  ***************************
  22622.       Creating sample.dat.
  22623.       Successfully appended 5 characters.
  22624. */
  22625.    }
  22626.