home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv4.zip / VACPP / IBMCPP / HELP / CPPLIB.INF (.txt) < prev    next >
OS/2 Help File  |  1995-05-04  |  1MB  |  40,590 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. About this Reference ΓòÉΓòÉΓòÉ
  3.  
  4. The VisualAge C++ C Library Reference describes the the VisualAge C++ 
  5. implementation of the C runtime library. Use it to find information about what 
  6. the different library functions do and how to declare and use them. This 
  7. reference also provides code examples that you can copy to a file and paste 
  8. into your own applications. 
  9.  
  10. This document is a reference rather than a tutorial.  It assumes you are 
  11. already familiar with C and C++ programming concepts. Information applies to 
  12. the C language, but you can also call the functions and macros from C++ 
  13. applications. 
  14.  
  15. For a list of other information that you might also find helpful, see Other 
  16. Information You Might Find Helpful. 
  17.  
  18. Before you begin to use this information, it would be helpful to understand how 
  19. to navigate through it. You can use the Table of Contents and Index facility to 
  20. locate topics and the Search facility to search the text of this document. You 
  21. can use hypertext links to acquire related information on the current topic. 
  22. Hypertext links appear in a different color (which you can customize using the 
  23. OS/2 Scheme Palette). For example, here is a link to another panel: 
  24. Communicating Your Comments to IBM. By double-clicking on the text of the link 
  25. or by pressing Enter on a highlighted link, you will open a panel of related 
  26. information. When you open a panel, the first link has the focus; to shift the 
  27. focus to other links, use the Tab key. 
  28.  
  29. You should also understand: 
  30.  
  31.      How to Use the Contents 
  32.      How to Obtain Additional Information 
  33.      How to Use Action Bar Choices 
  34.      How to Cut and Paste Examples 
  35.  
  36.  The following highlighting conventions are used in this reference: 
  37.  
  38.  Bold      Identifies commands and language keywords. 
  39.  
  40.  Italics   Identify parameters whose actual names or or values are to be 
  41.            supplied by the programmer. 
  42.  
  43.  Example   Identifies function names, examples of specific data values, 
  44.            examples of text similar to what you might see displayed, examples 
  45.            of portions of program code, messages from the system, or 
  46.            information that you should actually type. 
  47.  
  48.  
  49. ΓòÉΓòÉΓòÉ 1.1. Notices ΓòÉΓòÉΓòÉ
  50.  
  51. Copyright International Business Machines Corporation, 1992, 1995. All rights 
  52. reserved. 
  53.  
  54. Note to U.S. Government Users - Documentation related to restricted rights - 
  55. Use, duplication, or disclosure is subject to restrictions set forth in GSA ADP 
  56. Schedule Contract with IBM Corp. 
  57.  
  58. Third Edition, May 1995. 
  59.  
  60. This edition applies to Version 3.0 of IBM VisualAge C++ for OS/2 (30H1664, 
  61. 30H1665, 30H1666) and to all subsequent releases and modifications until 
  62. otherwise indicated in new editions.  Make sure you are using the correct 
  63. edition for the level of the product. 
  64.  
  65. Changes are periodically made to the information herein; any such changes will 
  66. be reported in subsequent revisions. 
  67.  
  68. Requests for publications and for technical information about IBM products 
  69. should be made to your IBM Authorized Dealer or your IBM Marketing 
  70. Representative. 
  71.  
  72. When you send information to IBM, you grant IBM a nonexclusive right to use or 
  73. distribute the information in any ways it believes appropriate without 
  74. incurring any obligation to you. 
  75.  
  76. Any reference to an IBM licensed program in this publication is not intended to 
  77. state or imply that only IBM's licensed program may be used. Any functionally 
  78. equivalent product, program, or service that does not infringe any of IBM's 
  79. intellectual property rights may be used instead of the IBM product, program, 
  80. or service. Evaluation and verification of operation in conjunction with other 
  81. products, except those expressly designated by IBM, is the user's 
  82. responsibility. 
  83.  
  84. IBM may have patents or pending patent applications covering subject matter in 
  85. this document.  The furnishing of this document does not give you any license 
  86. to these patents.  You can send license inquiries, in writing, to the IBM 
  87. Director of Licensing, IBM Corporation, 500 Columbus Avenue, Thornwood, NY, 
  88. 10594, USA. 
  89.  
  90. This publication contains examples of data and reports used in daily business 
  91. operations. To illustrate them as completely as possible, the examples include 
  92. the names of individuals, companies, brands, and products. All of these names 
  93. are fictitious and any similarity to the names and addresses used by an actual 
  94. business enterprise is entirely coincidental. 
  95.  
  96.  
  97. ΓòÉΓòÉΓòÉ 1.2. Programming Interface Information ΓòÉΓòÉΓòÉ
  98.  
  99. This book is intended to help you create programs using VisualAge C++ product. 
  100. It primarily documents General-Use Programming Interface and Associated 
  101. Guidance Information provided by VisualAge C++ product. 
  102.  
  103. General-Use programming interfaces allow the customer to write programs that 
  104. obtain the services of VisualAge C++ compiler and debugger. 
  105.  
  106. However, this book also documents Diagnosis, Modification, and Tuning 
  107. Information. Diagnosis, Modification, and Tuning Information is provided to 
  108. help you debug your programs. 
  109.  
  110. Warning: Do not use this Diagnosis, Modification, and Tuning Information as a 
  111. programming interface because it is subject to change. 
  112.  
  113. Diagnosis, Modification, and Tuning Information is identified where it occurs 
  114. by an introductory statement to a chapter or section. 
  115.  
  116.  
  117. ΓòÉΓòÉΓòÉ 1.3. Trademarks and Service Marks ΓòÉΓòÉΓòÉ
  118.  
  119. The following terms used in this publication are trademarks or service marks of 
  120. IBM Corporation in the United States or other countries: 
  121.  
  122.       AIX 
  123.       BookManager 
  124.       C/2 
  125.       C Set/2 
  126.       C Set ++ 
  127.       IBM 
  128.       IBMLink 
  129.       Library Reader 
  130.       Operating System/2 
  131.       OS/2 
  132.       Personal System/2 
  133.       Presentation Manager 
  134.       PS/2 
  135.       PROFS 
  136.       SAA 
  137.       Systems Application Architecture 
  138.       VisualAge 
  139.       WorkFrame/2 
  140.       Workplace Shell 
  141.  
  142.  Other company, product, and service names, which may be denoted by a double 
  143.  asterisk (**), may be trademarks or service marks of others. 
  144.  
  145.  
  146. ΓòÉΓòÉΓòÉ 1.4. How to Use the Contents ΓòÉΓòÉΓòÉ
  147.  
  148. When the Contents window first appears, some topics have a plus (+) sign beside 
  149. them. The plus sign indicates that additional topics are available. 
  150.  
  151. To expand the Contents if you are using a mouse, click on the plus sign. If you 
  152. are using the keyboard, use the Up or Down Arrow key to highlight the topic, 
  153. and press the plus (+) key. For example, How to Use the Contents has a plus 
  154. sign beside it.  To see additional topics for that heading, click on the plus 
  155. sign or highlight that topic and press the plus (+) key. 
  156.  
  157. To view a topic, double-click on the topic (or press the Up or Down Arrow key 
  158. to highlight the topic, and then press the Enter key). 
  159.  
  160.  
  161. ΓòÉΓòÉΓòÉ 1.5. How to Obtain Additional Information ΓòÉΓòÉΓòÉ
  162.  
  163. After you select a topic, the information for that topic appears in a window. 
  164. Highlighted words or phrases indicate that additional information is available. 
  165. Certain words and phrases are highlighted in a different color from the 
  166. surrounding text. These are called hypertext terms. 
  167.  
  168. If you are using a mouse, double-click on the highlighted word.  If you are 
  169. using a keyboard, press the Tab key to move to the highlighted word, and then 
  170. press the Enter key.  Additional information then appears in a window. 
  171.  
  172.  
  173. ΓòÉΓòÉΓòÉ 1.6. How to Use Action Bar Choices ΓòÉΓòÉΓòÉ
  174.  
  175. Several choices are available for managing the information presented in this 
  176. document. There are three menus on the action bar:  the Services menu, the 
  177. Options menu, and the Help menu. 
  178.  
  179. The actions that are selectable from the Services menu operate on the active 
  180. window currently displayed on the screen. These actions include the following: 
  181.  
  182.  Placing Bookmarks 
  183.    You can set a placeholder so you can retrieve information of interest to 
  184.    you. 
  185.  
  186.  Searching for Information 
  187.    You can find occurrences of a word or phrase in the current topic, selected 
  188.    topics, or all topics. 
  189.  
  190.  Printing Information 
  191.    You can print one or more topics. You can also print a set of topics by 
  192.    first marking the topics in the Contents list. 
  193.  
  194.  Copying Information to a File 
  195.    You can copy a topic that you are viewing to the System Clipboard or to a 
  196.    file that you can edit. This method is particularly useful for copying 
  197.    syntax definitions and program samples into the application that you are 
  198.    developing. 
  199.  
  200.  Using the actions that are selectable from the Options menu, you can change 
  201.  the way your Contents list is displayed. To expand the Contents and show all 
  202.  levels for all topics, choose Expand all from the Options pull-down. You can 
  203.  also press the Ctrl and * keys together. 
  204.  
  205.  The actions that are selectable from the Help menu allow you to select 
  206.  different types of help information. 
  207.  
  208.  For information about any of the pull-down menu choices, highlight the choice 
  209.  in the menu and press F1. 
  210.  
  211.  
  212. ΓòÉΓòÉΓòÉ 1.6.1. Placing Bookmarks ΓòÉΓòÉΓòÉ
  213.  
  214. When you place a bookmark on a topic, it is added to a list of bookmarks you 
  215. have previously set.  You can view the list, and you can remove one or all 
  216. bookmarks from the list.  If you have not set any bookmarks, the list is empty. 
  217.  
  218. To set a bookmark, do the following: 
  219.  
  220.    1. Select a topic from the Contents. 
  221.    2. When that topic appears, choose the Bookmark option from the Services 
  222.       menu. 
  223.    3. If you want to change the name used for the bookmark, type the new name 
  224.       in the field. 
  225.    4. Click on the Place radio button (or press the Up or Down Arrow key to 
  226.       select it). 
  227.    5. Click on OK (or select it and press Enter). The bookmark is then added to 
  228.       the bookmark list. 
  229.  
  230.  
  231. ΓòÉΓòÉΓòÉ 1.6.2. Searching for Information ΓòÉΓòÉΓòÉ
  232.  
  233. You can specify a word or phrase to be searched.  You can also limit the search 
  234. to a set of topics by first marking the topics in the Contents list. 
  235.  
  236. To search for a word or phrase in all topics, do the following: 
  237.  
  238.    1. Choose the Search option from the Services menu. 
  239.    2. Type the word or words to be searched for. 
  240.    3. Click on All sections (or press the Up or Down Arrow keys to select it). 
  241.    4. Click on Search (or select it and press Enter) to begin the search. 
  242.    5. The list of topics where the word or phrase appears is displayed. 
  243.  
  244.  
  245. ΓòÉΓòÉΓòÉ 1.6.3. Printing Information ΓòÉΓòÉΓòÉ
  246.  
  247. You can print one or more topics, the index, or the table of contents.  Make 
  248. sure that your printer is connected to the serial port, configured correctly, 
  249. and ready for input. To print: 
  250.  
  251.    1. Choose Print from the Services menu. 
  252.    2. Select what you want to print. Note that the This section and Marked 
  253.       sections choices are only available if you are viewing a topic or if you 
  254.       have marked topics, respectively.  To mark topics in the table of 
  255.       contents, press the Ctrl key and click on the topics, or use the arrow 
  256.       keys. 
  257.    3. Select Print to print what you've chosen on your printer. 
  258.  
  259.  
  260. ΓòÉΓòÉΓòÉ 1.6.4. Copying Information to a File ΓòÉΓòÉΓòÉ
  261.  
  262. You can copy a topic that you are viewing in two ways: 
  263.  
  264.      Copy copies the topic that you are viewing into the System Clipboard.  If 
  265.       you are using a Presentation Manager (PM) editor (for example, the 
  266.       Enhanced Editor) that copies or cuts (or both) to the System Clipboard, 
  267.       and pastes to the System Clipboard, you can easily add the copied 
  268.       information to your program source module. 
  269.  
  270.      Copy to file copies the topic that you are viewing into a temporary file 
  271.       named TEXT.TMP.  You can later edit that file by using any editor. 
  272.       TEXT.TMP is placed in the directory where your viewable document resides. 
  273.  
  274.  To copy a topic, do the following: 
  275.  
  276.    1. Expand the Contents list and select a topic. 
  277.    2. When the topic appears, choose Copy to file from the Services menu. 
  278.    3. The system puts the text pertaining to that topic into the temporary file 
  279.       TEXT.TMP. 
  280.  
  281.  
  282. ΓòÉΓòÉΓòÉ 1.7. How to Cut and Paste Examples ΓòÉΓòÉΓòÉ
  283.  
  284. You can copy examples (or information) from this reference to compile, link, 
  285. and run them, or to paste them into your own code. 
  286.  
  287. To copy an example or information: 
  288.  
  289.    1. Make the topic you want to copy the active window. 
  290.  
  291.    2. From the Services menu, select Copy to file. The text in that topic is 
  292.       placed in the temporary file TEXT.TMP, in the same directory as this 
  293.       reference. 
  294.  
  295.    3. You can then modify or use TEXT.TMP as you want. 
  296.  
  297.  Note:  Because the system copies the entire contents of the topic to the file, 
  298.  you may need to edit it to remove additional text. Most examples in this 
  299.  reference are ready to compile, link, and run as they appear, and do not 
  300.  require any editing. 
  301.  
  302.  
  303. ΓòÉΓòÉΓòÉ 1.8. Other Information You Might Find Helpful ΓòÉΓòÉΓòÉ
  304.  
  305. This product provides a number of online guides and references that we hope 
  306. you'll find helpful as you develop applications. This information includes 
  307. User's Guides, References, and How Do I help that gives you specific 
  308. instructions for performing common tasks. You can get to this online 
  309. information from the Information folder inside the main product folder.  You 
  310. can also get to it from the Help menu in any of the components of the product. 
  311.  
  312. You may want to use the following books with this Library Reference: 
  313.  
  314.  Programming Guide 
  315.       Describes different programming and coding techniques. 
  316.  C/C++ Language Reference 
  317.       Describes the VisualAge C++ implementation of the C and C++ languages. 
  318.  Control Programming Guide and Reference 
  319.       Describes the OS/2 Dos APIs and how to use them. 
  320.  Presentation Manager Programming Guide and Reference 
  321.       Describes the PM APIs and how to use them. 
  322.  Graphics Programming Guide and Reference 
  323.       Describes the graphics APIs and how to use them. 
  324.  
  325.  
  326. ΓòÉΓòÉΓòÉ 1.9. Communicating Your Comments to IBM ΓòÉΓòÉΓòÉ
  327.  
  328. If there is something you like, or dislike, about this book, please let us 
  329. know.  You can use one of the methods listed below to send your comments to 
  330. IBM.  Please be sure to include the complete title of the publication that you 
  331. are commenting on. 
  332.  
  333. The comments you send should only pertain to the information in this document 
  334. and its presentation.  To request additional publications or to ask questions 
  335. or make comments about the functions of IBM products or systems, you should 
  336. talk to your IBM representative or you authorized IBM remarketer. 
  337.  
  338. When you send comments to IBM, you grant IBM a nonexclusive right to use or 
  339. distribute your comments in any way it believes appropriate without incurring 
  340. any obligation to you. 
  341.  
  342. You can send your comments to IBM in the following ways: 
  343.  
  344.      By mail to the following address: 
  345.  
  346.             IBM Canada Ltd. Laboratory
  347.             Information Development
  348.             2G/345/1150/TOR
  349.             1150 EGLINTON AVENUE EAST
  350.             NORTH YORK, ONTARIO
  351.             CANADA M3C 1H7
  352.  
  353.      By FAX to the following number: 
  354.  
  355.         -  United States and Canada: (416) 448-6161 
  356.         -  Other countries (+1) 416-448-6161 
  357.  
  358.      By electronic mail to one of the following IDs.  Be sure to include your 
  359.       entire network address if you wish to get a reply. 
  360.  
  361.         -  Internet: torrcf@vnet.ibm.com 
  362.         -  IBMLink: toribm(torrcf) 
  363.         -  IBM/PROFS: torolab4(torrcf) 
  364.         -  IBMMAIL: ibmmail(caibmwt9 
  365.  
  366.  
  367. ΓòÉΓòÉΓòÉ 1.10. Changes to the C Library and this Document ΓòÉΓòÉΓòÉ
  368.  
  369. This section describes the changes made to the C runtime library for 
  370. VisualAge C++ Version 3.0, and to this book, S25H-6964, from the previous 
  371. version, S61G-1183. 
  372.  
  373. Changes to the C Library 
  374.  
  375.      The runtime library now supports locales and internationalization based 
  376.       on the IEEE POSIX P1003.2 and X/Open Portability Guide standards for 
  377.       global locales and coded character sets. 
  378.  
  379.      To support locales, including wide character sets, new functions, header 
  380.       files, and environment variables have been added. The functions include a 
  381.       number of multibyte functions defined in the 1993 proposed amendment to 
  382.       the ANSI/ISO C standard. 
  383.  
  384.      The memory management support has been completely redesigned to improve 
  385.       flexibility and performance.  Enhancements include: 
  386.  
  387.         -  Functions for creating and using your own memory heaps. 
  388.         -  Additional heap-checking functions. 
  389.         -  Support for shared memory heaps. 
  390.         -  A new environment variable, DDE4_HEAP_SKIP, that you can use to 
  391.            determine how often the heap is checked by debug memory management 
  392.            functions. 
  393.         -  Debug versions of the tiled memory management functions. 
  394.         -  Significantly reduced overhead per allocation from previous 
  395.            releases. 
  396.  
  397.       Note:  The new memory management design could surface memory problems in 
  398.              your applications that the previous version of C Set ++ did not 
  399.              catch.  If exceptions or problems occur that did not occur with 
  400.              earlier versions: 
  401.  
  402.         1. Rebuild your application to generate debug information and enable 
  403.            memory debugging (/Ti /Tm compiler options). 
  404.         2. Run your application and redirect stderr to a file (the memory debug 
  405.            messages are sent to stderr by default). 
  406.         3. Use the memory debug messages (and the debugger) to correct your 
  407.            memory problem. 
  408.  
  409.       Common problems are freeing an object twice, freeing an invalid object, 
  410.       writing to a freed object, or overwriting an allocated object beyond its 
  411.       requested size. 
  412.  
  413.       You can simplify your debugging by using the debugger and setting 
  414.       appropriate breakpoints when the object is allocated, freed, or written 
  415.       to.  You can also set a breakpoint on abort, which is called when a 
  416.       memory problem is detected. 
  417.  
  418.       The Debugger also has a new feature you can use to automatically check 
  419.       all the memory heaps in your application each time your application stops 
  420.       running (for example, hits a breakpoint).  See the User's Guide for more 
  421.       information about the Debugger. 
  422.  
  423.      Some VisualAge C++ extensions no longer begin with an underscore for 
  424.       compatibility with the X/Open standard: 
  425.  
  426.             ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  427.             Γöé access       Γöé execlp       Γöé isatty       Γöé stat       Γöé
  428.             Γöé chdir       Γöé execv       Γöé lfind       Γöé swab       Γöé
  429.             Γöé chmod       Γöé execve       Γöé lsearch      Γöé tempnam      Γöé
  430.             Γöé close       Γöé execvp       Γöé lseek       Γöé tzset       Γöé
  431.             Γöé creat       Γöé fdopen       Γöé mkdir       Γöé umask       Γöé
  432.             Γöé dup        Γöé fileno       Γöé open        Γöé unlink      Γöé
  433.             Γöé dup2        Γöé fstat       Γöé putenv       Γöé utime       Γöé
  434.             Γöé execl       Γöé getpid       Γöé read        Γöé wait       Γöé
  435.             Γöé execle       Γöé isascii      Γöé rmdir       Γöé write       Γöé
  436.             ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  437.  
  438.       To ensure compatibility with previous C Set ++ releases, VisualAge C++ 
  439.       maps the underscored name to the appropriate function name for you (for 
  440.       example, _access to access). 
  441.  
  442.      Functions to enable fast RAM semaphores have been added (__cxchg, 
  443.       __lxchg, and __sxchg). 
  444.  
  445.      The printf family of functions now prints (null) if you specify a null 
  446.       string for the %s or %ls format specifier. In previous releases, the 
  447.       printf functions produced no output for a null string. 
  448.  
  449.      The names of the runtime library files have changed. The new naming 
  450.       convention is: 
  451.  
  452.               CPPpivvt
  453.  
  454.       where: 
  455.  
  456.       p        Is the platform or operating system. 
  457.       i        Is the library identifier. 
  458.       vv       Is the version number. 
  459.       t        Is the type of library 
  460.  
  461.       The resulting library names are: 
  462.  
  463.             ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  464.             Γöé CHARAΓöéTPOSITΓöéON   Γöé    Γöé    Γöé SIGNIFICANCE                Γöé
  465.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  466.             Γöé 1-3  Γöé 4   Γöé 5   Γöé 6-7  Γöé 8   Γöé                      Γöé
  467.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  468.             Γöé CPP  Γöé    Γöé    Γöé    Γöé    Γöé Product prefix               Γöé
  469.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  470.             Γöé    Γöé O   Γöé    Γöé    Γöé    Γöé OS/2 platform               Γöé
  471.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  472.             Γöé    Γöé    Γöé S   Γöé    Γöé    Γöé  Single-thread environment         Γöé
  473.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  474.             Γöé    Γöé    Γöé M   Γöé    Γöé    Γöé  Multithread environment          Γöé
  475.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  476.             Γöé    Γöé    Γöé N   Γöé    Γöé    Γöé  No runtime environment (subsystem)    Γöé
  477.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  478.             Γöé    Γöé    Γöé    Γöé 30  Γöé    Γöé Version number 3.0             Γöé
  479.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  480.             Γöé    Γöé    Γöé    Γöé    Γöé I   Γöé  Import library              Γöé
  481.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  482.             Γöé    Γöé    Γöé    Γöé    Γöé O   Γöé  Object library (contains initialization  Γöé
  483.             Γöé    Γöé    Γöé    Γöé    Γöé    Γöé routines)                 Γöé
  484.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  485.             Γöé    Γöé    Γöé    Γöé    Γöé    Γöé  Statically bound library (no eighth    Γöé
  486.             Γöé    Γöé    Γöé    Γöé    Γöé    Γöé letter)                  Γöé
  487.             ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  488.  
  489.  Changes to this Publication 
  490.  
  491.      The section on memory management functions has been expanded. 
  492.  
  493.      Information has been added for all new functions. 
  494.  
  495.      Information has been added for the DLL initialization and termination 
  496.       functions. 
  497.  
  498.      The order of chapters has been revised. 
  499.  
  500.      Minor technical and editorial changes have been made. 
  501.  
  502.  
  503. ΓòÉΓòÉΓòÉ 2. The C Library ΓòÉΓòÉΓòÉ
  504.  
  505. This section summarizes the available C library functions. It also briefly 
  506. describes what the function does. Each library function is listed according to 
  507. the type of function it performs. 
  508.  
  509.      Error Handling 
  510.      Process Control 
  511.      File and Directory Management 
  512.      Searching and Sorting 
  513.      Regular Expressions 
  514.      Mathematical 
  515.      Fast RAM Semaphores 
  516.      Floating-Point Unit Control 
  517.      Date, Time, and Monetary Manipulation 
  518.      Type Conversion 
  519.      Stream Input/Output 
  520.      Low-Level Input/Output 
  521.      Handling Argument Lists 
  522.      Pseudorandom Numbers 
  523.      Dynamic Memory Management 
  524.      Memory Objects 
  525.      Environment and Locale Interaction 
  526.      String Operations 
  527.      Character Testing 
  528.      Case Mapping 
  529.      Multibyte Character Manipulation 
  530.  
  531.  
  532. ΓòÉΓòÉΓòÉ 2.1. Error Handling Functions ΓòÉΓòÉΓòÉ
  533.  
  534.      assert - Verify Condition 
  535.      atexit - Record Program Termination Function 
  536.      clearerr - Reset Error Indicators. 
  537.      ferror - Test for Read/Write Errors 
  538.      _matherr - Process Math Library Errors 
  539.      perror - Print Error Message 
  540.      raise - Send Signal 
  541.      _set_crt_msg_handle - Change Runtime Message Output Destination 
  542.      signal - Handle Interrupt Signals 
  543.      strerror - Set Pointer to Runtime Error Message 
  544.      _strerror - Set Pointer to System Error String 
  545.  
  546.  
  547. ΓòÉΓòÉΓòÉ 2.2. Process Control Functions ΓòÉΓòÉΓòÉ
  548.  
  549.      _beginthread - Create New Thread 
  550.      _cwait - Wait for Child Process 
  551.      _disable - Disable Interrupts 
  552.      _enable - Enable Interrupts 
  553.      _endthread - Terminate Current Thread 
  554.      execl - _execvpe - Load and Run Child Process 
  555.      _exit - End Process 
  556.      _freemod - Free User DLL 
  557.      getpid - Get Process Identifier 
  558.      _getTIBvalue - Get Thread Information Block Value 
  559.      _interrupt - Call Interrupt  Procedure 
  560.      _loadmod - Load DLL 
  561.      _onexit - Record Termination Function 
  562.      putenv - Modify Environment Variables 
  563.      _searchenv - Search for File 
  564.      _spawnl - _spawnvpe - Start and Run Child Processes 
  565.      _threadstore - Access Thread-Specific Storage 
  566.  
  567.  
  568. ΓòÉΓòÉΓòÉ 2.3. File and Directory Management Functions ΓòÉΓòÉΓòÉ
  569.  
  570.      chdir - Change Current Working Directory 
  571.      _chdrive - Change Current Working Drive 
  572.      fstat - Information about Open File 
  573.      _fullpath - Get Full Path Name of Partial Path 
  574.      _getcwd - Get Path Name of Current Directory 
  575.      _getdcwd - Get Full Path Name of Current Directory 
  576.      _getdrive - Get Current Working Drive 
  577.      _makepath - Create Path 
  578.      mkdir - Create New Directory 
  579.      rmdir - Remove Directory 
  580.      _splitpath - Decompose Path Name 
  581.      stat - Get Information about File or Directory 
  582.  
  583.  
  584. ΓòÉΓòÉΓòÉ 2.4. Searching and Sorting Functions ΓòÉΓòÉΓòÉ
  585.  
  586.      bsearch - Search Arrays 
  587.      lfind - lsearch - Find Key in Array 
  588.      lfind - lsearch - Find Key in Array 
  589.      qsort - Sort Array 
  590.  
  591.  
  592. ΓòÉΓòÉΓòÉ 2.5. Regular Expression Functions ΓòÉΓòÉΓòÉ
  593.  
  594.      regcomp - Compile Regular Expression 
  595.      regerror - Return Error Message for Regular Expression 
  596.      regexec - Execute Compiled Regular Expression 
  597.      regfree - Free Memory for Regular Expression 
  598.  
  599.  
  600. ΓòÉΓòÉΓòÉ 2.6. Mathematical Functions ΓòÉΓòÉΓòÉ
  601.  
  602.      abs - Calculate Integer Absolute Value 
  603.      _cabs - Calculate Absolute Value of Complex Number 
  604.      ceil - Find Integer >= Argument 
  605.      div  - Calculate Quotient and Remainder 
  606.      erf - erfc - Calculate Error Functions 
  607.      exp - Calculate Exponential Function 
  608.      fabs - Calculate Floating-Point Absolute Value 
  609.      floor - Integer <= Argument 
  610.      fmod - Calculate Floating-Point Remainder 
  611.      frexp - Separate Floating-Point Value 
  612.      _fsqrt -  Calculate Square Root 
  613.      _fyl2x - Calculate y * log2(x) 
  614.      _fyl2xp1 -  Calculate y * log2(x + 1) 
  615.      _f2xm1 -  Calculate (2**x) - 1 
  616.      gamma - Gamma Function 
  617.      hypot - Calculate Hypotenuse 
  618.      labs - Calculate Absolute Value of Long Integer 
  619.      ldexp - Multiply by a Power of Two 
  620.      ldiv - Perform Long Division 
  621.      log - Calculate Natural Logarithm 
  622.      log10 - Calculate Base 10 Logarithm 
  623.      max - Return Larger of Two Values 
  624.      min - Return Lesser of Two Values 
  625.      modf - Separate Floating-Point Value 
  626.      pow - Compute Power 
  627.      sqrt - Calculate Square Root 
  628.      Bessel Functions - Solve Differential Equations 
  629.  
  630.  Trigonometric Functions 
  631.  
  632.      acos - Calculate Arccosine 
  633.      asin - Calculate Arcsine 
  634.      atan - atan2 - Calculate Arctangent 
  635.      cos - Calculate Cosine 
  636.      cosh - Calculate Hyperbolic Cosine 
  637.      _facos - Calculate Arccosine 
  638.      _fasin - Calculate Arcsine 
  639.      _fcos - Calculate Cosine 
  640.      _fcossin - Calculate Cosine and Sine 
  641.      _fpatan - Calculate Arctangent 
  642.      _fptan - Calculate Tangent 
  643.      _fsin - Calculate Sine 
  644.      _fsincos - Calculate Sine and Cosine 
  645.      sin - Calculate Sine 
  646.      sinh - Calculate Hyperbolic Sine 
  647.      tan - Calculate Tangent 
  648.      tanh - Calculate Hyperbolic Tangent 
  649.  
  650.  Bit Rotation 
  651.  
  652.      _crotl - _crotr - Rotate Bits of Character Value 
  653.      _lrotl - _lrotr - Rotate Bits of Unsigned Long Value 
  654.      _rotl - _rotr - Rotate Bits of Unsigned Integer 
  655.      _srotl - _srotr - Rotate Bits of Unsigned Short Value 
  656.  
  657.  
  658. ΓòÉΓòÉΓòÉ 2.7. Fast RAM Semaphore Functions ΓòÉΓòÉΓòÉ
  659.  
  660.      __cxchg - Exchange Character Value with Memory 
  661.      __lxchg - Exchange Integer Value with Memory 
  662.      __sxchg - Exchange Integer Value with Memory 
  663.  
  664.  
  665. ΓòÉΓòÉΓòÉ 2.8. Floating-Point Unit Control Functions ΓòÉΓòÉΓòÉ
  666.  
  667.      _clear87 - Clear Floating-Point Status Word 
  668.      _control87 - Set Floating-Point Control Word 
  669.      _fpreset - Reset Floating-Point Unit 
  670.      _status87 - Get Floating-Point Status Word 
  671.  
  672.  
  673. ΓòÉΓòÉΓòÉ 2.9. Date, Time, and Monetary Manipulation Functions ΓòÉΓòÉΓòÉ
  674.  
  675.      asctime - Convert Time to Character String 
  676.      clock  - Determine Processor Time 
  677.      ctime - Convert Time to Character String 
  678.      difftime - Compute Time Difference 
  679.      _ftime - Store Current Time 
  680.      gmtime - Convert Time 
  681.      localtime - Convert Time 
  682.      mktime - Convert Local Time 
  683.      _strdate - Copy Current Date 
  684.      strfmon - Convert Monetary Value to String 
  685.      strftime - Convert to Formatted Time 
  686.      strptime - Convert to Formatted Date and Time 
  687.      _strtime - Copy Time 
  688.      time - Determine Current Time 
  689.      tzset - Assign Values to Locale Information 
  690.      utime - Set Modification Time 
  691.      wcsftime - Convert to Formatted Date and Time 
  692.  
  693.  
  694. ΓòÉΓòÉΓòÉ 2.10. Type Conversion Functions ΓòÉΓòÉΓòÉ
  695.  
  696.      atof - Convert Character String to Float 
  697.      atoi - Convert Character String to Integer 
  698.      atol - Convert Character String to Long Integer 
  699.      _atold - Convert Character String to Long Double 
  700.      _ecvt - Convert Floating-Point to Character 
  701.      _fcvt - Convert Floating-Point to String 
  702.      _gcvt - Convert Floating-Point to String 
  703.      _itoa - Convert Integer to String 
  704.      _ltoa - Convert Long Integer to String 
  705.      strtod - Convert Character String to Double 
  706.      strtol - Convert Character String to Long Integer 
  707.      strtold - Convert String to Long Double 
  708.      strtoul - Convert String Segment to Unsigned Integer 
  709.      _ultoa - Convert Unsigned Long Integer to String 
  710.      wcstod - Convert Wide-Character String to Double 
  711.      wcstol - Convert Wide-Character to Long Integer 
  712.      wcstoul - Convert Wide-Character String to Unsigned Long 
  713.      wctob - Convert Wide Character to Byte 
  714.  
  715.  Multibyte and Wide-Character Type Conversion 
  716.  
  717.      mbrtowc - Convert Multibyte Character to Wide Character 
  718.      mbsrtowcs - Convert Multibyte String to Wide-Character String 
  719.      mbstowcs - Convert Multibyte String to Wide-Character String 
  720.      mbtowc - Convert Multibyte Character to Wide Character 
  721.      wcrtomb - Convert Wide Character to Multibyte Character 
  722.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  723.      wcstombs - Convert Wide-Character String to Multibyte String 
  724.      wctomb -  Convert Wide Character to Multibyte Character 
  725.  
  726.  
  727. ΓòÉΓòÉΓòÉ 2.11. Stream Input/Output Functions ΓòÉΓòÉΓòÉ
  728.  
  729. Formatted Input/Output 
  730.  
  731.      fprintf - Write Formatted Data to a Stream 
  732.      fscanf - Read Formatted Data 
  733.      printf - Print Formatted Characters 
  734.      scanf - Read Data 
  735.      sprintf - Print Formatted Data to Buffer 
  736.      sscanf - Read Data 
  737.      swprintf - Format and Write Wide Characters to Buffer 
  738.      swscanf - Read Wide Characters from Buffer 
  739.      vfprintf - Print Argument Data to Stream 
  740.      vprintf - Print Argument Data 
  741.      vsprintf - Print Argument Data to Buffer 
  742.      vswprintf - Format and Write Wide Characters to Buffer 
  743.  
  744.  Character and String Input/Output 
  745.  
  746.      fgetc - Read a Character 
  747.      _fgetchar - Read Single Character from stdin 
  748.      fgets - Read a String 
  749.      fputc - Write Character 
  750.      _fputchar - Write Character 
  751.      fputs - Write String 
  752.      getc - getchar - Read a Character 
  753.      gets - Read a Line 
  754.      putc - putchar - Write a Character 
  755.      puts - Write a String 
  756.      ungetc - Push Character onto Input Stream 
  757.  
  758.  Wide Character and String Input/Output 
  759.  
  760.      fgetwc - Read Wide Character from Stream 
  761.      fgetwc - Read Wide Character from Stream 
  762.      fputwc - Write Wide Character 
  763.      fputws - Write Wide-Character String 
  764.      getwc - Read Wide Character from Stream 
  765.      getwchar - Get Wide Character from stdin 
  766.      putwc - Write Wide Character 
  767.      putwchar - Write Wide Character to stdout 
  768.      ungetwc - Push Wide Character onto Input Stream 
  769.  
  770.  Direct Input/Output 
  771.  
  772.      clearerr - Reset Error Indicators. 
  773.      feof - Test End-of-File Indicator 
  774.      ferror - Test for Read/Write Errors 
  775.      fread - Read Items 
  776.      fwrite - Write Items 
  777.  
  778.  File Positioning 
  779.  
  780.      fgetpos - Get File Position 
  781.      fseek - Reposition File Position 
  782.      fsetpos - Set File Position 
  783.      ftell - Get Current Position 
  784.      lseek - Move File Pointer 
  785.      rewind - Adjust Current File Position 
  786.  
  787.  File Access 
  788.  
  789.      fclose - Close Stream 
  790.      _fcloseall - Close All Open Streams 
  791.      fdopen - Associates Input Or Output With File 
  792.      fflush - Write Buffer to File 
  793.      _flushall - Write Buffers to Files 
  794.      fopen - Open Files 
  795.      freopen - Redirect Open Files 
  796.      setbuf - Control Buffering 
  797.      _setmode - Set File Translation Mode 
  798.      setvbuf - Control Buffering 
  799.  
  800.  File Operations 
  801.  
  802.      fileno - Determine File Handle 
  803.      remove - Delete File 
  804.      rename - Rename File 
  805.      _rmtmp - Remove Temporary Files 
  806.      tempnam - Produce Temporary File Name 
  807.      tmpfile - Create Temporary File 
  808.      tmpnam - Produce Temporary File Name 
  809.      unlink - Delete File 
  810.  
  811.  
  812. ΓòÉΓòÉΓòÉ 2.12. Low-Level Input/Output Functions ΓòÉΓòÉΓòÉ
  813.  
  814. Port Input/Output 
  815.  
  816.      _inp - Read Byte from Input Port 
  817.      _inpd - Read Doubleword from Input Port 
  818.      _inpw - Read Unsigned Short from Input Port 
  819.      _outp - Write Byte to Output Port 
  820.      _outpd - Write Double Word to Output Port 
  821.      _outpw - Write Word to Output Port 
  822.      umask - Sets File Mask of Current Process 
  823.  
  824.  Character and String Input/Output 
  825.  
  826.      _cgets - Read String of Characters from Keyboard 
  827.      _cprintf - Print Characters to Screen 
  828.      _cputs - Write String to Screen 
  829.      _cscanf - Read Data from Keyboard 
  830.      _getch - _getche - Read Character from Keyboard 
  831.      _kbhit - Test for Keystroke 
  832.      _putch - Write Character to Screen 
  833.      _ungetch - Push Character Back to Keyboard 
  834.  
  835.  Direct Input/Output 
  836.  
  837.      read - Read Into Buffer 
  838.      write - Writes from Buffer to File 
  839.  
  840.  File Positioning 
  841.  
  842.      __eof - Determine End of File 
  843.      _tell - Get Pointer Position 
  844.  
  845.  File Access 
  846.  
  847.      access - Determine Access Mode 
  848.      chmod - Change File Permission Setting 
  849.      close - Close File Associated with Handle 
  850.      creat - Create New File 
  851.      dup - Associate Second Handle with Open File 
  852.      dup2 - Associate Second Handle with Open File 
  853.      isatty - Test Handle for Character Device 
  854.      open - Open File 
  855.      _sopen - Open Shared File 
  856.  
  857.  File Operations 
  858.  
  859.      _chsize - Alter Length of File 
  860.      _filelength - Determine File Length 
  861.  
  862.  
  863. ΓòÉΓòÉΓòÉ 2.13. Functions for Handling Argument Lists ΓòÉΓòÉΓòÉ
  864.  
  865.      va_arg - va_end - va_start - Access Function Arguments 
  866.      vfprintf - Print Argument Data to Stream 
  867.      vprintf - Print Argument Data 
  868.      vsprintf - Print Argument Data to Buffer 
  869.      vswprintf - Format and Write Wide Characters to Buffer 
  870.  
  871.  
  872. ΓòÉΓòÉΓòÉ 2.14. Pseudorandom Number Functions ΓòÉΓòÉΓòÉ
  873.  
  874.      rand - Generate Random Number 
  875.      srand - Set Seed for rand Function 
  876.  
  877.  
  878. ΓòÉΓòÉΓòÉ 2.15. Dynamic Memory Management Functions ΓòÉΓòÉΓòÉ
  879.  
  880. Allocating and Freeing Memory 
  881.  
  882.      _alloca - Temporarily Reserve Storage Block 
  883.      calloc - Reserve and Initialize Storage 
  884.      _debug_calloc - Allocate and Initialize Memory 
  885.      _debug_free - Release Memory 
  886.      _debug_heapmin - Release Unused Memory in the Default Heap 
  887.      _debug_malloc - Allocate Memory 
  888.      _debug_realloc - Reallocate Memory Block 
  889.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  890.      _debug_tfree - Release Tiled Memory 
  891.      _debug_theapmin - Release Unused Tiled Memory 
  892.      _debug_tmalloc - Reserve Tiled Memory 
  893.      _debug_trealloc - Reallocate Tiled Memory Block 
  894.      _debug_ucalloc - Reserve and Initialize Memory from User Heap 
  895.      _debug_uheapmin - Release Unused Memory in User Heap 
  896.      _debug_umalloc - Reserve Memory Blocks from User Heap 
  897.      free - Release Storage Blocks 
  898.      _heapmin - Release Unused Memory from Default Heap 
  899.      malloc - Reserve Storage Block 
  900.      realloc - Change Reserved Storage Block Size 
  901.      _tcalloc - Reserve Tiled Storage Block 
  902.      _tfree - Free Tiled Storage Block 
  903.      _theapmin - Release Unused Tiled Memory 
  904.      _tmalloc - Reserve Tiled Storage Block 
  905.      _trealloc - Reallocate Tiled Storage Block 
  906.  
  907.  Heap Information and Checking 
  908.  
  909.      _dump_allocated - Get Information about Allocated Memory 
  910.      _dump_allocated_delta - Get Information about Allocated Memory 
  911.      _heap_check - Validate Default Memory Heap 
  912.      _heapchk - Validate Default Memory Heap 
  913.      _heapset - Validate and Set Default Heap 
  914.      _heap_walk - Return Information about Default Heap 
  915.      _mheap - Query Memory Heap for Allocated Object 
  916.      _msize - Return Number of Bytes Allocated 
  917.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  918.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  919.      _theap_check - Validate User Memory Heap 
  920.      _udump_allocated - Get Information about Allocated Memory in Heap 
  921.      _udump_allocated_delta - Get Information about Allocated Memory in Heap 
  922.      _uheap_check - Validate User Memory Heap 
  923.      _uheapchk - Validate Memory Heap 
  924.      _uheapset - Validate and Set Memory Heap 
  925.      _uheap_walk - Return Information about Memory Heap 
  926.      _ustats - Get Information about Heap 
  927.  
  928.  Heap Creation and Management 
  929.  
  930.      _uaddmem - Add Memory to a Heap 
  931.      _uclose - Close Heap from Use 
  932.      _ucreate - Create a Memory Heap 
  933.      _udefault - Change the Default Heap 
  934.      _udestroy - Destroy a Heap 
  935.      _uopen - Open Heap for Use 
  936.  
  937.  
  938. ΓòÉΓòÉΓòÉ 2.16. Memory Object Functions ΓòÉΓòÉΓòÉ
  939.  
  940.      memccpy - Copy Bytes 
  941.      memchr - Search Buffer 
  942.      memcmp - Compare Buffers 
  943.      memcpy - Copy Bytes 
  944.      memicmp - Compare Bytes 
  945.      memmove - Copy Bytes 
  946.      memset - Set Bytes to Value 
  947.      swab - Swap Adjacent Bytes 
  948.  
  949.  
  950. ΓòÉΓòÉΓòÉ 2.17. Environment and Locale Interaction Functions ΓòÉΓòÉΓòÉ
  951.  
  952.      abort - Stop a Program 
  953.      exit - End Program 
  954.      getenv - Search for Environment Variables 
  955.      longjmp - Restore Stack Environment 
  956.      __parmdwords - Get Number of dwords in Parameter List 
  957.      setjmp - Preserve Environment 
  958.      system - Invoke the Command Processor 
  959.  
  960.  Setting and Querying Locale 
  961.  
  962.      csid - Determine Character Set ID for Multibyte Character 
  963.      getsyntx - Return LC_SYNTAX Characters 
  964.      iconv - Convert Characters to New Code Set 
  965.      iconv_close - Remove Conversion Descriptor 
  966.      iconv_open - Create Conversion Descriptor 
  967.      localdtconv - Return Date and Time Formatting Convention 
  968.      localeconv - Retrieve Information from the Environment 
  969.      nl_langinfo - Retrieve Locale Information 
  970.      setlocale - Set Locale 
  971.      wcsid - Determine Character Set ID for Wide Character 
  972.      wctype - Get Handle for Character Property Classification 
  973.  
  974.  String and Character Collating 
  975.  
  976.      cclass - Return Characters in Character Class 
  977.      collequiv - Return List of Equivalent Collating Elements 
  978.      collorder - Return List of Collating Elements 
  979.      collrange - Calculate Range of Collating Elements 
  980.      colltostr - Return String for Collating Element 
  981.      getmccoll - Get Next Collating Element from String 
  982.      getwmccoll - Get Next Collating Element from Wide String 
  983.      ismccollel - Identify Multi-Character Collating Element 
  984.      maxcoll - Return Maximum Collating Element 
  985.      strcoll - Compare Strings Using Collation Rules 
  986.      strtocoll - Return Collating Element for String 
  987.      wcscoll - Compare Wide-Character Strings 
  988.  
  989.  
  990. ΓòÉΓòÉΓòÉ 2.18. String Operation Functions ΓòÉΓòÉΓòÉ
  991.  
  992.      strcat - Concatenate Strings 
  993.      strchr - Search for Character 
  994.      strcmp - Compare Strings 
  995.      strcmpi - Compare Strings Without Case Sensitivity 
  996.      strcoll - Compare Strings Using Collation Rules 
  997.      strcpy - Copy Strings 
  998.      strcspn - Compare Strings for Substrings 
  999.      strdup - Duplicate String 
  1000.      stricmp - Compare Strings as Lowercase 
  1001.      strlen - Determine String Length 
  1002.      strncat - Concatenate Strings 
  1003.      strncmp - Compare Strings 
  1004.      strncpy - Copy Strings 
  1005.      strnicmp - Compare Strings Without Case Sensitivity 
  1006.      strnset - strset - Set Characters in String 
  1007.      strpbrk - Find Characters in String 
  1008.      strrchr - Find Last Occurrence of Character in String 
  1009.      strrev - Reverse String 
  1010.      strnset - strset - Set Characters in String 
  1011.      strspn - Search Strings 
  1012.      strstr - Locate Substring 
  1013.      strtok - Tokenize String 
  1014.      strxfrm - Transform String 
  1015.  
  1016.  
  1017. ΓòÉΓòÉΓòÉ 2.19. Character Testing Functions ΓòÉΓòÉΓòÉ
  1018.  
  1019.      isalnum to isxdigit - Test Integer Value 
  1020.      isascii - Test Integer Values 
  1021.      isblank - Test for Blank Character Classification 
  1022.      _iscsym - _iscsymf - Test Integer 
  1023.      _iscsym - _iscsymf - Test Integer 
  1024.      iswalnum to iswxdigit - Test Wide Integer Value 
  1025.      iswblank - Test for Wide Blank Character Classification 
  1026.      iswctype - Test for Character Property 
  1027.      wcwidth - Determine Display Width of Wide Character 
  1028.  
  1029.  
  1030. ΓòÉΓòÉΓòÉ 2.20. Case Mapping Functions ΓòÉΓòÉΓòÉ
  1031.  
  1032.      strlwr - Convert Uppercase to Lowercase 
  1033.      strupr - Convert Lowercase to Uppercase 
  1034.      tolower() - toupper() - Convert Character Case 
  1035.      tolower() - toupper() - Convert Character Case 
  1036.      _toascii - _tolower - _toupper - Convert Character 
  1037.      towlower - towupper - Convert Wide Character Case 
  1038.  
  1039.  
  1040. ΓòÉΓòÉΓòÉ 2.21. Wide Character String Operation Functions ΓòÉΓòÉΓòÉ
  1041.  
  1042.      mblen - Determine Length of Multibyte Character 
  1043.      wcscat - Concatenate Wide-Character Strings 
  1044.      wcschr - Search for Wide Character 
  1045.      wcscmp - Compare Wide-Character Strings 
  1046.      wcscoll - Compare Wide-Character Strings 
  1047.      wcscpy - Copy Wide-Character Strings 
  1048.      wcscspn - Find Offset of First Wide-Character Match 
  1049.      wcslen - Calculate Length of Wide-Character String 
  1050.      wcsncat - Concatenate Wide-Character Strings 
  1051.      wcsncmp - Compare Wide-Character Strings 
  1052.      wcsncpy - Copy Wide-Character Strings 
  1053.      wcspbrk - Locate Wide Characters in String 
  1054.      wcsspn - Search Wide-Character Strings 
  1055.      wcsrchr - Locate Wide Character in String 
  1056.      wcsstr - Locate Wide-Character Substring 
  1057.      wcstok - Tokenize Wide-Character String 
  1058.      wcswcs - Locate Wide-Character Substring 
  1059.      wcswidth - Determine Display Width of Wide-Character String 
  1060.      wcsxfrm - Transform Wide-Character String 
  1061.  
  1062.  
  1063. ΓòÉΓòÉΓòÉ 3. Additional VisualAge C++ Library Features ΓòÉΓòÉΓòÉ
  1064.  
  1065. Many of the functions in the VisualAge C++ runtime library are extensions to 
  1066. the ANSI standard.  This section describes some of the additional support the 
  1067. VisualAge C++ library provides and the behavior of certain features. 
  1068.  
  1069.      Intrinsic Functions 
  1070.      Differentiating between the Memory Management Functions 
  1071.      Infinity and NaN Support 
  1072.      Using Low-Level I/O Functions 
  1073.  
  1074.  
  1075. ΓòÉΓòÉΓòÉ 3.1. Intrinsic Functions ΓòÉΓòÉΓòÉ
  1076.  
  1077. The VisualAge C++ compiler inlines some functions instead of generating a 
  1078. function call for them. Some of these functions are always inlined; others are 
  1079. inlined only when you compile with the optimization option (/O or /Oc) on. 
  1080.  
  1081.      Functions that Are Inlined when Optimization Is On 
  1082.      Functions that Are Always Inlined 
  1083.  
  1084.  
  1085. ΓòÉΓòÉΓòÉ 3.1.1. Functions that Are Inlined when Optimization Is On ΓòÉΓòÉΓòÉ
  1086.  
  1087. When optimization is on (/O+), VisualAge C++ compiler by default inlines 
  1088. (generates code instead of a function call) the following C library functions: 
  1089.  
  1090.  abs                 _clear87 
  1091.  _control87          fabs 
  1092.  labs                memchr 
  1093.  memcmp              memcpy 
  1094.  memmove             memset 
  1095.  _status87           strcat 
  1096.  strchr              strcmp 
  1097.  strcpy              strlen 
  1098.  strncat             strncmp 
  1099.  strncpy             strrchr 
  1100.  
  1101.  The compiler inlines these functions when you include the appropriate header 
  1102.  file that contains the function prototype and the #define and #pragma 
  1103.  statements for the function. 
  1104.  
  1105.  You can override the inlining either by undefining the macro or by placing the 
  1106.  name of the function in parentheses, thus disabling the processor 
  1107.  substitution. The function then remains a function call, and is not replaced 
  1108.  by the code. The size of your object module is reduced, but your application 
  1109.  program runs more slowly. 
  1110.  
  1111.  Note:  The optimize-for-size compiler option (/Oc) also disables the inlining 
  1112.  of intrinsic functions. 
  1113.  
  1114.  
  1115. ΓòÉΓòÉΓòÉ 3.1.2. Functions that Are Always Inlined ΓòÉΓòÉΓòÉ
  1116.  
  1117. The following functions are built-in functions, meaning they do not have any 
  1118. backing library functions, and are always inlined: 
  1119.  
  1120.  _alloca             _crotl 
  1121.  _crotr              __cxchg 
  1122.  _disable            _enable 
  1123.  _facos              _fasin 
  1124.  _fcos               _fcossin 
  1125.  _fpatan             _fptan 
  1126.  _fsin               _fsincos 
  1127.  _fsqrt              _fyl2x 
  1128.  _fyl2xp1            _f2xm1 
  1129.  _getTIBvalue        _inp 
  1130.  _inpd               _inpw 
  1131.  _interrupt          _lrotl 
  1132.  _lrotr              __lxchg 
  1133.  _outp               _outpd 
  1134.  _outpw              __parmdwords 
  1135.  _rotl               _rotr 
  1136.  _srotl              _srotr 
  1137.  __sxchg 
  1138.  
  1139.  Do not parenthesize the names of these functions. 
  1140.  
  1141.  The built-in functions are all defined in <builtin.h>, in addition to the 
  1142.  standard header definitions. 
  1143.  
  1144.  
  1145. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1146.  
  1147.      Functions that Are Inlined when Optimization Is On 
  1148.      Functions that Are Always Inlined 
  1149.      #include in the Language Reference 
  1150.      #define in the Language Reference 
  1151.      #pragma in the Language Reference 
  1152.      /O option in the User's Guide 
  1153.      <builtin.h> 
  1154.  
  1155.  
  1156. ΓòÉΓòÉΓòÉ 3.2. Differentiating between Memory Management Functions ΓòÉΓòÉΓòÉ
  1157.  
  1158. The memory management functions defined by ANSI are calloc, malloc, realloc, 
  1159. and free. These regular functions allocate and free memory from the default 
  1160. runtime heap. (VisualAge C++ has added another function, _heapmin, to return 
  1161. unused memory to the system.) VisualAge C++ also provides different versions of 
  1162. each of these functions as extensions to the ANSI definition. 
  1163.  
  1164. All the versions actually work the same way; they differ only in what heap they 
  1165. allocate from, and in whether they save information to help you debug memory 
  1166. problems. The memory allocated by all of these functions is suitably aligned 
  1167. for storing any type of object. 
  1168.  
  1169. The following table summarizes the different versions of memory management 
  1170. functions, using malloc as an example of how the names of the functions change 
  1171. for each version. They are all described in greater detail in this section. 
  1172.  
  1173. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1174. Γöé             Γöé REGULAR VERSION      Γöé DEBUG VERSION      Γöé
  1175. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1176. Γöé DEFAULT HEAP       Γöé malloc          Γöé _debug_malloc      Γöé
  1177. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1178. Γöé USER HEAP        Γöé _umalloc         Γöé _debug_umalloc      Γöé
  1179. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1180. Γöé TILED HEAP ("/Gt")    Γöé _tmalloc         Γöé _debug_tmalloc      Γöé
  1181. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1182.  
  1183. To use these extensions, you must set the language level to extended, either 
  1184. with the /Se compiler option or the #pragma langlvl(extended) directive. 
  1185.  
  1186.  
  1187. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1188.  
  1189.      Differentiating between Memory Management Functions 
  1190.      Heap-Specific Functions 
  1191.      Tiled Functions 
  1192.      Debug Functions 
  1193.      Heap-Specific Debug Functions 
  1194.      Tiled Debug Functions 
  1195.      "Managing Memory" in the Programming Guide 
  1196.      "Debugging Your Heaps" in the Programming Guide 
  1197.  
  1198.  
  1199. ΓòÉΓòÉΓòÉ 3.2.1. Heap-Specific Functions ΓòÉΓòÉΓòÉ
  1200.  
  1201. Use the heap-specific versions to allocate and free memory from a user-created 
  1202. heap that you specify.  (You can also explicitly use the runtime heap if you 
  1203. want.)  Their names are prefixed by _u (for "user heaps"), for example, 
  1204. _umalloc, and they are defined in <umalloc.h>. 
  1205.  
  1206. The functions provided are: 
  1207.  
  1208.      _ucalloc 
  1209.      _umalloc 
  1210.      _uheapmin 
  1211.  
  1212.  Notice there is no heap-specific version of realloc or free. Because they both 
  1213.  always check what heap the memory was allocated from, you can always use the 
  1214.  regular versions regardless of what heap the memory came from. 
  1215.  
  1216.  For more information about creating your own heaps and using the heap-specific 
  1217.  memory management functions, see Managing Memory with Multiple Heaps in the 
  1218.  Programming Guide. 
  1219.  
  1220.  
  1221. ΓòÉΓòÉΓòÉ 3.2.2. Tiled Functions ΓòÉΓòÉΓòÉ
  1222.  
  1223. Use the tiled memory management functions to allocate and free memory from the 
  1224. runtime's tiled memory heap. If you have objects that can be accessed by 16-bit 
  1225. code, you should store them in tiled memory. Tiled memory does not cross 64K 
  1226. boundaries, as long as the object is smaller than 64K. Objects larger than 64K 
  1227. are aligned on 64K boundaries, but will also cross 64K boundaries. 
  1228.  
  1229. When you use the tiled memory compiler option, /Gt, all calls to the regular 
  1230. memory management functions are mapped to their tiled versions. You can also 
  1231. call the tiled versions explicitly. 
  1232.  
  1233. Note:  If you parenthesize the calls to the regular memory management 
  1234. functions, they are not mapped to their tiled versions. 
  1235.  
  1236. The names of the tiled versions are prefixed by _t (for "tiled"), for example, 
  1237. _tmalloc, and they are defined in <malloc.h> and <stdlib.h>. 
  1238.  
  1239. The functions provided are: 
  1240.  
  1241.      _tcalloc 
  1242.      _tfree 
  1243.      _theapmin 
  1244.      _tmalloc 
  1245.      _trealloc 
  1246.  
  1247.  You can also create your own heaps of tiled memory. Creating your own heaps is 
  1248.  described in Managing Memory Using Multiple Heaps in the Programming Guide. 
  1249.  
  1250.  For more information about sharing objects between 32-bit and 16-bit code, see 
  1251.  Calling Between 32-Bit and 16-Bit Code in the Programming Guide. 
  1252.  
  1253.  
  1254. ΓòÉΓòÉΓòÉ 3.2.3. Debug Functions ΓòÉΓòÉΓòÉ
  1255.  
  1256. Use these functions to allocate and free memory from the default runtime heap, 
  1257. just as you would use the regular versions. They also provide information that 
  1258. you can use to debug memory problems. 
  1259.  
  1260. Note:  The information provided by these functions is Diagnosis, Modification, 
  1261.        and Tuning information only.  It is not intended to be used as a 
  1262.        programming interface. 
  1263.  
  1264.  When you use the debug memory compiler option, /Tm, all calls to the regular 
  1265.  memory management functions are mapped to their debug versions. You can also 
  1266.  call the debug versions explicitly. 
  1267.  
  1268.  Note:  If you parenthesize the calls to the regular memory management 
  1269.  functions, they are not mapped to their debug versions. 
  1270.  
  1271.  We recommend you place a #pragma strings(readonly) directive at the top of 
  1272.  each source file that will call debug functions, or in a common header file 
  1273.  that each includes. This directive is not essential, but it ensures that the 
  1274.  file name passed to the debug functions can't be overwritten, and that only 
  1275.  one copy of the file name string is included in the object module. 
  1276.  
  1277.  The names of the debug versions are prefixed by _debug_, for example, 
  1278.  _debug_malloc, and they are defined in <malloc.h> and <stdlib.h>. 
  1279.  
  1280.  The functions provided are: 
  1281.  
  1282.      _debug_calloc 
  1283.      _debug_free 
  1284.      _debug_heapmin 
  1285.      _debug_malloc 
  1286.      _debug_realloc 
  1287.  
  1288.  In addition to their usual behavior, these functions also store information 
  1289.  (file name and line number) about each call made to them.  Each call also 
  1290.  automatically checks the heap by calling _heap_check (described below). 
  1291.  
  1292.  Three additional debug memory management functions do not have regular 
  1293.  counterparts: 
  1294.  
  1295.      _dump_allocated 
  1296.  
  1297.       Prints information to file handle 2 (the usual destination of stderr) 
  1298.       about each memory block currently allocated by the debug functions. You 
  1299.       can change the destination of the information with the 
  1300.       _set_crt_msg_handle function. 
  1301.  
  1302.      _dump_allocated_delta 
  1303.  
  1304.       Prints information to file handle 2 about each memory block allocated by 
  1305.       the debug functions since the last call to _dump_allocated or 
  1306.       _dump_allocated_delta. Again, you can change the destination of the 
  1307.       information with the _set_crt_msg_handle function. 
  1308.  
  1309.      _heap_check 
  1310.  
  1311.       Checks all memory blocks allocated or freed by the debug functions to 
  1312.       make sure that no overwriting has occurred outside the bounds of 
  1313.       allocated blocks or in a free memory block. 
  1314.  
  1315.  The debug functions call _heap_check automatically; you can also call it 
  1316.  explicitly. To use _dump_allocated and _dump_allocated_delta, you must call 
  1317.  them explicitly. 
  1318.  
  1319.  In C Set ++ releases prior to VisualAge C++ Version 3.0, you could not mix 
  1320.  debug and regular versions of the memory management functions. For example, 
  1321.  you could not allocate memory with malloc and free it with _debug_free. This 
  1322.  restriction no longer applies; realloc and free (debug or otherwise) can now 
  1323.  handle memory allocated by any other allocation function. 
  1324.  
  1325.  
  1326. ΓòÉΓòÉΓòÉ 3.2.4. Heap-Specific Debug Functions ΓòÉΓòÉΓòÉ
  1327.  
  1328. The heap-specific functions also have debug versions that work just like the 
  1329. regular debug versions.  Use these functions to allocate and free memory from 
  1330. the user-created heap you specify, and also provide information that you can 
  1331. use to debug memory problems in your own heaps. 
  1332.  
  1333. Note:  The information provided by these functions is Diagnosis, Modification, 
  1334.        and Tuning information only.  It is not intended to be used as a 
  1335.        programming interface. 
  1336.  
  1337.  You can call them explicitly, or you can use the debug memory compiler option, 
  1338.  /Tm, to map calls to the heap-specific functions to their debug counterparts. 
  1339.  
  1340.  Note:  If you parenthesize the calls to the heap-specific memory management 
  1341.  functions, they are not mapped to their debug versions. 
  1342.  
  1343.  The names of the heap-specific debug versions are prefixed by _debug_u, for 
  1344.  example, _debug_umalloc, and they are defined in <umalloc.h>. 
  1345.  
  1346.  The functions provided are: 
  1347.  
  1348.      _debug_ucalloc 
  1349.      _debug_uheapmin 
  1350.      _debug_umalloc 
  1351.      _udump_allocated 
  1352.      _udump_allocated_delta 
  1353.      _uheap_check 
  1354.  
  1355.  Notice there is no heap-specific debug version of realloc or free. Because 
  1356.  they both always check what heap the memory was allocated from, you always use 
  1357.  the regular debug versions (_debug_realloc and _debug_free), regardless of 
  1358.  what heap the memory came from. 
  1359.  
  1360.  For more information about debugging memory problems in your own heaps, see 
  1361.  "Debugging Your Heaps" in the Programming Guide. 
  1362.  
  1363.  
  1364. ΓòÉΓòÉΓòÉ 3.2.5. Tiled Debug Functions ΓòÉΓòÉΓòÉ
  1365.  
  1366. The tiled functions also have debug versions that work just like the regular 
  1367. and heap-specific debug versions. Use these functions to allocate and free 
  1368. memory from the tiled VisualAge C++ runtime heap.  They also provide 
  1369. information that you can use to debug memory problems with the tiled heap. 
  1370.  
  1371. Note:  The information provided by these functions is Diagnosis, Modification, 
  1372.        and Tuning information only.  It is not intended to be used as a 
  1373.        programming interface. 
  1374.  
  1375.  You can call them explicitly, or you can use the debug memory and tiled memory 
  1376.  compiler options /Tm and /Gt, to map calls to the regular memory management 
  1377.  functions to their tiled debug counterparts. 
  1378.  
  1379.  Note:  If you parenthesize the calls to the heap-specific memory management 
  1380.  functions, they are not mapped to their debug versions. 
  1381.  
  1382.  The names of the tiled debug versions are prefixed by _debug_t, for example, 
  1383.  _debug_tmalloc, and they are defined in <malloc.h> and <stdlib.h>. 
  1384.  
  1385.  The functions provided are: 
  1386.  
  1387.      _debug_tcalloc 
  1388.      _debug_tfree 
  1389.      _debug_theapmin 
  1390.      _debug_tmalloc 
  1391.      _debug_trealloc 
  1392.      _tdump_allocated 
  1393.      _tdump_allocated_delta 
  1394.      _theap_check 
  1395.  
  1396.  For more information about debugging memory problems, see "Debugging Your 
  1397.  Heaps" in the Programming Guide. 
  1398.  
  1399.  
  1400. ΓòÉΓòÉΓòÉ 3.3. Infinity and NaN Support ΓòÉΓòÉΓòÉ
  1401.  
  1402. VisualAge C++ compiler supports the use of infinity and NaN (not-a-number) 
  1403. values. Infinity is a value with an associated sign that is mathematically 
  1404. greater in magnitude than any binary floating-point number. A NaN is a value in 
  1405. floating-point computations that is not interpreted as a mathematical value, 
  1406. and that contains a mask state and a sequence of binary digits. 
  1407.  
  1408. The value of infinity can be computed from 1.0 / 0.0. The value of a NaN can be 
  1409. computed from 0.0 / 0.0. 
  1410.  
  1411. Depending on its bit pattern, a NaN can be either quiet (NaNQ) or signalling 
  1412. (NaNS), as defined in the ANSI/IEEE Standard for Binary Floating-Point 
  1413. Arithmetic (754-1982). A NaNQ is masked and never generates exceptions. A NaNS 
  1414. may be masked and may generate an exception, but does not necessarily do so. 
  1415. VisualAge C++ compiler supports only quiet NaN values; all NaN values discussed 
  1416. below refer to quiet NaNs. 
  1417.  
  1418. NaN and infinity values are defined as macro constants in the <float.h> header 
  1419. file. The macros are: 
  1420.  
  1421.  Macro                Description 
  1422.  _INFINITYF           Infinity of type float 
  1423.  _INFINITY            Infinity of type double 
  1424.  _INFINITYL           Infinity of type long double 
  1425.  
  1426.  _INFF                Same as _INFINITYF 
  1427.  _INF                 Same as _INFINITY 
  1428.  _INFL                Same as _INFINITYL 
  1429.  
  1430.  _NANF                Quiet NaN of type float 
  1431.  _NAN                 Quiet NaN of type double 
  1432.  _NANL                Quiet NaN of type long double. 
  1433.  
  1434.  You can get the corresponding negative values by using the unary minus 
  1435.  operator (for example, -_INF). 
  1436.  
  1437.  Note:  The value of 0.0 can also be positive or negative. For example, 1.0 / 
  1438.  (-0.0) results in -_INF. 
  1439.  
  1440.  Because these macros are actually references to constant variables, you cannot 
  1441.  use them to initialize static variables. For example, the following statements 
  1442.  are not allowed: 
  1443.  
  1444.      static double infval = _INF;
  1445.      static float nanval = 1.0 + _NANF;
  1446.  
  1447.  However, you can initialize static variables to the numeric values of infinity 
  1448.  and NaN: 
  1449.  
  1450.      static double infval = 1.0 / 0.0;
  1451.      static float nanval =  0.0 / 0.0;
  1452.  
  1453.  Note:  Although positive and negative infinities are specific bit patterns, 
  1454.         NaNs are not. A NaN value is not equal to itself or to any other value. 
  1455.         For example, if you assign a NaN value to a variable x, you cannot 
  1456.         check the value of x with the statement if (_NAN == x). Instead, use 
  1457.         the statement if (x != x). 
  1458.  
  1459.  All relational and equality expressions involving NaN values always evaluate 
  1460.  to FALSE or zero (0), with the exception of not equal (!=), which always 
  1461.  evaluates to TRUE or one (1). 
  1462.  
  1463.  For information on the bit mapping and storage mapping of NaN and infinity 
  1464.  values, see the User's Guide. 
  1465.  
  1466.  
  1467. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1468.  
  1469.      Infinity and NaN in Library Functions 
  1470.      Assignment Expression 
  1471.      Equality 
  1472.      Relational 
  1473.      <float.h> 
  1474.  
  1475.  
  1476. ΓòÉΓòÉΓòÉ 3.3.1. Infinity and NaN in Library Functions ΓòÉΓòÉΓòÉ
  1477.  
  1478. When the language level is set to extended (using the /Se option or the #pragma 
  1479. langlvl(extended) directive), which is the default, infinity and NaN values can 
  1480. be passed as arguments to the scanf and printf families of library functions, 
  1481. and to the string conversion and math functions. At other language levels, 
  1482. these functions work as described in this reference. 
  1483.  
  1484. The following sections describe how the library functions handle the infinity 
  1485. and NaN values: 
  1486.  
  1487.      scanf Family 
  1488.      printf Family 
  1489.      String Conversion Functions 
  1490.      Math Functions 
  1491.  
  1492.  
  1493. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1494.  
  1495.      Infinity and NaN Support 
  1496.      scanf Family 
  1497.      printf Family 
  1498.      String Conversion Functions 
  1499.      Math Functions 
  1500.      #pragma langlvl 
  1501.      /Se option. 
  1502.  
  1503.  
  1504. ΓòÉΓòÉΓòÉ 3.3.1.1. scanf Family ΓòÉΓòÉΓòÉ
  1505.  
  1506. The scanf family of functions includes the functions scanf, fscanf, sscanf, and 
  1507. swscanf. When reading in floating-point numbers, these functions convert the 
  1508. strings INFINITY, INF, and NAN (in upper-, lower-, or mixed case) to the 
  1509. corresponding floating-point value. The sign of the value is determined by the 
  1510. format specification. 
  1511.  
  1512. Given a string that consists of NAN, INF, or INFINITY, followed by other 
  1513. characters, the scanf functions read in only the NaN or infinity value, and 
  1514. consider the rest of the string to be a second input field. For example, Nancy 
  1515. would be scanned as two fields, Nan and cy. 
  1516.  
  1517. Note:  In the case of a string that begins with INF, the functions check the 
  1518.        fourth letter. If that letter is not I (in upper- or lowercase), INF is 
  1519.        read and converted and the rest of the string is left for the next 
  1520.        format specification. If the fourth letter is I, the functions continue 
  1521.        to scan for the full INFINITY string. If the string is other than 
  1522.        INFINITY, the entire string is discarded. 
  1523.  
  1524.  
  1525. ΓòÉΓòÉΓòÉ <hidden> Example of fscanf with NaN and Infinity Values ΓòÉΓòÉΓòÉ
  1526.  
  1527. /************************************************************************
  1528. *
  1529.  
  1530. In the following example, fscanf converts NaN and infinity strings to their 
  1531. numeric values. 
  1532.  
  1533.                                                                         *
  1534. ************************************************************************/
  1535.  
  1536. #include <stdio.h>
  1537.  
  1538. int main(void)
  1539. {
  1540.    int n, count;
  1541.    double d1, d2, d3;
  1542.    FILE *stream;
  1543.  
  1544.    stream = tmpfile();
  1545.  
  1546.    fputs(" INFINITY NAn INF", stream);
  1547.  
  1548.    rewind(stream);
  1549.  
  1550.    n = fscanf(stream, "%lF%lf%lF%n", &d1, &d2, &d3, &count);
  1551.  
  1552.    if (n != EOF)
  1553.    {
  1554.       printf("Number of fields converted = %d\n", n);
  1555.       printf("Number of characters read = %d\n", count);
  1556.       printf("Output = %f %F %F\n", d1, d2, d3);
  1557.    }
  1558.  
  1559.    return 0;
  1560.  
  1561.    /* The expected output is:
  1562.  
  1563.       Number of fields converted = 3
  1564.       Number of characters read = 17
  1565.       Output = infinity NAN INFINITY  */
  1566.  
  1567. }
  1568.  
  1569.  
  1570. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1571.  
  1572. Example 
  1573.  
  1574.      Infinity and NaN Support 
  1575.      fscanf - Read Formatted Data 
  1576.      scanf - Read Data 
  1577.      sscanf - Read Data 
  1578.      swscanf - Read Wide Characters from Buffer 
  1579.  
  1580.  
  1581. ΓòÉΓòÉΓòÉ 3.3.1.2. printf Family ΓòÉΓòÉΓòÉ
  1582.  
  1583. The printf family of functions includes the functions printf, fprintf, sprintf, 
  1584. swprintf, vfprintf, vprintf, vsprintf, and vswprintf. These functions convert 
  1585. floating-point values of infinity and NaN to the strings "INFINITY" or 
  1586. "infinity" and "NAN" or "nan". 
  1587.  
  1588. The case is determined by the format specification, as is the sign (positive or 
  1589. negative). When converting these values, the printf functions ignore the 
  1590. precision width given by the format specification. 
  1591.  
  1592.  
  1593. ΓòÉΓòÉΓòÉ <hidden> Example of printf with Nan and Infinity Values ΓòÉΓòÉΓòÉ
  1594.  
  1595. /************************************************************************
  1596. *
  1597.  
  1598. In the following example, printf converts the NaN and infinity values and 
  1599. prints out the corresponding string. 
  1600.  
  1601.                                                                         *
  1602. ************************************************************************/
  1603.  
  1604. #include <stdio.h>
  1605. #include <float.h>
  1606.  
  1607. int main(void)
  1608. {
  1609.    double infval = -(_INF);
  1610.    float nanval = _NANF;
  1611.  
  1612.    printf("-_INF is the same as %-15.30f\n", infval);
  1613.    printf("_NANF is the same as %-15.30F\n", nanval);
  1614.  
  1615.    return 0;
  1616.  
  1617.    /* The expected output is:
  1618.  
  1619.       -_INF is the same as -infinity
  1620.       _NANF is the same as NAN        */
  1621.  
  1622. }
  1623.  
  1624.  
  1625. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1626.  
  1627. Example 
  1628.  
  1629.      Infinity and NaN Support 
  1630.      fprintf - Write Formatted Data to a Stream 
  1631.      printf - Print Formatted Characters 
  1632.      sprintf - Print Formatted Data to Buffer 
  1633.      swprintf - Format and Write Wide Characters to Buffer 
  1634.      vfprintf - Print Argument Data to Stream 
  1635.      vprintf - Print Argument Data 
  1636.      vsprintf - Print Argument Data to Buffer 
  1637.      vswprintf - Format and Write Wide Characters to Buffer 
  1638.  
  1639.  
  1640. ΓòÉΓòÉΓòÉ 3.3.1.3. String Conversion Functions ΓòÉΓòÉΓòÉ
  1641.  
  1642. The string conversion functions that support infinity and NaN representations 
  1643. include the functions atof, _atold, _ecvt, _fcvt, _gcvt, strtod, strtold, and 
  1644. wcstod. 
  1645.  
  1646. The atof, _atold, strtod, strtold, and wcstod functions accept the strings 
  1647. INFINITY, INF, and NAN (in upper-, lower-, or mixed case) as input, and convert 
  1648. these strings to the corresponding macro value defined in <float.h>. The _ecvt, 
  1649. _fcvt, and _gcvt functions convert infinity and NaN values to the strings 
  1650. INFINITY and NAN, respectively. 
  1651.  
  1652. Note:  If a signalling NaN string is passed to a string conversion function, a 
  1653. quiet NaN value is returned, and no signal is raised. 
  1654.  
  1655.  
  1656. ΓòÉΓòÉΓòÉ <hidden> Example of atof with NaN and Infinity Values ΓòÉΓòÉΓòÉ
  1657.  
  1658. /************************************************************************
  1659. *
  1660.  
  1661. The following example uses atof to convert the strings "naN" and "inf" to the 
  1662. corresponding macro value. 
  1663.  
  1664.                                                                         *
  1665. ************************************************************************/
  1666.  
  1667. #include <stdlib.h>
  1668. #include <stdio.h>
  1669.  
  1670. int main(void)
  1671. {
  1672.    char *nanstr;
  1673.    char *infstr;
  1674.  
  1675.    nanstr = "naN";
  1676.    printf( "Result of atof = %.10e\n", atof(nanstr) );
  1677.  
  1678.    infstr = "inf";
  1679.    printf( "Result of atof = %.10E\n", atof(infstr) );
  1680.  
  1681.    return 0;
  1682.  
  1683.    /* The expected output is:
  1684.  
  1685.       Result of atof = nan
  1686.       Result of atof = INFINITY  */
  1687.  
  1688. }
  1689.  
  1690.  
  1691. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1692.  
  1693. Example 
  1694.  
  1695.      Infinity and NaN Support 
  1696.      atof - Convert Character String to Float 
  1697.      _atold - Convert Character String to Long Double 
  1698.      _ecvt - Convert Floating-Point to Character 
  1699.      _fcvt - Convert Floating-Point to String 
  1700.      _gcvt - Convert Floating-Point to String 
  1701.      strtod - Convert Character String to Double 
  1702.      strtold - Convert String to Long Double 
  1703.  
  1704.  
  1705. ΓòÉΓòÉΓòÉ 3.3.1.4. Math Functions ΓòÉΓòÉΓòÉ
  1706.  
  1707. Most math functions accept infinity, negative infinity, and NaN values as 
  1708. input. (For information on those functions that do not accept these values, see 
  1709. Math Functions without Infinity and NaN Support.) In general, a NaN value as 
  1710. input results in a NaN value as output, and infinity values as input usually 
  1711. result in infinity values. If the input value is outside the domain or range of 
  1712. the function, errno is set to EDOM or ERANGE, respectively. 
  1713.  
  1714. The following tables display the results of each math function when NaN or 
  1715. infinity values are input, and the associated errno value if one exists. The 
  1716. first table lists the functions that take only one argument; the second lists 
  1717. those that take two arguments. 
  1718.  
  1719. Note:  In some cases, infinity is always a valid input value for the function 
  1720. regardless of the language level (for example, atan). These cases do not appear 
  1721. in these two tables. 
  1722.  
  1723. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1724. Γöé Table 1. NaN and Infinity Values in Math Functions              Γöé
  1725. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1726. Γöé FUNCTION      Γöé INPUT       Γöé RESULT       Γöé "ERRNO" VALUE   Γöé
  1727. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1728. Γöé "         Γöé NaN        Γöé NaN "       Γöé          Γöé
  1729. Γöé acos        Γöé infinity      Γöé 0         Γöé EDOM       Γöé
  1730. Γöé asin "       Γöé -infinity     Γöé 0 "        Γöé EDOM       Γöé
  1731. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1732. Γöé "atan"       Γöé NaN        Γöé NaN        Γöé          Γöé
  1733. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1734. Γöé "         Γöé NaN        Γöé NaN        Γöé          Γöé
  1735. Γöé ceil        Γöé infinity      Γöé infinity      Γöé          Γöé
  1736. Γöé floor "      Γöé -infinity     Γöé -infinity     Γöé          Γöé
  1737. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1738. Γöé "         Γöé NaN        Γöé NaN        Γöé EDOM       Γöé
  1739. Γöé cos        Γöé infinity      Γöé NaN        Γöé ERANGE      Γöé
  1740. Γöé tan "       Γöé -infinity     Γöé NaN        Γöé ERANGE      Γöé
  1741. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1742. Γöé "cosh"       Γöé NaN        Γöé NaN        Γöé          Γöé
  1743. Γöé          Γöé infinity      Γöé infinity      Γöé ERANGE      Γöé
  1744. Γöé          Γöé -infinity     Γöé infinity      Γöé ERANGE      Γöé
  1745. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1746. Γöé "erf"       Γöé NaN        Γöé NaN "       Γöé EDOM       Γöé
  1747. Γöé          Γöé infinity      Γöé 1         Γöé          Γöé
  1748. Γöé          Γöé -infinity     Γöé -1 "        Γöé          Γöé
  1749. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1750. Γöé "erfc"       Γöé NaN        Γöé NaN "       Γöé EDOM       Γöé
  1751. Γöé          Γöé infinity      Γöé 0         Γöé          Γöé
  1752. Γöé          Γöé -infinity     Γöé 2 "        Γöé          Γöé
  1753. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1754. Γöé "exp"       Γöé NaN        Γöé NaN        Γöé          Γöé
  1755. Γöé          Γöé infinity      Γöé infinity "     Γöé ERANGE      Γöé
  1756. Γöé          Γöé -infinity     Γöé 0 "        Γöé ERANGE      Γöé
  1757. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1758. Γöé "fabs"       Γöé NaN        Γöé NaN        Γöé          Γöé
  1759. Γöé          Γöé infinity      Γöé infinity      Γöé          Γöé
  1760. Γöé          Γöé -infinity     Γöé infinity      Γöé          Γöé
  1761. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1762. Γöé "frexp"      Γöé NaN        Γöé NaN, "0"      Γöé EDOM       Γöé
  1763. Γöé          Γöé infinity      Γöé NaN, "0"      Γöé EDOM       Γöé
  1764. Γöé          Γöé -infinity     Γöé NaN, "0"      Γöé EDOM       Γöé
  1765. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1766. Γöé "gamma"      Γöé NaN        Γöé NaN        Γöé EDOM       Γöé
  1767. Γöé          Γöé infinity      Γöé infinity      Γöé ERANGE      Γöé
  1768. Γöé          Γöé -infinity     Γöé NaN        Γöé EDOM       Γöé
  1769. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1770. Γöé "         Γöé NaN        Γöé NaN        Γöé          Γöé
  1771. Γöé log        Γöé infinity "     Γöé infinity      Γöé          Γöé
  1772. Γöé log10 "      Γöé 0         Γöé -infinity     Γöé ERANGE      Γöé
  1773. Γöé          Γöé <0 "        Γöé NaN        Γöé EDOM       Γöé
  1774. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1775. Γöé "modf"       Γöé NaN        Γöé NaN, NaN      Γöé EDOM       Γöé
  1776. Γöé          Γöé infinity      Γöé NaN, infinity   Γöé EDOM       Γöé
  1777. Γöé          Γöé -infinity     Γöé NaN, -infinity   Γöé EDOM       Γöé
  1778. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1779. Γöé "sin"       Γöé NaN        Γöé NaN        Γöé EDOM       Γöé
  1780. Γöé          Γöé infinity      Γöé NaN        Γöé ERANGE      Γöé
  1781. Γöé          Γöé -infinity     Γöé NaN        Γöé ERANGE      Γöé
  1782. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1783. Γöé "sinh"       Γöé NaN        Γöé NaN        Γöé EDOM       Γöé
  1784. Γöé          Γöé infinity      Γöé infinity      Γöé ERANGE      Γöé
  1785. Γöé          Γöé -infinity     Γöé -infinity     Γöé ERANGE      Γöé
  1786. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1787. Γöé "sqrt"       Γöé NaN        Γöé NaN        Γöé          Γöé
  1788. Γöé          Γöé infinity      Γöé infinity "     Γöé          Γöé
  1789. Γöé          Γöé -infinity     Γöé 0 "        Γöé EDOM       Γöé
  1790. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1791. Γöé "tanh"       Γöé NaN        Γöé NaN "       Γöé EDOM       Γöé
  1792. Γöé          Γöé infinity      Γöé 1         Γöé          Γöé
  1793. Γöé          Γöé -infinity     Γöé -1 "        Γöé          Γöé
  1794. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1795.  
  1796. The functions in the following table take two arguments. The results from NaN 
  1797. and infinity values vary depending on which argument they are passed as. 
  1798.  
  1799. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1800. Γöé Table 2. Infinity and NaN Values in Math Functions              Γöé
  1801. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1802. Γöé FUNCTION    Γöé ARGUMENT 1   Γöé ARGUMENT 2   Γöé RESULT     Γöé "ERRNO"    Γöé
  1803. Γöé        Γöé        Γöé        Γöé        Γöé VALUE     Γöé
  1804. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1805. Γöé "atan2"    Γöé NaN      Γöé any number   Γöé NaN      Γöé EDOM     Γöé
  1806. Γöé        Γöé any number   Γöé NaN      Γöé NaN      Γöé        Γöé
  1807. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1808. Γöé "fmod"     Γöé NaN      Γöé any number   Γöé NaN      Γöé EDOM     Γöé
  1809. Γöé        Γöé any number   Γöé NaN      Γöé NaN      Γöé EDOM     Γöé
  1810. Γöé        Γöé ╤æinfinity   Γöé any number   Γöé 0       Γöé EDOM     Γöé
  1811. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1812. Γöé "ldexp"    Γöé infinity    Γöé any number   Γöé infinity    Γöé ERANGE    Γöé
  1813. Γöé        Γöé -infinity   Γöé any number   Γöé -infinity   Γöé ERANGE    Γöé
  1814. Γöé        Γöé NaN      Γöé any number   Γöé NaN      Γöé EDOM     Γöé
  1815. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  1816. Γöé "pow"     Γöé ╤æinfinity   Γöé "0"      Γöé NaN      Γöé EDOM     Γöé
  1817. Γöé        Γöé infinity    Γöé -infinity   Γöé NaN      Γöé EDOM     Γöé
  1818. Γöé        Γöé -infinity   Γöé ╤æinfinity   Γöé NaN      Γöé EDOM     Γöé
  1819. Γöé        Γöé -infinity   Γöé <-1      Γöé NaN      Γöé EDOM     Γöé
  1820. Γöé        Γöé -infinity   Γöé <1, >-1    Γöé NaN      Γöé EDOM     Γöé
  1821. Γöé        Γöé -infinity   Γöé >1       Γöé NaN      Γöé EDOM     Γöé
  1822. Γöé        Γöé NaN      Γöé any number   Γöé NaN      Γöé EDOM     Γöé
  1823. Γöé        Γöé any number   Γöé NaN      Γöé NaN      Γöé EDOM     Γöé
  1824. Γöé        Γöé <=0      Γöé infinity    Γöé NaN      Γöé EDOM     Γöé
  1825. Γöé        Γöé 1       Γöé ╤æinfinity   Γöé NaN      Γöé EDOM     Γöé
  1826. Γöé        Γöé ╤æinfinity   Γöé ╤æ1       Γöé 0       Γöé ERANGE    Γöé
  1827. Γöé        Γöé >0, <1     Γöé infinity    Γöé 0       Γöé ERANGE    Γöé
  1828. Γöé        Γöé >0, <1     Γöé -infinity   Γöé infinity    Γöé ERANGE    Γöé
  1829. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1830.  
  1831. Note:  If a signalling NaN is passed to a math function, the behavior is 
  1832.        undefined. 
  1833.  
  1834.  
  1835. ΓòÉΓòÉΓòÉ 3.3.1.5. Math Functions without Infinity and NaN Support ΓòÉΓòÉΓòÉ
  1836.  
  1837. The following floating-point unit functions are not supported for use with 
  1838. infinity or NaN values. In general, a NaN or infinity value as input for these 
  1839. functions results in an undefined value, an invalid operation exception, or 
  1840. both. These functions do not set errno. 
  1841.  
  1842.  _facos      _fasin 
  1843.  _fcos       _fcossin 
  1844.  _fpatan     _fptan 
  1845.  _fsin       _fsincos 
  1846.  _fsqrt      _fyl2x 
  1847.  _fyl2xp1    _f2xm1 
  1848.  
  1849.  Note:  If you expect the return value of a math function to be infinity or 
  1850.  NaN, you should use the functions that are supported for these values. The 
  1851.  advantage in using the floating-point unit math functions is a reduction in 
  1852.  the processing time and in the size of your executable file. 
  1853.  
  1854.  
  1855. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1856.  
  1857.      Infinity and NaN Support 
  1858.      <math.h> 
  1859.      acos - Calculate Arccosine 
  1860.      asin - Calculate Arcsine 
  1861.      atan - atan2 - Calculate Arctangent 
  1862.      ceil - Find Integer >= Argument 
  1863.      cos - Calculate Cosine 
  1864.      cosh - Calculate Hyperbolic Cosine 
  1865.      erf - erfc - Calculate Error Functions 
  1866.      exp - Calculate Exponential Function 
  1867.      fabs - Calculate Floating-Point Absolute Value 
  1868.      floor - Integer <= Argument 
  1869.      fmod - Calculate Floating-Point Remainder 
  1870.      frexp - Separate Floating-Point Value 
  1871.      gamma - Gamma Function 
  1872.      ldexp - Multiply by a Power of Two 
  1873.      log - Calculate Natural Logarithm 
  1874.      log10 - Calculate Base 10 Logarithm 
  1875.      modf - Separate Floating-Point Value 
  1876.      pow - Compute Power 
  1877.      sin - Calculate Sine 
  1878.      sinh - Calculate Hyperbolic Sine 
  1879.      sqrt - Calculate Square Root 
  1880.      tan - Calculate Tangent 
  1881.      tanh - Calculate Hyperbolic Tangent 
  1882.  
  1883.  
  1884. ΓòÉΓòÉΓòÉ 3.4. Using Low-Level I/O Functions ΓòÉΓòÉΓòÉ
  1885.  
  1886. The VisualAge C++ compiler supports both stream and low-level I/O. The primary 
  1887. difference between the two types of I/O is that low-level I/O leaves the 
  1888. responsibility of buffering and formatting up to you. 
  1889.  
  1890. In general, you should not mix input or output from low-level I/O with that 
  1891. from stream I/O. The only way to communicate between stream I/O and low-level 
  1892. I/O is by using the fdopen or fileno functions. 
  1893.  
  1894. The low-level I/O functions include: 
  1895.  
  1896.  access         fstat 
  1897.  chmod          isatty 
  1898.  _chsize        lseek 
  1899.  close          open 
  1900.  creat          read 
  1901.  dup            _setmode 
  1902.  dup2           _sopen 
  1903.  __eof          stat 
  1904.  fdopen         _tell 
  1905.  _filelength    umask 
  1906.  fileno         write 
  1907.  
  1908.  When you use the low-level I/O functions, you should be aware of the 
  1909.  following: 
  1910.  
  1911.      A handle is a value that identifies a file.  It is created by the system 
  1912.       and used by low-level I/O functions. For VisualAge C++, the handle 
  1913.       returned by low-level I/O functions like open (called the C_handle) is 
  1914.       the same as that returned by DosOpen (called the API_handle). As a 
  1915.       result, you can get a file handle using the low-level I/O functions, and 
  1916.       then use it with OS/2 APIs. 
  1917.  
  1918.       Portability Note  Other compilers may map the file handle so that the 
  1919.       C_handle and API_handle are different.  If you will be compiling your 
  1920.       programs with other compilers, do not write code that depends on the file 
  1921.       handles being the same. 
  1922.  
  1923.       You can pass handles between library environments without restriction. If 
  1924.       you acquire a handle other than by using the VisualAge C++ library 
  1925.       functions open, creat, _sopen, or fileno, you must run _setmode for that 
  1926.       handle before you use it with other VisualAge C++ library functions. 
  1927.  
  1928.      The default open-sharing mode is SH_DENYWR. Use _sopen to obtain other 
  1929.       sharing modes. 
  1930.  
  1931.      Text mode deletes '\r' characters on input and changes '\n' to '\r\n' on 
  1932.       output. 
  1933.  
  1934.      In a multithread environment, you must ensure that two threads do not 
  1935.       attempt to perform low-level I/O operations on the same file at the same 
  1936.       time. You must make sure that one I/O process is completed before another 
  1937.       begins. 
  1938.  
  1939.      If the file mode is text, the low-level I/O functions treat the character 
  1940.       'x1a' in the following ways: 
  1941.  
  1942.         -  If it is detected in a nonseekable file, 'x1a' is treated as 
  1943.            end-of-file. In a seekable file, it is treated as end-of-file only 
  1944.            if it is the last character. 
  1945.         -  If a file is opened as text with either the O_APPEND or O_RDWR flags 
  1946.            and 'x1a' is the last character of the file, the last character of 
  1947.            the file is deleted. 
  1948.  
  1949.  
  1950. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  1951.  
  1952.      Low-Level Input/Output Functions 
  1953.      Performing I/O Operations in the Programming Guide 
  1954.      access - Determine Access Mode 
  1955.      chmod - Change File Permission Setting 
  1956.      _chsize - Alter Length of File 
  1957.      close - Close File Associated with Handle 
  1958.      creat - Create New File 
  1959.      dup - Associate Second Handle with Open File 
  1960.      dup2 - Associate Second Handle with Open File 
  1961.      __eof - Determine End of File 
  1962.      fdopen - Associates Input Or Output With File 
  1963.      _filelength - Determine File Length 
  1964.      fileno - Determine File Handle 
  1965.      fstat - Information about Open File 
  1966.      isatty - Test Handle for Character Device 
  1967.      lseek - Move File Pointer 
  1968.      open - Open File 
  1969.      read - Read Into Buffer 
  1970.      _setmode - Set File Translation Mode 
  1971.      _sopen - Open Shared File 
  1972.      stat - Get Information about File or Directory 
  1973.      _tell - Get Pointer Position 
  1974.      umask - Sets File Mask of Current Process 
  1975.      write - Writes from Buffer to File 
  1976.  
  1977.  
  1978. ΓòÉΓòÉΓòÉ 4. Library Functions ΓòÉΓòÉΓòÉ
  1979.  
  1980. The VisualAge C++ libraries are divided into two parts: 
  1981.  
  1982.      Standard libraries, which define the SAA features and the VisualAge C++ 
  1983.       standard extensions to SAA 
  1984.  
  1985.      Subsystem libraries, which are a subset of the standard libraries, and 
  1986.       are used for subsystem development. The functions in these libraries do 
  1987.       not require a runtime environment. 
  1988.  
  1989.  This section lists alphabetically and describes all the functions that 
  1990.  VisualAge C++ product offers, including the extensions to the ANSI/ISO C 
  1991.  definition. For information on the subsystem libraries and the functions in 
  1992.  them, see the chapter called "Developing Subsystems" in the Programming Guide. 
  1993.  
  1994.  Each function description includes the following subsections: 
  1995.  
  1996.  Format 
  1997.        The prototyped declaration of the function and the header file in which 
  1998.        it is found. To include the declaration in your code, include the header 
  1999.        file. 
  2000.  
  2001.  Description 
  2002.        A brief description of what the function does, what parameters it takes, 
  2003.        and how to use the function. 
  2004.  
  2005.  Language Level 
  2006.        The C language standard that each function belongs to (some fall under 
  2007.        more than one): 
  2008.  
  2009.        ANSI           ANSI/ISO 9899-1990[1992] C standard (commonly referred to 
  2010.                       as the ANSI C standard or ANSI/ISO C standard). 
  2011.        ANSI 93        A subset of the ISO/IEC 9899:1990/Amendment 1:1993(E). 
  2012.        POSIX          ISO/IEC 9945-1:1990/IEEE POSIX 1003.1-1990 standard. 
  2013.        XPG4           X/Open Common Applications Environment Specification, 
  2014.                       System Interfaces and Headers, Issue 4. 
  2015.        SAA            IBM Systems Application Architecture Common Programming 
  2016.                       Interface (SAA CPI) Level 2 definition. 
  2017.        Extension      Extensions to the conventional standards, often specific 
  2018.                       to VisualAge C++.  (These include standard functions that 
  2019.                       have additional features under VisualAge C++.) 
  2020.  
  2021.                       Note:  To use the library extensions, you must set the 
  2022.                       language level to extended (with the #pragma 
  2023.                       langlvl(extended) directive or the /Se option); note that 
  2024.                       this is the default. 
  2025.  
  2026.  Example 
  2027.        A short example of how to use the function. From the online C Library 
  2028.        Reference, you can use the IPF Copy to File choice from the Services 
  2029.        pull-down to copy a function example to a separate file (called TEXT.TMP 
  2030.        by default). You can then compile, link, and run the example, or use the 
  2031.        example code in your own source files. 
  2032.  
  2033.  Related Information 
  2034.        A list of other functions that are similar to or related to the 
  2035.        function, and of other topics that provide additional information that 
  2036.        help you use the function. 
  2037.  
  2038.  
  2039. ΓòÉΓòÉΓòÉ 4.1. abort - Stop a Program ΓòÉΓòÉΓòÉ
  2040.  
  2041.  
  2042. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2043.  
  2044. #include <stdlib.h>
  2045. void abort(void);
  2046.  
  2047.  
  2048. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2049.  
  2050. Language Level:  ANSI, SAA, POSIX, XPG4, Extension 
  2051.  
  2052. abort causes an abnormal program termination and returns control to the host 
  2053. environment. It is similar to exit, except that abort does not flush buffers 
  2054. and close open files before ending the program. Calls to abort raise the 
  2055. SIGABRT signal. 
  2056.  
  2057. Return Value 
  2058. There is no return value. 
  2059.  
  2060.  
  2061. ΓòÉΓòÉΓòÉ <hidden> Example of abort ΓòÉΓòÉΓòÉ
  2062.  
  2063. /************************************************************************
  2064.  
  2065. This example tests for successful opening of the file myfile.mjq. If an error 
  2066. occurs, an error message is printed and the program ends with a call to abort. 
  2067.  
  2068. ************************************************************************/
  2069.  
  2070. #include <stdio.h>
  2071. #include <stdlib.h>
  2072.  
  2073. int main(void)
  2074. {
  2075.    FILE *stream;
  2076.  
  2077.    if (NULL == (stream = fopen("myfile.mjq", "r"))) {
  2078.       perror("Could not open data file");
  2079.       abort();
  2080.    }
  2081.    return 0;
  2082.  
  2083.    /****************************************************************************
  2084.       If myfile.mjq does'nt exist, the output should be:
  2085.  
  2086.       Could not open data file: The file cannot be found.
  2087.    ****************************************************************************/
  2088. }
  2089.  
  2090.  
  2091. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2092.  
  2093. Example of abort 
  2094.  
  2095.      exit - End Program 
  2096.      _exit - End Process 
  2097.      signal - Handle Interrupt Signals 
  2098.      <stdlib.h> 
  2099.  
  2100.  
  2101. ΓòÉΓòÉΓòÉ 4.2. abs - Calculate Integer Absolute Value ΓòÉΓòÉΓòÉ
  2102.  
  2103.  
  2104. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2105.  
  2106. #include <stdlib.h>
  2107. int abs(int n);
  2108.  
  2109.  
  2110. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2111.  
  2112. Language Level:  ANSI, SAA, POSIX, XPG4, Extension 
  2113.  
  2114. abs returns the absolute value of an integer argument n. 
  2115.  
  2116. Return Value 
  2117. There is no error return value.  The result is undefined when the absolute 
  2118. value of the argument cannot be represented as an integer. The value of the 
  2119. minimum allowable integer is defined by -INT_MAX in the <limits.h> include 
  2120. file. 
  2121.  
  2122.  
  2123. ΓòÉΓòÉΓòÉ <hidden> Example of abs ΓòÉΓòÉΓòÉ
  2124.  
  2125. /************************************************************************
  2126.  
  2127. This example calculates the absolute value of an integer x and assigns it to y. 
  2128.  
  2129. ************************************************************************/
  2130.  
  2131. #include <stdio.h>
  2132. #include <stdlib.h>
  2133.  
  2134. int main(void)
  2135. {
  2136.    int x = -4, y;
  2137.  
  2138.    y = abs(x);                                            /* y = 4            */
  2139.    printf("abs( %d ) = %d\n", x, y);
  2140.    return 0;
  2141.  
  2142.    /****************************************************************************
  2143.       The output should be:
  2144.  
  2145.       abs( -4 ) = 4
  2146.    ****************************************************************************/
  2147. }
  2148.  
  2149.  
  2150. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2151.  
  2152. Example of abs 
  2153.  
  2154.      _cabs - Calculate Absolute Value of Complex Number 
  2155.      fabs - Calculate Floating-Point Absolute Value 
  2156.      labs - Calculate Absolute Value of Long Integer 
  2157.      <limits.h> 
  2158.      <stdlib.h> 
  2159.  
  2160.  
  2161. ΓòÉΓòÉΓòÉ 4.3. access - Determine Access Mode ΓòÉΓòÉΓòÉ
  2162.  
  2163.  
  2164. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2165.  
  2166. #include <io.h>
  2167. int access(char *pathname, int mode);
  2168.  
  2169.  
  2170. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2171.  
  2172. Language Level:  POSIX, XPG4, Extension 
  2173.  
  2174. access determines whether the specified file exists and whether you can get 
  2175. access to it in the given mode. Possible values for the mode and their meaning 
  2176. in the access call are: 
  2177.  
  2178.  Value    Meaning 
  2179.   06      Check for permission to read from and write to the file. 
  2180.   04      Check for permission to read from the file. 
  2181.   02      Check for permission to write to the file. 
  2182.   00      Check only for the existence of the file. 
  2183.  
  2184.  Note:  In earlier releases of C Set ++, access began with an underscore 
  2185.  (_access). Because it is defined by the X/Open standard, the underscore has 
  2186.  been removed. For compatibility, VisualAge C++ will map _access to access for 
  2187.  you. 
  2188.  
  2189.  Return Value 
  2190.  access returns 0 if you can get access to the file in the specified mode. A 
  2191.  return value of -1 shows that the file does not exist or is inaccessible in 
  2192.  the given mode, and the system sets errno to one of the following values: 
  2193.  
  2194.  Value          Meaning 
  2195.  EACCESS        Access is denied; the permission setting of the file does not 
  2196.                 allow you to get access to the file in the specified mode. 
  2197.  ENOENT         The system cannot find the file or the path that you specified, 
  2198.                 or the file name was incorrect. 
  2199.  EINVAL         The mode specified was not valid. 
  2200.  EOS2ERR        The call to the operating system was not successful. 
  2201.  
  2202.  
  2203. ΓòÉΓòÉΓòÉ <hidden> Example of _access ΓòÉΓòÉΓòÉ
  2204.  
  2205. /************************************************************************
  2206.  
  2207. This example checks for the existence of the file sample.dat. If the file does 
  2208. not exist, it is created. 
  2209.  
  2210. ************************************************************************/
  2211.  
  2212. #include <io.h>
  2213. #include <stdio.h>
  2214. #include <stdlib.h>
  2215.  
  2216. int main(void)
  2217. {
  2218.    if (-1 == access("sample.dat", 00)) {
  2219.       printf("File sample.dat does not exist.\n");
  2220.       printf("Creating sample.dat.\n");
  2221.       system("echo Sample Program > sample.dat");
  2222.       if (0 == access("sample.dat", 00))
  2223.          printf("File sample.dat created.\n");
  2224.    }
  2225.    else
  2226.       printf("File sample.dat exists.\n");
  2227.    return 0;
  2228.  
  2229.    /****************************************************************************
  2230.       The output should be:
  2231.  
  2232.       File sample.dat does not exist.
  2233.       Creating sample.dat.
  2234.       File sample.dat created.
  2235.    ****************************************************************************/
  2236. }
  2237.  
  2238.  
  2239. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2240.  
  2241. Example of access 
  2242.  
  2243.      chmod - Change File Permission Setting 
  2244.      _sopen - Open Shared File 
  2245.      umask - Sets File Mask of Current Process 
  2246.      <io.h> 
  2247.  
  2248.  
  2249. ΓòÉΓòÉΓòÉ 4.4. acos - Calculate Arccosine ΓòÉΓòÉΓòÉ
  2250.  
  2251.  
  2252. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2253.  
  2254. #include <math.h>
  2255. double acos(double x);
  2256.  
  2257.  
  2258. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2259.  
  2260. Language Level:  ANSI, SAA, POSIX, XPG4 
  2261.  
  2262. acos calculates the arccosine of x, expressed in radians, in the range 0 to pi. 
  2263.  
  2264. Return Value 
  2265. acos returns the arccosine of x. The value of x must be between -1 and 1 
  2266. inclusive. If x is less than -1 or greater than 1, acos sets errno to EDOM and 
  2267. returns 0. 
  2268.  
  2269.  
  2270. ΓòÉΓòÉΓòÉ <hidden> Example of acos ΓòÉΓòÉΓòÉ
  2271.  
  2272. /************************************************************************
  2273.  
  2274. This example prompts for a value for x. It prints an error message if x is 
  2275. greater than 1 or less than -1; otherwise, it assigns the arccosine of x to y. 
  2276.  
  2277. ************************************************************************/
  2278.  
  2279. #include <stdio.h>
  2280. #include <stdlib.h>
  2281. #include <math.h>
  2282.  
  2283. #define  MAX           1.0
  2284. #define  MIN          -1.0
  2285.  
  2286. int main(void)
  2287. {
  2288.    double x,y;
  2289.  
  2290.    printf("Enter x\n");
  2291.    scanf("%lf", &x);
  2292.  
  2293.    /* Output error if not in range */
  2294.    if (x > MAX)
  2295.       printf("Error: %lf too large for acos\n", x);
  2296.    else
  2297.       if (x < MIN)
  2298.          printf("Error: %lf too small for acos\n", x);
  2299.       else {
  2300.          y = acos(x);
  2301.          printf("acos( %lf ) = %lf\n", x, y);
  2302.       }
  2303.    return 0;
  2304.  
  2305.    /****************************************************************************
  2306.       For the following input: 0.4
  2307.  
  2308.       The output should be:
  2309.  
  2310.       Enter x
  2311.       acos( 0.400000 ) = 1.159279
  2312.    ****************************************************************************/
  2313. }
  2314.  
  2315.  
  2316. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2317.  
  2318. Example of acos 
  2319.  
  2320.      asin - Calculate Arcsine 
  2321.      atan - atan2 - Calculate Arctangent 
  2322.      cos - Calculate Cosine 
  2323.      cosh - Calculate Hyperbolic Cosine 
  2324.      _facos - Calculate Arccosine 
  2325.      _fcos - Calculate Cosine 
  2326.      _fcossin - Calculate Cosine and Sine 
  2327.      _fsincos - Calculate Sine and Cosine 
  2328.      sin - Calculate Sine 
  2329.      sinh - Calculate Hyperbolic Sine 
  2330.      tan - Calculate Tangent 
  2331.      tanh - Calculate Hyperbolic Tangent 
  2332.      <math.h> 
  2333.  
  2334.  
  2335. ΓòÉΓòÉΓòÉ 4.5. _alloca - Temporarily Reserve Storage Block ΓòÉΓòÉΓòÉ
  2336.  
  2337.  
  2338. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2339.  
  2340. #include <stdlib.h>  /* also in <malloc.h> and <builtin.h> */
  2341. void *_alloca(size_t size);
  2342.  
  2343.  
  2344. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2345.  
  2346. Language Level:  Extension 
  2347.  
  2348. _alloca is a built-in function that temporarily allocates size bytes of storage 
  2349. space from the program's stack. The memory space is automatically freed when 
  2350. the function that called _alloca returns. 
  2351.  
  2352. Note:  _alloca is faster than other allocation functions such as malloc, but it 
  2353. has several limitations: 
  2354.  
  2355.      Because it is a built-in function, which means it is implemented as an 
  2356.       inline instruction and has no backing code in the library: 
  2357.         -  You cannot take the address of _alloca. 
  2358.         -  You cannot parenthesize a call to _alloca. (Parentheses specify a 
  2359.            call to the function's backing code, and _alloca has none). 
  2360.      Because _alloca automatically frees storage after the function that calls 
  2361.       it returns, you cannot pass the pointer value returned by _alloca as an 
  2362.       argument to the free function. 
  2363.      You cannot pass memory allocated by _alloca to 16-bit programs, because 
  2364.       it is never tiled. 
  2365.  
  2366.  Because _alloca uses automatic storage, programs calling _alloca must not be 
  2367.  compiled using the /Gs+ switch. This switch disables stack probes and does not 
  2368.  guarantee that enough stack storage will be available. You should use the /Gs- 
  2369.  switch, which is the default setting. 
  2370.  
  2371.  Return Value 
  2372.  _alloca returns a pointer to the reserved space. If _alloca cannot reserve the 
  2373.  requested space, the program gets an out of stack exception. 
  2374.  
  2375.  
  2376. ΓòÉΓòÉΓòÉ <hidden> Example of _alloca ΓòÉΓòÉΓòÉ
  2377.  
  2378. /************************************************************************
  2379.  
  2380. This example uses srand to generate five random numbers.  The numbers determine 
  2381. how much space _alloca is to allocate for the array barstr.  The result is a 
  2382. ragged two-dimensional array of strings. 
  2383.  
  2384. ************************************************************************/
  2385.  
  2386. #include <stdio.h>
  2387. #include <stdlib.h>
  2388. #include <string.h>
  2389. #include <time.h>
  2390.  
  2391. int main(void)
  2392. {
  2393.    char *fullbar = "1 2 3 4 5";
  2394.    int range,rval;
  2395.    char *barstr[5];
  2396.    int i;
  2397.  
  2398.    printf("Bar representation of 5 random numbers ");
  2399.    printf("(each generated from 1 to 5):\n\n");
  2400.  
  2401.    /* set seed for rand function using time in seconds                        */
  2402.    srand((unsigned int)time(NULL));
  2403.  
  2404.    for (i = 0; i < 5; i++) {
  2405.       rval = (rand()+1)%5; /* generate random number from 0 to 4              */
  2406.  
  2407.       /* for partial copy of fullbar, allocate space on stack for barstr
  2408.          from 2 to 10 characters long + one space for a null character        */
  2409.  
  2410.       barstr[i] = _alloca((rval *sizeof(char) << 1)+3);
  2411.       memset(barstr[i], '\0', (rval *sizeof(char) << 1)+3);
  2412.  
  2413.       /* copy random sized portion of fullbar                                 */
  2414.  
  2415.       strncpy(barstr[i], fullbar, ((rval+1)*2));
  2416.       printf("%s\n", barstr[i]);             /* print random length bar       */
  2417.    }
  2418.    return 0;
  2419.  
  2420.    /****************************************************************************
  2421.       The output should be similar to :
  2422.  
  2423.         Bar representation of 5 random numbers (each generated from 1 to 5):
  2424.         1
  2425.         1 2 3 4
  2426.         1 2 3
  2427.         1 2 3 4 5
  2428.         1 2
  2429.    ****************************************************************************/
  2430. }
  2431.  
  2432.  
  2433. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2434.  
  2435. Example 
  2436.  
  2437.      calloc - Reserve and Initialize Storage 
  2438.      free - Release Storage Blocks 
  2439.      malloc - Reserve Storage Block 
  2440.      realloc - Change Reserved Storage Block Size 
  2441.      /Gs option in the User's Guide 
  2442.      <malloc.h> 
  2443.      <stdlib.h> 
  2444.  
  2445.  
  2446. ΓòÉΓòÉΓòÉ 4.6. asctime - Convert Time to Character String ΓòÉΓòÉΓòÉ
  2447.  
  2448.  
  2449. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2450.  
  2451. #include <time.h>
  2452. char *asctime(const struct tm *time);
  2453.  
  2454.  
  2455. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2456.  
  2457. Language Level:  ANSI, SAA, POSIX, XPG4 
  2458.  
  2459. The asctime function converts time, stored as a structure pointed to by time, 
  2460. to a character string. You can obtain the time value from a call to gmtime or 
  2461. localtime; either returns a pointer to a tm structure defined in <time.h>. See 
  2462. gmtime - Convert Time for a description of the tm structure fields. 
  2463.  
  2464. The string result that asctime produces contains exactly 26 characters and has 
  2465. the format: 
  2466.  
  2467.    "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"
  2468.  
  2469. See printf - Print Formatted Characters for a description of format 
  2470. specifications. The following are examples of the string returned: 
  2471.  
  2472.    Sat Jul 16 02:03:55 1994\n\0
  2473. or
  2474.    Sat Jul 16  2:03:55 1994\n\0
  2475.  
  2476. The asctime function uses a 24-hour-clock format.  The days are abbreviated to: 
  2477. Sun, Mon, Tue, Wed, Thu, Fri, and Sat.  The months are abbreviated to: Jan, 
  2478. Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec. All fields have 
  2479. constant width. Dates with only one digit are preceded either with a zero or a 
  2480. blank space. The new-line character (\n) and the null character (\0) occupy the 
  2481. last two positions of the string. 
  2482.  
  2483. The time and date functions begin at 00:00:00 Universal Time, January 1, 1970. 
  2484.  
  2485. Return Value 
  2486. The asctime function returns a pointer to the resulting character string. 
  2487. There is no error return value. 
  2488.  
  2489. Note:  asctime, ctime, and other time functions may use a common, statically 
  2490.        allocated buffer to hold the return string. Each call to one of these 
  2491.        functions may destroy the result of the previous call. 
  2492.  
  2493.  
  2494. ΓòÉΓòÉΓòÉ <hidden> Example of asctime ΓòÉΓòÉΓòÉ
  2495.  
  2496. /************************************************************************
  2497.  
  2498. This example polls the system clock and prints a message giving the current 
  2499. time. 
  2500.  
  2501. ************************************************************************/
  2502.  
  2503. #include <time.h>
  2504. #include <stdio.h>
  2505.  
  2506. int main(void)
  2507. {
  2508.    struct tm *newtime;
  2509.    time_t ltime;
  2510.  
  2511.    /* Get the time in seconds */
  2512.    time(<ime);
  2513.  
  2514.    /* Convert it to the structure tm */
  2515.    newtime = localtime(<ime);
  2516.  
  2517.    /* Print the local time as a string */
  2518.    printf("The current date and time are %s", asctime(newtime));
  2519.    return 0;
  2520.  
  2521.    /****************************************************************************
  2522.       The output should be similar to :
  2523.  
  2524.       The current date and time are Fri Jun 28 13:51 1994
  2525.    ****************************************************************************/
  2526. }
  2527.  
  2528.  
  2529. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2530.  
  2531. Example of asctime 
  2532.  
  2533.      ctime - Convert Time to Character String 
  2534.      gmtime - Convert Time 
  2535.      localtime - Convert Time 
  2536.      mktime - Convert Local Time 
  2537.      strftime - Convert to Formatted Time 
  2538.      time - Determine Current Time 
  2539.      printf - Print Formatted Characters 
  2540.      <time.h> 
  2541.  
  2542.  
  2543. ΓòÉΓòÉΓòÉ 4.7. asin - Calculate Arcsine ΓòÉΓòÉΓòÉ
  2544.  
  2545.  
  2546. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2547.  
  2548. #include <math.h>
  2549. double asin(double x);
  2550.  
  2551.  
  2552. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2553.  
  2554. Language Level:  ANSI, SAA, POSIX, XPG4 
  2555.  
  2556. asin calculates the arcsine of x, in the range -pi/2 to pi/2 radians. 
  2557.  
  2558. Return Value 
  2559. asin returns the arcsine of x. The value of x must be between -1 and 1. If x is 
  2560. less than -1 or greater than 1, asin sets errno to EDOM, and returns a value of 
  2561. 0. 
  2562.  
  2563.  
  2564. ΓòÉΓòÉΓòÉ <hidden> Example of asin ΓòÉΓòÉΓòÉ
  2565.  
  2566. /************************************************************************
  2567.  
  2568. This example prompts for a value for x. It prints an error message if x is 
  2569. greater than 1 or less than -1; otherwise, it assigns the arcsine of x to y. 
  2570.  
  2571. ************************************************************************/
  2572.  
  2573. #include <stdio.h>
  2574. #include <stdlib.h>
  2575. #include <math.h>
  2576.  
  2577. #define  MAX           1.0
  2578. #define  MIN          -1.0
  2579.  
  2580. int main(void)
  2581. {
  2582.    double x,y;
  2583.  
  2584.    printf("Enter x\n");
  2585.    scanf("%lf", &x);
  2586.  
  2587.    /* Output error if not in range                                            */
  2588.    if (x > MAX)
  2589.       printf("Error: %lf too large for asin\n", x);
  2590.    else
  2591.       if (x < MIN)
  2592.          printf("Error: %lf too small for asin\n", x);
  2593.       else {
  2594.          y = asin(x);
  2595.          printf("asin( %lf ) = %lf\n", x, y);
  2596.       }
  2597.    return 0;
  2598.  
  2599.    /****************************************************************************
  2600.       For the following input: 0.2
  2601.  
  2602.       The output should be:
  2603.  
  2604.       Enter x
  2605.       asin( 0.200000 ) = 0.201358
  2606.    ****************************************************************************/
  2607. }
  2608.  
  2609.  
  2610. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2611.  
  2612. Example of asin 
  2613.  
  2614.      acos - Calculate Arccosine 
  2615.      atan - atan2 - Calculate Arctangent 
  2616.      cos - Calculate Cosine 
  2617.      cosh - Calculate Hyperbolic Cosine 
  2618.      _fasin - Calculate Arcsine 
  2619.      _fcossin - Calculate Cosine and Sine 
  2620.      _fsin - Calculate Sine 
  2621.      _fsincos - Calculate Sine and Cosine 
  2622.      sin - Calculate Sine 
  2623.      sinh - Calculate Hyperbolic Sine 
  2624.      tan - Calculate Tangent 
  2625.      tanh - Calculate Hyperbolic Tangent 
  2626.      <math.h> 
  2627.  
  2628.  
  2629. ΓòÉΓòÉΓòÉ 4.8. assert - Verify Condition ΓòÉΓòÉΓòÉ
  2630.  
  2631.  
  2632. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2633.  
  2634. #include <assert.h>
  2635. void assert(int expression);
  2636.  
  2637.  
  2638. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2639.  
  2640. Language Level:  ANSI, SAA, POSIX, XPG4 
  2641.  
  2642. assert prints a diagnostic message to stderr and aborts the program if 
  2643. expression is false (zero). The diagnostic message has the format: 
  2644.  
  2645. Assertion failed: expression, file filename, line line-number.
  2646.  
  2647. assert takes no action if the expression is true (nonzero). 
  2648.  
  2649. Use assert to identify program logic errors.  Choose an expression that holds 
  2650. true only if the program is operating as you intend.  After you have debugged 
  2651. the program, you can use the special no-debug identifier NDEBUG to remove the 
  2652. assert calls from the program.  If you define NDEBUG to any value with a 
  2653. #define directive, the C preprocessor expands all assert invocations to void 
  2654. expressions. If you use NDEBUG, you must define it before you include 
  2655. <assert.h> in the program. There is no return value. 
  2656.  
  2657. Note:  assert is implemented as a macro. Do not use the #undef directive with 
  2658. assert. 
  2659.  
  2660.  
  2661. ΓòÉΓòÉΓòÉ <hidden> Example of assert ΓòÉΓòÉΓòÉ
  2662.  
  2663. /************************************************************************
  2664.  
  2665. In this example, assert tests string for a null string and an empty string, and 
  2666. verifies that length is positive before processing these arguments. 
  2667.  
  2668. ************************************************************************/
  2669.  
  2670. #include <stdio.h>
  2671. #include <assert.h>
  2672.  
  2673. void analyze(char *string,int length)
  2674. {
  2675.    assert(string != NULL);                                /* cannot be NULL   */
  2676.    assert(*string != '\0');                               /* cannot be empty  */
  2677.    assert(length > 0);                                    /* must be positive */
  2678.    return;
  2679. }
  2680.  
  2681. int main(void)
  2682. {
  2683.    char *string = "ABC";
  2684.    int length = 3;
  2685.  
  2686.    analyze(string, length);
  2687.    printf("The string %s is not null or empty, and has length %d \n", string,
  2688.       length);
  2689.    return 0;
  2690.  
  2691.    /****************************************************************************
  2692.       The output should be:
  2693.  
  2694.       The string ABC is not null or empty, and has length 3
  2695.    ****************************************************************************/
  2696. }
  2697.  
  2698.  
  2699. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2700.  
  2701. Example of assert 
  2702.  
  2703.      abort - Stop a Program 
  2704.      <assert.h> 
  2705.      #define in the Language Reference 
  2706.      #undef in the Language Reference 
  2707.  
  2708.  
  2709. ΓòÉΓòÉΓòÉ 4.9. atan - atan2 - Calculate Arctangent ΓòÉΓòÉΓòÉ
  2710.  
  2711.  
  2712. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2713.  
  2714. #include <math.h>
  2715. double atan(double x);
  2716. double atan2(double y, double x);
  2717.  
  2718.  
  2719. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2720.  
  2721. Language Level:  ANSI, SAA, POSIX, XPG4 
  2722.  
  2723. atan and atan2 calculate the arctangent of x and y/x, respectively. 
  2724.  
  2725. Return Value 
  2726. atan returns a value in the range -pi/2 to pi/2 radians. atan2 returns a value 
  2727. in the range -pi to pi radians. If both arguments of atan2 are zero, the 
  2728. function sets errno to EDOM, and returns a value of 0. 
  2729.  
  2730.  
  2731. ΓòÉΓòÉΓòÉ <hidden> Example of atan - atan2 ΓòÉΓòÉΓòÉ
  2732.  
  2733. /************************************************************************
  2734.  
  2735. This example calculates arctangents using the atan and atan2 functions. 
  2736.  
  2737. ************************************************************************/
  2738.  
  2739. #include <math.h>
  2740.  
  2741. int main(void)
  2742. {
  2743.    double a,b,c,d;
  2744.  
  2745.    c = 0.45;
  2746.    d = 0.23;
  2747.    a = atan(c);
  2748.    b = atan2(c, d);
  2749.    printf("atan( %lf ) = %lf\n", c, a);
  2750.    printf("atan2( %lf, %lf ) = %lf\n", c, d, b);
  2751.    return 0;
  2752.  
  2753.    /****************************************************************************
  2754.       The output should be:
  2755.  
  2756.       atan( 0.450000 ) = 0.422854
  2757.       atan2( 0.450000, 0.230000 ) = 1.098299
  2758.    ****************************************************************************/
  2759. }
  2760.  
  2761.  
  2762. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2763.  
  2764. Example of atan - atan2 
  2765.  
  2766.      acos - Calculate Arccosine 
  2767.      asin - Calculate Arcsine 
  2768.      cos - Calculate Cosine 
  2769.      cosh - Calculate Hyperbolic Cosine 
  2770.      _fpatan - Calculate Arctangent 
  2771.      _fptan - Calculate Tangent 
  2772.      sin - Calculate Sine 
  2773.      sinh - Calculate Hyperbolic Sine 
  2774.      tan - Calculate Tangent 
  2775.      tanh - Calculate Hyperbolic Tangent 
  2776.      <math.h> 
  2777.  
  2778.  
  2779. ΓòÉΓòÉΓòÉ 4.10. atexit - Record Program Termination Function ΓòÉΓòÉΓòÉ
  2780.  
  2781.  
  2782. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2783.  
  2784. #include <stdlib.h>
  2785. int atexit(void (*func)(void));
  2786.  
  2787.  
  2788. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2789.  
  2790. Language Level:  ANSI, SAA, POSIX, XPG4 
  2791.  
  2792. atexit records a function, pointed to by func, that the system calls at normal 
  2793. program termination.  For portability, you should use atexit to register up to 
  2794. 32 functions only. The functions are executed in a last-in, first-out order. 
  2795.  
  2796. Return Value 
  2797. atexit returns 0 if it is successful, and nonzero if it fails. 
  2798.  
  2799.  
  2800. ΓòÉΓòÉΓòÉ <hidden> Example of atexit ΓòÉΓòÉΓòÉ
  2801.  
  2802. /************************************************************************
  2803.  
  2804. This example uses atexit to call the function goodbye at program termination. 
  2805.  
  2806. ************************************************************************/
  2807.  
  2808. #include <stdlib.h>
  2809. #include <stdio.h>
  2810.  
  2811. void goodbye(void)
  2812. {
  2813.  
  2814.    /* This function is called at normal program termination                   */
  2815.  
  2816.    printf("The function goodbye was called at program termination\n");
  2817. }
  2818.  
  2819. int main(void)
  2820. {
  2821.    int rc;
  2822.  
  2823.    rc = atexit(goodbye);
  2824.    if (rc != 0)
  2825.       perror("Error in atexit");
  2826.    return 0;
  2827.  
  2828.    /****************************************************************************
  2829.       The output should be:
  2830.  
  2831.       The function goodbye was called at program termination
  2832.    ****************************************************************************/
  2833. }
  2834.  
  2835.  
  2836. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2837.  
  2838. Example of atexit 
  2839.  
  2840.      exit - End Program 
  2841.      _exit - End Process 
  2842.      _onexit - Record Termination Function 
  2843.      signal - Handle Interrupt Signals 
  2844.      <stdlib.h> 
  2845.  
  2846.  
  2847. ΓòÉΓòÉΓòÉ 4.11. atof - Convert Character String to Float ΓòÉΓòÉΓòÉ
  2848.  
  2849.  
  2850. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2851.  
  2852. #include <stdlib.h>
  2853. double atof(const char *string);
  2854.  
  2855.  
  2856. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2857.  
  2858. Language Level:  ANSI, SAA, POSIX, XPG4, Extension 
  2859.  
  2860. atof converts a character string to a double-precision floating-point value. 
  2861.  
  2862. The input string is a sequence of characters that can be interpreted as a 
  2863. numerical value of the specified return type.  The function stops reading the 
  2864. input string at the first character that it cannot recognize as part of a 
  2865. number;  this character can be the null character that ends the string. 
  2866.  
  2867. atof expects a string in the following form: 
  2868.  
  2869. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  2870. Γöé                                        Γöé
  2871. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ>          Γöé
  2872. Γöé   ΓööΓöÇwhitespaceΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ  Γö£ΓöÇdigitsΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöñ           Γöé
  2873. Γöé           ΓööΓöÇΓö┤ΓöÇΓöÿ  Γöé     ΓööΓöÇ.ΓöÇΓöÿ  ΓööΓöÇdigitsΓöÇΓöÿ Γöé           Γöé
  2874. Γöé               ΓööΓöÇ.ΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ           Γöé
  2875. Γöé                                        Γöé
  2876. Γöé >ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><                        Γöé
  2877. Γöé   ΓööΓöÇΓö¼ΓöÇeΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÿ                          Γöé
  2878. Γöé    ΓööΓöÇEΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ                               Γöé
  2879. Γöé       ΓööΓöÇΓö┤ΓöÇΓöÿ                               Γöé
  2880. Γöé                                        Γöé
  2881. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2882.  
  2883. The white space consists of the same characters for which the isspace function 
  2884. is true, such as spaces and tabs. atof ignores leading white-space characters. 
  2885.  
  2886. For atof, digits is one or more decimal digits;  if no digits appear before the 
  2887. decimal point, at least one digit must appear after the decimal point.  The 
  2888. decimal digits can precede an exponent, introduced by the letter e or E.  The 
  2889. exponent is a decimal integer, which may be signed. The string can also be 
  2890. "infinity", "inf", or "nan". These strings are case insensitive, and can be 
  2891. preceded by a unary minus (-). They are converted to infinity and NaN values. 
  2892.  
  2893. Return Value 
  2894. atof returns a double value produced by interpreting the input characters as a 
  2895. number. The return value is 0 if the function cannot convert the input to a 
  2896. value of that type. The return value is undefined in case of overflow. 
  2897.  
  2898.  
  2899. ΓòÉΓòÉΓòÉ <hidden> Example of atof ΓòÉΓòÉΓòÉ
  2900.  
  2901. /************************************************************************
  2902.  
  2903. This example shows how to convert numbers stored as strings to numerical values 
  2904. using the atof function. 
  2905.  
  2906. ************************************************************************/
  2907.  
  2908. #include <stdio.h>
  2909. #include <stdlib.h>
  2910.  
  2911. int main(void)
  2912. {
  2913.    double x;
  2914.    char *s;
  2915.  
  2916.    s = " -2309.12E-15";
  2917.    x = atof(s);                                           /* x = -2309.12E-15 */
  2918.    printf("atof( %s ) = %G\n", s, x);
  2919.    return 0;
  2920.  
  2921.    /****************************************************************************
  2922.       The output should be:
  2923.  
  2924.       atof(  -2309.12E-15 ) = -2.30912E-12
  2925.    ****************************************************************************/
  2926. }
  2927.  
  2928.  
  2929. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  2930.  
  2931. Example of atof 
  2932.  
  2933.      atoi - Convert Character String to Integer 
  2934.      atol - Convert Character String to Long Integer 
  2935.      _atold - Convert Character String to Long Double 
  2936.      strtod - Convert Character String to Double 
  2937.      strtol - Convert Character String to Long Integer 
  2938.      strtold - Convert String to Long Double 
  2939.      Infinity and NaN Support 
  2940.      <stdlib.h> 
  2941.  
  2942.  
  2943. ΓòÉΓòÉΓòÉ 4.12. atoi - Convert Character String to Integer ΓòÉΓòÉΓòÉ
  2944.  
  2945.  
  2946. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  2947.  
  2948. #include <stdlib.h>
  2949. int atoi(const char *string);
  2950.  
  2951.  
  2952. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  2953.  
  2954. Language Level:  ANSI, SAA, POSIX, XPG4 
  2955.  
  2956. atoi converts a character string to an integer value. 
  2957.  
  2958. The input string is a sequence of characters that can be interpreted as a 
  2959. numerical value of the specified return type.  The function stops reading the 
  2960. input string at the first character that it cannot recognize as part of a 
  2961. number;  this character can be the null character that ends the string. 
  2962.  
  2963. atoi does not recognize decimal points nor exponents. The string argument for 
  2964. this function has the form: 
  2965.  
  2966. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  2967. Γöé                                        Γöé
  2968. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÇ><                     Γöé
  2969. Γöé   ΓööΓöÇwhitespaceΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ                           Γöé
  2970. Γöé           ΓööΓöÇΓö┤ΓöÇΓöÿ                           Γöé
  2971. Γöé                                        Γöé
  2972. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2973.  
  2974. where whitespace consists of the same characters for which the isspace function 
  2975. is true, such as spaces and tabs. atoi ignores leading white-space characters. 
  2976. digits is one or more decimal digits. 
  2977.  
  2978. Return Value 
  2979. atoi returns an int value produced by interpreting the input characters as a 
  2980. number.  The return value is 0 if the function cannot convert the input to a 
  2981. value of that type.  The return value is undefined in the case of an overflow. 
  2982.  
  2983.  
  2984. ΓòÉΓòÉΓòÉ <hidden> Example of atoi ΓòÉΓòÉΓòÉ
  2985.  
  2986. /************************************************************************
  2987.  
  2988. This example shows how to convert numbers stored as strings to numerical values 
  2989. using the atoi function. 
  2990.  
  2991. ************************************************************************/
  2992.  
  2993. #include <stdio.h>
  2994. #include <stdlib.h>
  2995.  
  2996. int main(void)
  2997. {
  2998.    int i;
  2999.    char *s;
  3000.  
  3001.    s = " -9885";
  3002.    i = atoi(s);                                           /* i = -9885        */
  3003.    printf("atoi( %s ) = %d\n", s, i);
  3004.    return 0;
  3005.  
  3006.    /****************************************************************************
  3007.       The output should be:
  3008.  
  3009.       atoi(  -9885 ) = -9885
  3010.    ****************************************************************************/
  3011. }
  3012.  
  3013.  
  3014. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3015.  
  3016. Example of atoi 
  3017.  
  3018.      atof - Convert Character String to Float 
  3019.      atol - Convert Character String to Long Integer 
  3020.      _atold - Convert Character String to Long Double 
  3021.      strtod - Convert Character String to Double 
  3022.      strtol - Convert Character String to Long Integer 
  3023.      strtold - Convert String to Long Double 
  3024.      <stdlib.h> 
  3025.  
  3026.  
  3027. ΓòÉΓòÉΓòÉ 4.13. atol - Convert Character String to Long Integer ΓòÉΓòÉΓòÉ
  3028.  
  3029.  
  3030. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3031.  
  3032. #include <stdlib.h>
  3033. long int atol(const char *string);
  3034.  
  3035.  
  3036. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3037.  
  3038. Language Level:  ANSI, SAA, POSIX, XPG4 
  3039.  
  3040. atol converts a character string to a long value. 
  3041.  
  3042. The input string is a sequence of characters that can be interpreted as a 
  3043. numerical value of the specified return type.  The function stops reading the 
  3044. input string at the first character that it cannot recognize as part of a 
  3045. number; this character can be the null character that ends the string. 
  3046.  
  3047. atol does not recognize decimal points nor exponents.  The string argument for 
  3048. this function has the form: 
  3049.  
  3050. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  3051. Γöé                                        Γöé
  3052. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÇ><                     Γöé
  3053. Γöé   ΓööΓöÇwhitespaceΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ                           Γöé
  3054. Γöé           ΓööΓöÇΓö┤ΓöÇΓöÿ                           Γöé
  3055. Γöé                                        Γöé
  3056. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  3057.  
  3058. where whitespace consists of the same characters for which the isspace function 
  3059. is true, such as spaces and tabs. atol ignores leading white-space characters. 
  3060. digits is one or more decimal digits. 
  3061.  
  3062. Return Value 
  3063. atol returns a long value produced by interpreting the input characters as a 
  3064. number.  The return value is 0L if the function cannot convert the input to a 
  3065. value of that type.  The return value is undefined in case of overflow. 
  3066.  
  3067.  
  3068. ΓòÉΓòÉΓòÉ <hidden> Example of atol ΓòÉΓòÉΓòÉ
  3069.  
  3070. /************************************************************************
  3071.  
  3072. This example shows how to convert numbers stored as strings to numerical values 
  3073. using the atol function. 
  3074.  
  3075. ************************************************************************/
  3076.  
  3077. #include <stdio.h>
  3078. #include <stdlib.h>
  3079.  
  3080. int main(void)
  3081. {
  3082.    long l;
  3083.    char *s;
  3084.  
  3085.    s = "98854 dollars";
  3086.    l = atol(s);                                           /* l = 98854        */
  3087.    printf("atol( %s ) = %d\n", s, l);
  3088.    return 0;
  3089.  
  3090.    /****************************************************************************
  3091.       The output should be similar to :
  3092.  
  3093.       atol( 98854 dollars ) = 98854
  3094.    ****************************************************************************/
  3095. }
  3096.  
  3097.  
  3098. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3099.  
  3100. Example of atol 
  3101.  
  3102.      atof - Convert Character String to Float 
  3103.      atoi - Convert Character String to Integer 
  3104.      _atold - Convert Character String to Long Double 
  3105.      strtod - Convert Character String to Double 
  3106.      strtol - Convert Character String to Long Integer 
  3107.      strtold - Convert String to Long Double 
  3108.      <stdlib.h> 
  3109.  
  3110.  
  3111. ΓòÉΓòÉΓòÉ 4.14. _atold - Convert Character String to Long Double ΓòÉΓòÉΓòÉ
  3112.  
  3113.  
  3114. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3115.  
  3116. #include <stdlib.h>    /* also defined in <math.h> */
  3117. long double _atold(const char *nptr);
  3118.  
  3119.  
  3120. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3121.  
  3122. Language Level:  Extension 
  3123.  
  3124. _atold converts a character string pointed to by nptr to a long double value. 
  3125. The function continues until it reads a character it does not recognize as part 
  3126. of a number. This character can be the ending null character. Except for its 
  3127. behavior on error, _atold is equivalent to: 
  3128.  
  3129.    strtold(nptr, (char **)NULL)
  3130.  
  3131. The string pointed to by nptr must have the following format: 
  3132.  
  3133. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  3134. Γöé                                        Γöé
  3135. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ>       Γöé
  3136. Γöé   ΓööΓöÇwhitespaceΓöÇΓöÿ  ΓööΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇdigitsΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÿ        Γöé
  3137. Γöé            Γö£ΓöÇ + ΓöÇΓöñ  Γöé     ΓööΓöÇ.ΓöÇΓöÿ  ΓööΓöÇdigitsΓöÇΓöÿ Γöé         Γöé
  3138. Γöé            ΓööΓöÇ Γö┤ ΓöÇΓöÿ  ΓööΓöÇ.ΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ         Γöé
  3139. Γöé                                        Γöé
  3140. Γöé >ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><                      Γöé
  3141. Γöé   ΓööΓöÇΓö¼ΓöÇ e ΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÿ                        Γöé
  3142. Γöé    ΓööΓöÇ E ΓöÇΓöÿ  Γö£ΓöÇ + ΓöÇΓöñ                             Γöé
  3143. Γöé        ΓööΓöÇ Γö┤ ΓöÇΓöÿ                             Γöé
  3144. Γöé                                        Γöé
  3145. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  3146.  
  3147. digits is one or more decimal digits.  If no digits appear before the decimal 
  3148. point, at least one digit must follow the decimal point.  You can place an 
  3149. exponent expressed as a decimal integer after the digits. The exponent can be 
  3150. signed. 
  3151.  
  3152. The value of nptr can also be one of the strings infinity, inf, or nan.  These 
  3153. strings are case insensitive, and can be preceded by a unary minus (-). They 
  3154. are converted to infinity and NaN values. For more information on NaN and 
  3155. infinity values, see Infinity and NaN Support. 
  3156.  
  3157. _atold ignores any white-space characters, as defined by the isspace function. 
  3158.  
  3159. Return Value 
  3160. _atold returns the converted long double value. In the case of an underflow, it 
  3161. returns 0. In the case of a positive overflow, _atold returns positive 
  3162. _LHUGE_VAL. It returns negative _LHUGE_VAL for a negative overflow. 
  3163.  
  3164.  
  3165. ΓòÉΓòÉΓòÉ <hidden> Example of _atold ΓòÉΓòÉΓòÉ
  3166.  
  3167. /************************************************************************
  3168.  
  3169. This example uses _atold to convert two strings, "  -001234.5678e10end of 
  3170. string" and "NaNQ", to their corresponding long double values. 
  3171.  
  3172. ************************************************************************/
  3173.  
  3174. #include <stdlib.h>
  3175. #include <stdio.h>
  3176.  
  3177. int main(void)
  3178. {
  3179.    char *string;
  3180.  
  3181.    string = "  -001234.5678e10end of string";
  3182.    printf("_atold = %.10Le\n", _atold(string));
  3183.    string = "NaNQ";
  3184.    printf("_atold = %.10Le\n", _atold(string));
  3185.    return 0;
  3186.  
  3187.    /****************************************************************************
  3188.       The output should be:
  3189.  
  3190.       _atold = -1.2345678000e+13
  3191.       _atold = nan
  3192.    ****************************************************************************/
  3193.  
  3194. }
  3195.  
  3196.  
  3197. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3198.  
  3199. Example of _atold 
  3200.  
  3201.      atof - Convert Character String to Float 
  3202.      atoi - Convert Character String to Integer 
  3203.      atol - Convert Character String to Long Integer 
  3204.      strtod - Convert Character String to Double 
  3205.      strtol - Convert Character String to Long Integer 
  3206.      strtold - Convert String to Long Double 
  3207.      <stdlib.h> 
  3208.      <math.h> 
  3209.  
  3210.  
  3211. ΓòÉΓòÉΓòÉ 4.15. _beginthread - Create New Thread ΓòÉΓòÉΓòÉ
  3212.  
  3213.  
  3214. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3215.  
  3216. #include <stdlib.h>   /* also in <process.h> */
  3217. int _beginthread(void (*start_address) (void *),
  3218.                      (void *)stack,
  3219.                      unsigned stack_size,
  3220.                      void *arglist);
  3221.  
  3222.  
  3223. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3224.  
  3225. Language Level:  Extension 
  3226.  
  3227. _beginthread creates a new thread. It takes the following arguments: 
  3228.  
  3229.  start_address 
  3230.    This parameter is the address of the function that the newly created thread 
  3231.    will execute. When the thread returns from that function, it is terminated 
  3232.    automatically. You can also explicitly terminate the thread by calling 
  3233.    _endthread. 
  3234.  
  3235.  stack 
  3236.    This parameter is ignored, but is retained to ease migration of C/2 
  3237.    programs.  The C/2 compiler requires the second parameter to be the address 
  3238.    of the bottom of the stack that the new thread will use. Because the OS/2 
  3239.    operating system automatically takes care of stack allocation, the parameter 
  3240.    is not needed. 
  3241.  
  3242.  stack_size 
  3243.    The size of the stack, in bytes, that is to be allocated for the new thread. 
  3244.    The stack size should be a nonzero multiple of 4K and a minimum of 8K. 
  3245.    Memory is used when needed, one page at a time. 
  3246.  
  3247.  arglist 
  3248.    A parameter to be passed to the newly created thread. It is the size of a 
  3249.    pointer, and is usually the address of a data item to be passed to the new 
  3250.    thread, such as a char string. It provides _beginthread with a value to pass 
  3251.    to the child thread. NULL can be used as a placeholder. 
  3252.  
  3253.  The function that the new thread will perform must be declared and compiled 
  3254.  using _Optlink linkage. 
  3255.  
  3256.  An alternative to this function is the OS/2 DosCreateThread API. If you use 
  3257.  DosCreateThread, you must also use a #pragma handler statement for the thread 
  3258.  function to ensure proper C exception handling. You should also call the 
  3259.  _fpreset function at the start of the thread to preset the 387 control status 
  3260.  word correctly. Using DosCreateThread requires that you use _endthread to 
  3261.  terminate the thread. 
  3262.  
  3263.  Note:  When using the _beginthread and _endthread functions, you must specify 
  3264.  the /Gm+ compiler option to use the multithread libraries. 
  3265.  
  3266.  Return Value 
  3267.  If successful, _beginthread returns the thread ID number of the new thread. It 
  3268.  returns -1 to indicate an error. 
  3269.  
  3270.  
  3271. ΓòÉΓòÉΓòÉ <hidden> Example of _beginthread ΓòÉΓòÉΓòÉ
  3272.  
  3273. /************************************************************************
  3274.  
  3275. This example uses _beginthread to start a new thread bonjour, which prints 
  3276. Bonjour! five times and then implicitly ends itself. The program then prints a 
  3277. statement indicating the thread identifier number for bonjour. 
  3278.  
  3279. Note:  To run this example, you must compile it using the /Gm+ compiler option. 
  3280.  
  3281. ************************************************************************/
  3282.  
  3283. #define  INCL_DOS
  3284. #include <os2.h>
  3285. #include <stdio.h>
  3286. #include <stdlib.h>
  3287.  
  3288. static int wait = 1;
  3289.  
  3290. void _Optlink bonjour(void *arg)
  3291. {
  3292.    int i = 0;
  3293.  
  3294.    while (wait)              /* wait until the thread id has been printed     */
  3295.       DosSleep(0l);
  3296.    while (i++ < 5)
  3297.       printf("Bonjour!\n");
  3298. }
  3299.  
  3300. int main(void)
  3301. {
  3302.    int tid;
  3303.  
  3304.    tid = _beginthread(bonjour, NULL, 8192, NULL);
  3305.    if (-1 == tid) {
  3306.       printf("Unable to start thread.\n");
  3307.       return EXIT_FAILURE;
  3308.    }
  3309.    else {
  3310.       printf("Thread started with thread identifier number %d.\n", tid);
  3311.       wait = 0;
  3312.    }
  3313.    DosWaitThread((PTID)&tid, DCWW_WAIT);  /* wait for thread bonjourto end    */
  3314.                                           /* before ending main thread        */
  3315.  
  3316.    return 0;
  3317.  
  3318.    /****************************************************************************
  3319.       The output should be similar to :
  3320.  
  3321.        Thread started with thread identifier number 2.
  3322.        Bonjour!
  3323.        Bonjour!
  3324.        Bonjour!
  3325.        Bonjour!
  3326.        Bonjour!
  3327.    ****************************************************************************/
  3328. }
  3329.  
  3330.  
  3331. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3332.  
  3333. Example of _beginthread 
  3334.  
  3335.      _endthread - Terminate Current Thread 
  3336.      _threadstore - Access Thread-Specific Storage 
  3337.      /Gm+ option in the User's Guide 
  3338.      <stdlib.h> 
  3339.      <process.h> 
  3340.  
  3341.  
  3342. ΓòÉΓòÉΓòÉ 4.16. Bessel Functions - Solve Differential Equations ΓòÉΓòÉΓòÉ
  3343.  
  3344.  
  3345. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3346.  
  3347. #include <math.h>
  3348. double _j0(double x);
  3349. double _j1(double x);
  3350. double _jn(int n, double x);
  3351. double _y0(double x);
  3352. double _y1(double x);
  3353. double _yn(int n, double x);
  3354.  
  3355.  
  3356. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3357.  
  3358. Language Level: SAA 
  3359.  
  3360. Bessel functions solve certain types of differential equations.  The _j0, _j1, 
  3361. and _jn functions are Bessel functions of the first kind for orders 0, 1, and 
  3362. n, respectively. 
  3363.  
  3364. The _y0, _y1, and _yn functions are Bessel functions of the second kind for 
  3365. orders 0, 1, and n, respectively. The argument x must be positive. The argument 
  3366. n should be greater than or equal to zero. If n is less than zero, it will be a 
  3367. negative exponent. 
  3368.  
  3369. Return Value 
  3370. For _j0, _j1, _y0, or _y1, if the absolute value of x is too large, the 
  3371. function sets errno to ERANGE, and returns 0. For _y0, _y1, or _yn, if x is 
  3372. negative, the function sets errno to EDOM and returns the value -HUGE_VAL. For 
  3373. _y0, _y1, or _yn, if x causes an overflow, the function sets errno to ERANGE 
  3374. and returns the value -HUGE_VAL. 
  3375.  
  3376.  
  3377. ΓòÉΓòÉΓòÉ <hidden> Example of Bessel Functions ΓòÉΓòÉΓòÉ
  3378.  
  3379. /************************************************************************
  3380.  
  3381. This example computes y to be the order 0 Bessel function of the first kind for 
  3382. x, and z to be the order 3 Bessel function of the second kind for x. 
  3383.  
  3384. ************************************************************************/
  3385.  
  3386. #include <stdio.h>
  3387. #include <math.h>
  3388.  
  3389. int main(void)
  3390. {
  3391.    double x,y,z;
  3392.  
  3393.    x = 4.27;
  3394.    y = j0(x);      /* y = -0.3660 is the order 0 bessel                       */
  3395.                    /* function of the first kind for x                        */
  3396.  
  3397.    printf("j0( 4.27 ) = %5.4f\n", y);
  3398.    z = yn(3, x);   /* z = -0.0875 is the order 3 bessel                       */
  3399.                    /* function of the second kind for x                       */
  3400.  
  3401.    printf("yn( 3,4.27 ) = %5.4f\n", z);
  3402.    return 0;
  3403.  
  3404.    /****************************************************************************
  3405.       The output should be:
  3406.  
  3407.       j0( 4.27 ) = -0.3660
  3408.       yn( 3,4.27 ) = -0.0875
  3409.    ****************************************************************************/
  3410. }
  3411.  
  3412.  
  3413. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3414.  
  3415. Example of Bessel Functions 
  3416.  
  3417.      erf - erfc - Calculate Error Functions 
  3418.      gamma - Gamma Function 
  3419.      <math.h> 
  3420.  
  3421.  
  3422. ΓòÉΓòÉΓòÉ 4.17. bsearch - Search Arrays ΓòÉΓòÉΓòÉ
  3423.  
  3424.  
  3425. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3426.  
  3427. #include <stdlib.h>  /* also in <search.h> */
  3428. void *bsearch(const void *key, const void *base,
  3429.               size_t num, size_t size,
  3430.               int (*compare)(const void *key, const void *element));
  3431.  
  3432.  
  3433. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3434.  
  3435. Language Level: ANSI, SAA, POSIX, XPG, Extension 
  3436.  
  3437. bsearch performs a binary search of an array of num elements, each of size 
  3438. bytes. The array must be sorted in ascending order by the function pointed to 
  3439. by compare.  The base is a pointer to the base of the array to search, and key 
  3440. is the value being sought. 
  3441.  
  3442. The compare argument is a pointer to a function you must supply that takes a 
  3443. pointer to the key argument and to an array element, in that order. bsearch 
  3444. calls this function one or more times during the search. The function must 
  3445. compare the key and the element and return one of the following values: 
  3446.  
  3447.  Value             Meaning 
  3448.  Less than 0       key less than element 
  3449.  0                 key identical to element 
  3450.  Greater than 0    key greater than element 
  3451.  
  3452.  Return Value 
  3453.  bsearch returns a pointer to key in the array to which base points. If two 
  3454.  keys are equal, the element that key will point to is unspecified. If bsearch 
  3455.  cannot find the key, it returns NULL. 
  3456.  
  3457.  
  3458. ΓòÉΓòÉΓòÉ <hidden> Example of bsearch ΓòÉΓòÉΓòÉ
  3459.  
  3460. /************************************************************************
  3461.  
  3462. This example performs a binary search on the argv array of pointers to the 
  3463. program parameters and finds the position of the argument PATH. It first 
  3464. removes the program name from argv, and then sorts the array alphabetically 
  3465. before calling bsearch. The functions compare1 and compare2 compare the values 
  3466. pointed to by arg1 and arg2 and return the result to bsearch. 
  3467.  
  3468. ************************************************************************/
  3469.  
  3470. #include <stdlib.h>
  3471. #include <stdio.h>
  3472. #include <string.h>
  3473.  
  3474. /* ------------------------------------------------------------------         */
  3475. /* Note: Library always calls functions internally with _Optlink              */
  3476. /*       linkage convention.  Ensure that compare1() and compare2             */
  3477. /*       are always _Optlink.                                                 */
  3478. /* ------------------------------------------------------------------         */
  3479.  
  3480. int _Optlink compare1(const void *arg1,const void *arg2)
  3481. {
  3482.    return (strcmp(*(char **)arg1, *(char **)arg2));
  3483. }
  3484.  
  3485. int _Optlink compare2(const void *arg1,const void *arg2)
  3486. {
  3487.    return (strcmp((char *)arg1, *(char **)arg2));
  3488. }
  3489.  
  3490. int main(int argc,char *argv[])
  3491. {
  3492.    char **result;
  3493.    char *key = "PATH";
  3494.    int i;
  3495.    argv++;
  3496.    argc--;
  3497.  
  3498.    qsort((char *)argv, argc, sizeof(char *), compare1);
  3499.    result = (char **)bsearch(key, argv, argc, sizeof(char *), compare2);
  3500.    if (result != NULL) {
  3501.       printf("result = <%s>\n", *result);
  3502.    }
  3503.    else
  3504.       printf("result is null\n");
  3505.    return 0;
  3506.  
  3507.    /****************************************************************************
  3508.       If the program name is progname and you enter:
  3509.  
  3510.       progname where is PATH in this phrase?
  3511.  
  3512.       The output should be:
  3513.  
  3514.       result = <PATH>
  3515.    ****************************************************************************/
  3516. }
  3517.  
  3518.  
  3519. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3520.  
  3521. Example of bsearch 
  3522.  
  3523.      lfind - lsearch - Find Key in Array 
  3524.      qsort - Sort Array 
  3525.      <stdlib.h> 
  3526.  
  3527.  
  3528. ΓòÉΓòÉΓòÉ 4.18. _cabs - Calculate Absolute Value of Complex Number ΓòÉΓòÉΓòÉ
  3529.  
  3530.  
  3531. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3532.  
  3533. #include <math.h>
  3534. double _cabs(struct complex z);
  3535.  
  3536.  
  3537. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3538.  
  3539. Language Level:  Extension 
  3540.  
  3541. _cabs calculates the absolute value of a complex number.  This complex number 
  3542. is represented as a structure with the tag complex containing the real and 
  3543. imaginary parts.  The following type declaration is in <math.h>: 
  3544.  
  3545.    struct complex {double x,y;};
  3546.  
  3547. A call to _cabs is equivalent to: 
  3548.  
  3549.    sqrt(z.x * z.x + z.y * z.y)
  3550.  
  3551. Note:  For portability across SAA systems, use the SAA function hypot. to 
  3552. replace _cabs. 
  3553.  
  3554. Return Value 
  3555. _cabs returns the absolute value as a double value.  If an overflow results, 
  3556. _cabs calls the _matherr routine and, if necessary, sets errno to ERANGE and 
  3557. returns the value HUGE_VAL. 
  3558.  
  3559.  
  3560. ΓòÉΓòÉΓòÉ <hidden> Example of _cabs ΓòÉΓòÉΓòÉ
  3561.  
  3562. /************************************************************************
  3563.  
  3564. The following program computes the absolute value of the complex number (3.0, 
  3565. 4.0). 
  3566.  
  3567. ************************************************************************/
  3568.  
  3569. #include <math.h>
  3570. #include <stdio.h>
  3571.  
  3572. int main(void)
  3573. {
  3574.    struct complex value;
  3575.    double d;
  3576.  
  3577.    value.x = 3.0;
  3578.    value.y = 4.0;
  3579.    d = _cabs(value);
  3580.    printf("The complex absolute value of %f and %f is %f\n", value.x, value.y, d
  3581.       );
  3582.    return 0;
  3583.  
  3584.    /****************************************************************************
  3585.       The output should be:
  3586.  
  3587.       The complex absolute value of 3.000000 and 4.000000 is 5.000000
  3588.    ****************************************************************************/
  3589. }
  3590.  
  3591.  
  3592. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3593.  
  3594. Example of _cabs 
  3595.  
  3596.      abs - Calculate Integer Absolute Value 
  3597.      fabs - Calculate Floating-Point Absolute Value 
  3598.      hypot - Calculate Hypotenuse 
  3599.      labs - Calculate Absolute Value of Long Integer 
  3600.      _matherr - Process Math Library Errors 
  3601.      sqrt - Calculate Square Root 
  3602.      <math.h> 
  3603.  
  3604.  
  3605. ΓòÉΓòÉΓòÉ 4.19. calloc - Reserve and Initialize Storage ΓòÉΓòÉΓòÉ
  3606.  
  3607.  
  3608. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3609.  
  3610. #include <stdlib.h>  /* also in <malloc.h> */
  3611. void *calloc(size_t num, size_t size);
  3612.  
  3613.  
  3614. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3615.  
  3616. Language Level: ANSI, SAA, POSIX, XPG4 
  3617.  
  3618. calloc reserves storage space for an array of num elements, each of length size 
  3619. bytes. calloc then gives all the bits of each element an initial value of 0. 
  3620.  
  3621. Heap-specific and tiled versions of this function (_ucalloc and _tcalloc) are 
  3622. also available.  calloc always allocates memory from the default heap.  You can 
  3623. also use the debug version of calloc, _debug_calloc, to debug memory problems. 
  3624.  
  3625. Return Value calloc returns a pointer to the reserved space.  The storage space 
  3626. to which the return value points is suitably aligned for storage of any type of 
  3627. object.  To get a pointer to a type, use a type cast on the return value.  The 
  3628. return value is NULL if there is not enough storage, or if num or size is 0. 
  3629.  
  3630.  
  3631. ΓòÉΓòÉΓòÉ <hidden> Example of calloc ΓòÉΓòÉΓòÉ
  3632.  
  3633. /************************************************************************
  3634.  
  3635. This example prompts for the number of array entries required and then reserves 
  3636. enough space in storage for the entries. If calloc is successful, the example 
  3637. prints out each entry;  otherwise, it prints out an error. 
  3638.  
  3639. ************************************************************************/
  3640.  
  3641. #include <stdio.h>
  3642. #include <stdlib.h>
  3643.  
  3644. int main(void)
  3645. {
  3646.    long *array;                             /* start of the array             */
  3647.    long *index;                             /* index variable                 */
  3648.    int i;                                   /* index variable                 */
  3649.    int num;                                 /* number of entries of the array */
  3650.  
  3651.    printf("Enter the size of the array\n");
  3652.    scanf("%i", &num);
  3653.  
  3654.    /* allocate num entries                                                    */
  3655.  
  3656.    if ((index = array = calloc(num, sizeof(long))) != NULL) {
  3657.       for (i = 0; i < num; ++i)             /* put values in array            */
  3658.          *index++ = i;                      /* using pointer notation         */
  3659.       for (i = 0; i < num; ++i)             /* print the array out            */
  3660.          printf("array[ %i ] = %i\n", i, array[i]);
  3661.    }
  3662.    else {                                                 /* out of storage   */
  3663.       perror("Out of storage");
  3664.       abort();
  3665.    }
  3666.    return 0;
  3667.  
  3668.    /****************************************************************************
  3669.       The output should be similar to :
  3670.  
  3671.       Enter the size of the array
  3672.       3
  3673.       array[ 0 ] = 0
  3674.       array[ 1 ] = 1
  3675.       array[ 2 ] = 2
  3676.    ****************************************************************************/
  3677. }
  3678.  
  3679.  
  3680. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3681.  
  3682. Example of calloc 
  3683.  
  3684.      _alloca - Temporarily Reserve Storage Block 
  3685.      _debug_calloc - Allocate and Initialize Memory 
  3686.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  3687.      _debug_ucalloc - Reserve and Initialize Memory from User Heap 
  3688.      free - Release Storage Blocks 
  3689.      malloc - Reserve Storage Block 
  3690.      realloc - Change Reserved Storage Block Size 
  3691.      _tcalloc - Reserve Tiled Storage Block 
  3692.      _ucalloc - Reserve and Initialize Memory from User Heap 
  3693.      <malloc.h> 
  3694.      <stdlib.h> 
  3695.      Managing Memory in the Programming Guide 
  3696.  
  3697.  
  3698. ΓòÉΓòÉΓòÉ 4.20. cclass - Return Characters in Character Class ΓòÉΓòÉΓòÉ
  3699.  
  3700.  
  3701. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3702.  
  3703. #include <collate.h>
  3704. int cclass(char *class, collel_t **list);
  3705.  
  3706.  
  3707. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3708.  
  3709. Language Level:  Extension 
  3710.  
  3711. cclass finds all the collating elements of the character class, and stores them 
  3712. in an array. It then updates the list to point to the first element of the 
  3713. array of found collating elements. The list is valid until the next call to 
  3714. setlocale. 
  3715.  
  3716. cclass supports POSIX.2 character classes and user-defined character classes. 
  3717.  
  3718. Return Value 
  3719. cclass returns the number of elements in the list and sets a pointer to point 
  3720. to the list. If the class does not exist in the LC_CTYPE category of the 
  3721. current locale, cclass returns -1. 
  3722.  
  3723.  
  3724. ΓòÉΓòÉΓòÉ <hidden> Example of cclass ΓòÉΓòÉΓòÉ
  3725.  
  3726. /************************************************************************
  3727.  
  3728. This example finds all the collating elements that belong to the digit class. 
  3729. It then prints how many elements were found in that class and the weight 
  3730. (collating value) of each element. 
  3731.  
  3732. ************************************************************************/
  3733.  
  3734. #include <stdio.h>
  3735. #include <collate.h>
  3736.  
  3737. int main(void)
  3738. {
  3739.    collel_t *list;      /* ptr to the digit class collation weights */
  3740.    int       weights;   /* no. of class collation weights found     */
  3741.    int       i;
  3742.  
  3743.    weights = cclass("digit", &list);
  3744.  
  3745.    printf("weights = %d\n", weights);
  3746.    for (i = 0; i < weights; i++)
  3747.       printf(" *(list + %d) = %d\n", i, *(list  + i));
  3748.    return 0;
  3749.  
  3750.    /****************************************************************************
  3751.       The output should be similar to :
  3752.  
  3753.       weights = 10
  3754.        *(list + 0) = 48
  3755.        *(list + 1) = 49
  3756.        *(list + 2) = 50
  3757.        *(list + 3) = 51
  3758.        *(list + 4) = 52
  3759.        *(list + 5) = 53
  3760.        *(list + 6) = 54
  3761.        *(list + 7) = 55
  3762.        *(list + 8) = 56
  3763.        *(list + 9) = 57
  3764.    ****************************************************************************/
  3765. }
  3766.  
  3767.  
  3768. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3769.  
  3770. Example of cclass 
  3771.  
  3772.      collequiv - Return List of Equivalent Collating Elements 
  3773.      collorder - Return List of Collating Elements 
  3774.      collrange - Calculate Range of Collating Elements 
  3775.      colltostr - Return String for Collating Element 
  3776.      getmccoll - Get Next Collating Element from String 
  3777.      getwmccoll - Get Next Collating Element from Wide String 
  3778.      ismccollel - Identify Multi-Character Collating Element 
  3779.      maxcoll - Return Maximum Collating Element 
  3780.      setlocale - Set Locale 
  3781.      strtocoll - Return Collating Element for String 
  3782.      wctype - Get Handle for Character Property Classification 
  3783.      <collate.h> 
  3784.      <locale.h> 
  3785.  
  3786.  
  3787. ΓòÉΓòÉΓòÉ 4.21. ceil - Find Integer >= Argument ΓòÉΓòÉΓòÉ
  3788.  
  3789.  
  3790. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3791.  
  3792. #include <math.h>
  3793. double ceil(double x);
  3794.  
  3795.  
  3796. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3797.  
  3798. Language Level: ANSI, SAA, POSIX, XPG4 
  3799.  
  3800. ceil computes the smallest integer that is greater than or equal to x. 
  3801.  
  3802. Return Value 
  3803. ceil returns the integer as a double value. 
  3804.  
  3805.  
  3806. ΓòÉΓòÉΓòÉ <hidden> Example of ceil ΓòÉΓòÉΓòÉ
  3807.  
  3808. /************************************************************************
  3809.  
  3810. This example sets y to the smallest integer greater than 1.05, and then to the 
  3811. smallest integer greater than -1.05.  The results are 2.0 and -1.0, 
  3812. respectively. 
  3813.  
  3814. ************************************************************************/
  3815.  
  3816. #include <stdio.h>
  3817. #include <math.h>
  3818.  
  3819. int main(void)
  3820. {
  3821.    double y,z;
  3822.  
  3823.    y = ceil(1.05);                                        /* y = 2.0          */
  3824.    printf("ceil( 1.05 ) = %5.f\n", y);
  3825.    z = ceil(-1.05);                                       /* z = -1.0         */
  3826.    printf("ceil( -1.05 ) = %5.f\n", z);
  3827.    return 0;
  3828.  
  3829.    /****************************************************************************
  3830.       The output should be:
  3831.  
  3832.       ceil( 1.05 ) =     2
  3833.       ceil( -1.05 ) =    -1
  3834.    ****************************************************************************/
  3835. }
  3836.  
  3837.  
  3838. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3839.  
  3840. Example of ceil 
  3841.  
  3842.      floor - Integer <= Argument 
  3843.      fmod - Calculate Floating-Point Remainder 
  3844.      <math.h> 
  3845.  
  3846.  
  3847. ΓòÉΓòÉΓòÉ 4.22. _cgets - Read String of Characters from Keyboard ΓòÉΓòÉΓòÉ
  3848.  
  3849.  
  3850. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3851.  
  3852. #include <conio.h>
  3853. char *_cgets(char *str);
  3854.  
  3855.  
  3856. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3857.  
  3858. Language Level:  Extension 
  3859.  
  3860. _cgets reads a string of characters directly from the keyboard and stores the 
  3861. string and its length in the location pointed to by str. 
  3862.  
  3863. _cgets continues to read characters until it meets a carriage return followed 
  3864. by a line feed (CR-LF) or until it reads the specified number of characters. It 
  3865. stores the string starting at str[2]. If _cgets reads a CR-LF combination, it 
  3866. replaces this combination with a null character ('\0') before storing the 
  3867. string. _cgets then stores the actual length of the string in the second array 
  3868. element, str[1]. 
  3869.  
  3870. The str variable must be a pointer to a character array. The first element of 
  3871. the array, str[0], must contain the maximum length, in characters, of the 
  3872. string to be read.  The array must have enough elements to hold the string, a 
  3873. final null character, and 2 additional bytes. 
  3874.  
  3875. Return Value 
  3876. If successful, _cgets returns a pointer to the actual start of the string, 
  3877. str[2]. Otherwise, _cgets returns NULL. 
  3878.  
  3879.  
  3880. ΓòÉΓòÉΓòÉ <hidden> Example of _cgets ΓòÉΓòÉΓòÉ
  3881.  
  3882. /************************************************************************
  3883.  
  3884. This example creates a buffer and initializes the first byte to the size of the 
  3885. buffer. The program then accepts an input string using _cgets and displays the 
  3886. size and text of that string. 
  3887.  
  3888. ************************************************************************/
  3889.  
  3890. #include <conio.h>
  3891. #include <stdio.h>
  3892.  
  3893. void nothing(void)
  3894. {
  3895. }
  3896.  
  3897. int main(void)
  3898. {
  3899.    char buffer[82] =  { 84,0 };
  3900.    char *buffer2;
  3901.    int i;
  3902.  
  3903.    _cputs("\nPress any key to continue.");
  3904.    printf("\n");
  3905.    while (0 == _kbhit()) {
  3906.       nothing();
  3907.    }
  3908.    _getch();
  3909.    _cputs("\nEnter a line of text:");
  3910.    printf("\n");
  3911.    buffer2 = _cgets(buffer);
  3912.    printf("\nText entered was: %s", buffer2);
  3913.    return 0;
  3914.  
  3915.    /****************************************************************************
  3916.       The output should be similar to:
  3917.  
  3918.       Press any key to continue.
  3919.  
  3920.       Enter a line of text:
  3921.       This is a simple test.
  3922.       Text entered was: This is a simple test.
  3923.  
  3924.    ****************************************************************************/
  3925. }
  3926.  
  3927.  
  3928. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  3929.  
  3930. Example of _cgets 
  3931.  
  3932.      _cputs - Write String to Screen 
  3933.      fgets - Read a String 
  3934.      gets - Read a Line 
  3935.      _getch - _getche - Read Character from Keyboard 
  3936.      <conio.h> 
  3937.  
  3938.  
  3939. ΓòÉΓòÉΓòÉ 4.23. chdir - Change Current Working Directory ΓòÉΓòÉΓòÉ
  3940.  
  3941.  
  3942. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  3943.  
  3944. #include <direct.h>
  3945. int chdir(char *pathname);
  3946.  
  3947.  
  3948. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  3949.  
  3950. Language Level:  XPG4, Extension 
  3951.  
  3952. chdir causes the current working directory to change to the directory specified 
  3953. by pathname.  The pathname must refer to an existing directory. 
  3954.  
  3955. Note:  This function can change the current working directory on any drive.  It 
  3956. cannot change the default drive.  For example, if A:\BIN is the current working 
  3957. directory and A: is the default drive, the following changes only the current 
  3958. working directory on drive C:. 
  3959.  
  3960.    chdir ("c:\\emp");
  3961.  
  3962. A: is still the default drive. 
  3963.  
  3964. An alternative to this function is the DosSetCurrentDir API call. 
  3965.  
  3966. Note:  In earlier releases of C Set ++, chdir began with an underscore 
  3967. (_chdir). Because it is defined by the X/Open standard, the underscore has been 
  3968. removed. For compatibility, VisualAge C++ will map _chdir to chdir for you. 
  3969.  
  3970. Return Value 
  3971. chdir returns a value of 0 if the working directory was successfully changed. A 
  3972. return value of -1 indicates an error; chdir sets errno to ENOENT, showing that 
  3973. chdir cannot find the specified path name.  No error occurs if pathname 
  3974. specifies the current working directory. 
  3975.  
  3976.  
  3977. ΓòÉΓòÉΓòÉ <hidden> Example of chdir ΓòÉΓòÉΓòÉ
  3978.  
  3979. /************************************************************************
  3980.  
  3981. This example changes the current working directory to the root directory, and 
  3982. then to the \red\green\blue directory. 
  3983.  
  3984. ************************************************************************/
  3985.  
  3986. #include <direct.h>
  3987. #include <stdio.h>
  3988.  
  3989. int main(void)
  3990. {
  3991.    printf("Changing to the root directory.\n");
  3992.    if (chdir("\\"))
  3993.       perror(NULL);
  3994.    else
  3995.       printf("Changed to the root directory.\n\n");
  3996.    printf("Changing to directory '\\red\\green\\blue'.\n");
  3997.    if (chdir("\\red\\green\\blue"))
  3998.       perror(NULL);
  3999.    else
  4000.       printf("Changed to directory '\\red\\green\\blue'.\n");
  4001.    return 0;
  4002.  
  4003.    /****************************************************************************
  4004.       If directory \red\green\blue exists, the output should be:
  4005.  
  4006.       Changing to the root directory.
  4007.       Changed to the root directory.
  4008.  
  4009.       Changing to directory '\red\green\blue'.
  4010.       Changed to directory '\red\green\blue'.
  4011.    ****************************************************************************/
  4012. }
  4013.  
  4014.  
  4015. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4016.  
  4017. Example of chdir 
  4018.  
  4019.      _chdrive - Change Current Working Drive 
  4020.      _getcwd - Get Path Name of Current Directory 
  4021.      _getdcwd - Get Full Path Name of Current Directory 
  4022.      _getdrive - Get Current Working Drive 
  4023.      system - Invoke the Command Processor 
  4024.      mkdir - Create New Directory 
  4025.      rmdir - Remove Directory 
  4026.      system - Invoke the Command Processor 
  4027.      <direct.h> 
  4028.  
  4029.  
  4030. ΓòÉΓòÉΓòÉ 4.24. _chdrive - Change Current Working Drive ΓòÉΓòÉΓòÉ
  4031.  
  4032.  
  4033. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4034.  
  4035. #include <direct.h>
  4036. int _chdrive(int drive);
  4037.  
  4038.  
  4039. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4040.  
  4041. Language Level:  Extension 
  4042.  
  4043. _chdrive changes the current working drive to the drive specified.  The drive 
  4044. variable is an integer value representing the number of the new working drive 
  4045. (A: is 1, B: is 2, and so on). 
  4046.  
  4047. To change the default drive, include <os2.h>, define INCL_DOSFILEMGR, and use 
  4048. DosSetDefaultDisk to pass the appropriate command to the operating system. You 
  4049. can also use DosQueryCurrentDisk to query the disk. For more information, refer 
  4050. to the Control Program Guide and Reference. 
  4051.  
  4052. Return Value 
  4053. _chdrive returns 0 if it is successful in changing the working drive. A return 
  4054. value of -1 indicates an error; _chdrive sets errno to EOS2ERR. 
  4055.  
  4056.  
  4057. ΓòÉΓòÉΓòÉ <hidden> Example of _chdrive ΓòÉΓòÉΓòÉ
  4058.  
  4059. /************************************************************************
  4060.  
  4061. This example uses _chdrive to change the current working drive to C:. 
  4062.  
  4063. ************************************************************************/
  4064.  
  4065. #include <direct.h>
  4066. #include <stdio.h>
  4067.  
  4068. int main(void)
  4069. {
  4070.    if (_chdrive(3))
  4071.       printf("Cannot change current working drive to 'C' drive.\n");
  4072.    else {
  4073.       printf("Current working drive changed to ");
  4074.       printf("'%c' drive.\n", ('A'+_getdrive()-1));
  4075.    }
  4076.    return 0;
  4077.  
  4078.    /****************************************************************************
  4079.       The output should be similar to :
  4080.  
  4081.       Current working drive changed to 'C' drive.
  4082.    ****************************************************************************/
  4083. }
  4084.  
  4085.  
  4086. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4087.  
  4088. Example of _chdrive 
  4089.  
  4090.      chdir - Change Current Working Directory 
  4091.      _getcwd - Get Path Name of Current Directory 
  4092.      _getdcwd - Get Full Path Name of Current Directory 
  4093.      _getdrive - Get Current Working Drive 
  4094.      mkdir - Create New Directory 
  4095.      rmdir - Remove Directory 
  4096.      <direct.h> 
  4097.  
  4098.  
  4099. ΓòÉΓòÉΓòÉ 4.25. chmod - Change File Permission Setting ΓòÉΓòÉΓòÉ
  4100.  
  4101.  
  4102. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4103.  
  4104. #include <io.h>
  4105. #include <sys\stat.h>
  4106. int chmod(char *pathname, int pmode);
  4107.  
  4108.  
  4109. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4110.  
  4111. Language Level:  XPG4, Extension 
  4112.  
  4113. chmod changes the permission setting of the file specified by pathname. The 
  4114. permission setting controls access to the file for reading or writing. You can 
  4115. use chmod only if the file is closed. 
  4116.  
  4117. The pmode expression contains one or both of the constants S_IWRITE and 
  4118. S_IREAD, defined in <sys\stat.h>. The meanings of the values of pmode are: 
  4119.  
  4120.  Value                   Meaning 
  4121.  S_IREAD                 Reading permitted 
  4122.  S_IWRITE                Writing permitted 
  4123.  S_IREAD | S_IWRITE      Reading and writing permitted. 
  4124.  
  4125.  If you do not give permission to write to the file, chmod makes the file 
  4126.  read-only. With the OS/2 operating system, all files are readable; you cannot 
  4127.  give write-only permission. Thus, the modes S_IWRITE and S_IREAD | S_IWRITE 
  4128.  set the same permission. 
  4129.  
  4130.  Specifying a pmode of S_IREAD is similar to making a file read-only with the 
  4131.  ATTRIB system command. 
  4132.  
  4133.  Note:  In earlier releases of C Set ++, chmod began with an underscore 
  4134.  (_chmod). Because it is defined by the X/Open standard, the underscore has 
  4135.  been removed. For compatibility, VisualAge C++ will map _chmod to chmod for 
  4136.  you. 
  4137.  
  4138.  Return Value 
  4139.  chmod returns the value 0 if it successfully changes the permission setting. 
  4140.  A return value of -1 shows an error; chmod sets errno to one of the following 
  4141.  values: 
  4142.  
  4143.  Value          Meaning 
  4144.  ENOENT         The system cannot find the file or the path that you specified, 
  4145.                 or the file name was incorrect. 
  4146.  EOS2ERR        The call to the operating system was not successful. 
  4147.  EINVAL         The mode specified was not valid. 
  4148.  
  4149.  
  4150. ΓòÉΓòÉΓòÉ <hidden> Example of chmod ΓòÉΓòÉΓòÉ
  4151.  
  4152. /************************************************************************
  4153.  
  4154. This example opens the file chmod.dat for writing after checking the file to 
  4155. see if writing is permissible. It then writes from the buffer to the opened 
  4156. file. This program takes file names passed as arguments and sets each to 
  4157. read-only. 
  4158.  
  4159. ************************************************************************/
  4160.  
  4161. #include <sys\stat.h>
  4162. #include <io.h>
  4163. #include <stdio.h>
  4164. #include <stdlib.h>
  4165.  
  4166. int main(void)
  4167. {
  4168.    if (-1 == access("chmod.dat", 00))        /* Check if file exists.         */
  4169.       {
  4170.       printf("\nCreating chmod.dat.\n");
  4171.       system("echo Sample Program > chmod.dat");
  4172.       printf("chmod chmod.dat to be readonly.\n");
  4173.       if (-1 == chmod("chmod.dat", S_IREAD))
  4174.          perror("Chmod failed");
  4175.       if (-1 == access("chmod.dat", 02))
  4176.          printf("File chmod.dat is now readonly.\n\n");
  4177.       printf("Run this program again to erase chmod.dat.\n\n");
  4178.    }
  4179.    else {
  4180.       printf("\nFile chmod.dat exist.\n");
  4181.       printf("chmod chmod.dat to become writable.\n");
  4182.       if (-1 == chmod("chmod.dat", S_IWRITE))
  4183.          perror("Chmod failed");
  4184.       system("erase  chmod.dat");
  4185.       printf("File chmod.dat removed.\n\n");
  4186.    }
  4187.    return 0;
  4188.  
  4189.    /****************************************************************************
  4190.       If chmod.dat does not exist, the output should be :
  4191.  
  4192.        Creating chmod.dat.
  4193.        chmod chmod.dat to be readonly.
  4194.        File chmod.dat is now readonly.
  4195.  
  4196.        Run this program again to erase chmod.dat.
  4197.    ****************************************************************************/
  4198. }
  4199.  
  4200.  
  4201. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4202.  
  4203. Example of chmod 
  4204.  
  4205.      access - Determine Access Mode 
  4206.      _sopen - Open Shared File 
  4207.      umask - Sets File Mask of Current Process 
  4208.      <sys\stat.h> 
  4209.      <io.h> 
  4210.  
  4211.  
  4212. ΓòÉΓòÉΓòÉ 4.26. _chsize - Alter Length of File ΓòÉΓòÉΓòÉ
  4213.  
  4214.  
  4215. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4216.  
  4217. #include <io.h>
  4218. int _chsize(int handle, long size);
  4219.  
  4220.  
  4221. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4222.  
  4223. Language Level:  Extension 
  4224.  
  4225. _chsize lengthens or cuts off the file associated with handle to the length 
  4226. specified by size. You must open the file in a mode that permits writing. 
  4227. _chsize adds null characters (\0) when it lengthens the file. When _chsize cuts 
  4228. off the file, it erases all data from the end of the shortened file to the end 
  4229. of the original file. 
  4230.  
  4231. Return Value 
  4232. _chsize returns the value 0 if it successfully changes the file size. A return 
  4233. value of -1 shows an error; _chsize sets errno to one of the following values: 
  4234.  
  4235.  Value          Meaning 
  4236.  EACCESS        The specified file is locked against access. 
  4237.  EBADF          The file handle is not valid, or the file is not open for 
  4238.                 writing. 
  4239.  ENOSPC         There is no space left on the device. 
  4240.  EOS2ERR        The call to the operating system was not successful. 
  4241.  
  4242.  
  4243. ΓòÉΓòÉΓòÉ <hidden> Example of _chsize ΓòÉΓòÉΓòÉ
  4244.  
  4245. /************************************************************************
  4246.  
  4247. This example opens a file named sample.dat and returns the current length of 
  4248. that file. It then alters the size of sample.dat and returns the new length of 
  4249. that file. 
  4250.  
  4251. ************************************************************************/
  4252.  
  4253. #include <io.h>
  4254. #include <stdio.h>
  4255. #include <stdlib.h>
  4256. #include <fcntl.h>
  4257.  
  4258. int main(void)
  4259. {
  4260.    long length;
  4261.    int fh;
  4262.  
  4263.    printf("\nCreating sample.dat.\n");
  4264.    system("echo Sample Program > sample.dat");
  4265.    if (-1 == (fh = open("sample.dat", O_RDWR|O_APPEND))) {
  4266.       printf("Unable to open sample.dat.\n");
  4267.       return EXIT_FAILURE;
  4268.    }
  4269.    if (-1 == (length = filelength(fh))) {
  4270.       printf("Unable to determine length of sample.dat.\n");
  4271.       return EXIT_FAILURE;
  4272.    }
  4273.    printf("Current length of sample.dat is %d.\n", length);
  4274.    printf("Changing the length of sample.dat to 20.\n");
  4275.    if (-1 == (_chsize(fh, 20))) {
  4276.       perror("chsize failed");
  4277.       return EXIT_FAILURE;
  4278.    }
  4279.    if (-1 == (length = _filelength(fh))) {
  4280.       printf("Unable to determine length of sample.dat.\n");
  4281.       return EXIT_FAILURE;
  4282.    }
  4283.    printf("New length of sample.dat is %d.\n", length);
  4284.    close(fh);
  4285.    return 0;
  4286.  
  4287.    /****************************************************************************
  4288.       The output should be similar to :
  4289.  
  4290.        Creating sample.dat.
  4291.        Current length of sample.dat is 17.
  4292.        Changing the length of sample.dat to 20.
  4293.        New length of sample.dat is 20.
  4294.    ****************************************************************************/
  4295. }
  4296.  
  4297.  
  4298. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4299.  
  4300. Example of _chsize 
  4301.  
  4302.      _filelength - Determine File Length 
  4303.      lseek - Move File Pointer 
  4304.      <io.h> 
  4305.  
  4306.  
  4307. ΓòÉΓòÉΓòÉ 4.27. clearerr - Reset Error Indicators. ΓòÉΓòÉΓòÉ
  4308.  
  4309.  
  4310. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4311.  
  4312. #include <stdio.h>
  4313. void clearerr (FILE *stream);
  4314.  
  4315.  
  4316. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4317.  
  4318. Language Level: ANSI, SAA, POSIX, XPG4 
  4319.  
  4320. The clearerr function resets the error indicator and end-of-file indicator for 
  4321. the specified stream. Once set, the indicators for a specified stream remain 
  4322. set until your program calls clearerr or rewind. fseek also clears the 
  4323. end-of-file indicator. 
  4324.  
  4325. Return Value 
  4326. There is no return value. 
  4327.  
  4328.  
  4329. ΓòÉΓòÉΓòÉ <hidden> Example of clearerr ΓòÉΓòÉΓòÉ
  4330.  
  4331. /************************************************************************
  4332.  
  4333. This example reads a data stream and then checks that a read error has not 
  4334. occurred. 
  4335.  
  4336. ************************************************************************/
  4337.  
  4338. #include <stdio.h>
  4339. #include <stdlib.h>
  4340.  
  4341. FILE *stream;
  4342. int c;
  4343.  
  4344. int main(void)
  4345. {
  4346.    if (NULL != (stream = fopen("file.dat", "r"))) {
  4347.       if (EOF == (c = getc(stream))) {
  4348.          if (feof(stream)) {
  4349.             perror("Read error");
  4350.             clearerr(stream);
  4351.          }
  4352.       }
  4353.    }
  4354.    return 0;
  4355.  
  4356.    /****************************************************************************
  4357.       If file.dat is an empty file, the output should be:
  4358.  
  4359.       Read error: Attempted to read past end-of-file.
  4360.  
  4361.    ****************************************************************************/
  4362. }
  4363.  
  4364.  
  4365. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4366.  
  4367. Example of clearerr 
  4368.  
  4369.      feof - Test End-of-File Indicator 
  4370.      ferror - Test for Read/Write Errors 
  4371.      perror - Print Error Message 
  4372.      rewind - Adjust Current File Position 
  4373.      strerror - Set Pointer to Runtime Error Message 
  4374.      _strerror - Set Pointer to System Error String 
  4375.      <stdio.h> 
  4376.  
  4377.  
  4378. ΓòÉΓòÉΓòÉ 4.28. _clear87 - Clear Floating-Point Status Word ΓòÉΓòÉΓòÉ
  4379.  
  4380.  
  4381. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4382.  
  4383. #include <float.h>  /* also in <builtin.h> */
  4384. unsigned int _clear87(void);
  4385.  
  4386.  
  4387. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4388.  
  4389. Language Level:  Extension 
  4390.  
  4391. _clear87 gets the floating-point status word and then clears it. The 
  4392. floating-point status word is a combination of the numeric coprocessor status 
  4393. word and other conditions that the numeric exception handler detects, such as 
  4394. floating-point stack overflow and underflow. 
  4395.  
  4396. _clear87 affects only the current thread. It does not affect any other threads 
  4397. that may be processing. 
  4398.  
  4399. Return Value 
  4400. The bits in the value returned reflect the floating-point status before the 
  4401. call to _clear87 was made. 
  4402.  
  4403.  
  4404. ΓòÉΓòÉΓòÉ <hidden> Example of _clear87 ΓòÉΓòÉΓòÉ
  4405.  
  4406. /************************************************************************
  4407.  
  4408. This example takes a number close to 0 as a double and assigns it to a float. 
  4409. The result is a loss of significance, y becomes a denormal number, and the 
  4410. underflow bit of the floating-point status word is set. _clear87 gets the 
  4411. current floating-point status word and then clears it, and printf prints it as 
  4412. immediate data. The result shows the change in the floating-point word because 
  4413. of the loss of significance. 
  4414.  
  4415. The program then assigns the denormal y to another variable, causing the 
  4416. denormal bit to be set in the floating-point status word. Again, _clear87 gets 
  4417. the current status word and clears it, and printf prints it to the screen. 
  4418.  
  4419. ************************************************************************/
  4420.  
  4421. #include <stdio.h>
  4422. #include <float.h>
  4423.  
  4424. double a = 1e-40;
  4425. double b;
  4426. float y;
  4427.  
  4428. int main(void)
  4429. {
  4430.    unsigned int statword;
  4431.    unsigned int old_cw;
  4432.  
  4433.    /*  change control word to mask all exceptions                             */
  4434.  
  4435.    _control87(0x037f, 0xffff);
  4436.  
  4437.    /* Assignment of the double to the float y is inexact;                     */
  4438.    /* the underflow bit is set.                                               */
  4439.  
  4440.    y = a;
  4441.    statword = _clear87();
  4442.    printf("floating-point status = 0x%.4x after underflow\n", statword);
  4443.    statword = _status87();
  4444.    printf("cleared floating-point status word = 0x%.4x\n", statword);
  4445.  
  4446.    /*  reset floating point status word                                       */
  4447.  
  4448.    _fpreset();
  4449.  
  4450.    /*  change control word to mask all exception                              */
  4451.  
  4452.    _control87(0x037f, 0xffff);
  4453.  
  4454.    /* Reassigning the denormal y to the double b                              */
  4455.    /*   causes the denormal bit to be set.                                    */
  4456.  
  4457.    b = y;
  4458.    statword = _clear87();
  4459.    printf("floating-point status = 0x%.4x for denormal\n", statword);
  4460.  
  4461.    /*  reset floating point status word                                       */
  4462.  
  4463.    _fpreset();
  4464.    return 0;
  4465.  
  4466.    /****************************************************************************
  4467.       The output should be:
  4468.  
  4469.       floating-point status = 0x0030 after underflow
  4470.       cleared floating-point status word = 0x0000
  4471.       floating-point status = 0x0002 for denormal
  4472.    ****************************************************************************/
  4473. }
  4474.  
  4475.  
  4476. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4477.  
  4478. Example of _clear87 
  4479.  
  4480.      _control87 - Set Floating-Point Control Word 
  4481.      _status87 - Get Floating-Point Status Word 
  4482.      _fpreset - Reset Floating-Point Unit 
  4483.      <float.h> 
  4484.  
  4485.  
  4486. ΓòÉΓòÉΓòÉ 4.29. clock  - Determine Processor Time ΓòÉΓòÉΓòÉ
  4487.  
  4488.  
  4489. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4490.  
  4491. #include <time.h>
  4492. clock_t clock(void);
  4493.  
  4494.  
  4495. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4496.  
  4497. Language Level: ANSI, SAA, XPG4 
  4498.  
  4499. clock returns an approximation of the processor time used by the program since 
  4500. the beginning of an implementation-defined time-period that is related to the 
  4501. program invocation. To obtain the time in seconds, divide the value returned by 
  4502. clock by the value of the macro CLOCKS_PER_SEC. 
  4503.  
  4504. Return Value 
  4505.  
  4506. If the value of the processor time is not available or cannot be represented, 
  4507. clock returns the value (clock_t)-1. 
  4508.  
  4509. To measure the time spent in a program, call clock at the start of the program, 
  4510. and subtract its return value from the value returned by subsequent calls to 
  4511. clock. 
  4512.  
  4513.  
  4514. ΓòÉΓòÉΓòÉ <hidden> Example of clock ΓòÉΓòÉΓòÉ
  4515.  
  4516. /************************************************************************
  4517.  
  4518. This example prints the time elapsed since the program was invoked. 
  4519.  
  4520. ************************************************************************/
  4521.  
  4522. #include <time.h>
  4523. #include <stdio.h>
  4524.  
  4525. double time1,time2,timedif;               /* use doubles to show small values */
  4526. int i;
  4527.  
  4528. int main(void)
  4529. {
  4530.    time1 = (double)clock();               /* get initial time in seconds      */
  4531.    time1 = time1/CLOCKS_PER_SEC;
  4532.  
  4533.    /* use some CPU time                                                       */
  4534.  
  4535.    for (i = 0; i < 5000000; i++) {
  4536.       int j;
  4537.  
  4538.       j = i;
  4539.    }
  4540.    time2 = (double)clock();                /* call clock a second time        */
  4541.    time2 = time2/CLOCKS_PER_SEC;
  4542.    timedif = time2-time1;
  4543.    printf("The elapsed time is %f seconds\n", timedif);
  4544.    return 0;
  4545.  
  4546.    /****************************************************************************
  4547.       The output should be similar to:
  4548.  
  4549.       The elapsed time is 0.969000 seconds
  4550.    ****************************************************************************/
  4551. }
  4552.  
  4553.  
  4554. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4555.  
  4556. Example of clock 
  4557.  
  4558.      difftime - Compute Time Difference 
  4559.      time - Determine Current Time 
  4560.      <time.h> 
  4561.  
  4562.  
  4563. ΓòÉΓòÉΓòÉ 4.30. close - Close File Associated with Handle ΓòÉΓòÉΓòÉ
  4564.  
  4565.  
  4566. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4567.  
  4568. #include <io.h>
  4569. int close(int handle);
  4570.  
  4571.  
  4572. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4573.  
  4574. Language Level:  XPG4, Extension 
  4575.  
  4576. close closes the file associated with the handle. Use close if you opened the 
  4577. handle with open. If you opened the handle with fopen, use fclose to close it. 
  4578.  
  4579. Note:  In earlier releases of C Set ++, close began with an underscore 
  4580. (_close). Because it is defined by the X/Open standard, the underscore has been 
  4581. removed. For compatibility, VisualAge C++ will map _close to close for you. 
  4582.  
  4583. Return Value 
  4584. close returns 0 if it successfully closes the file. A return value of -1 shows 
  4585. an error, and close sets errno to EBADF, showing an incorrect file handle 
  4586. argument. 
  4587.  
  4588.  
  4589. ΓòÉΓòÉΓòÉ <hidden> Example of close ΓòÉΓòÉΓòÉ
  4590.  
  4591. /************************************************************************
  4592.  
  4593. This example opens the file edclose.dat and then closes it using the close 
  4594. function. 
  4595.  
  4596. ************************************************************************/
  4597.  
  4598. #include <io.h>
  4599. #include <stdio.h>
  4600. #include <fcntl.h>
  4601. #include <sys\stat.h>
  4602. #include <stdlib.h>
  4603.  
  4604. int main(void)
  4605. {
  4606.    int fh;
  4607.  
  4608.    printf("\nCreating edclose.dat.\n");
  4609.    if (-1 == (fh = open("edclose.dat", O_RDWR|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE)
  4610.       )) {
  4611.       perror("Unable to open edclose.dat");
  4612.       return EXIT_FAILURE;
  4613.    }
  4614.    printf("File was successfully opened.\n");
  4615.    if (-1 == close(fh)) {
  4616.       perror("Unable to close edclose.dat");
  4617.       return EXIT_FAILURE;
  4618.    }
  4619.    printf("File was successfully closed.\n");
  4620.    return 0;
  4621.  
  4622.    /****************************************************************************
  4623.       The output should be:
  4624.  
  4625.       Creating edclose.dat.
  4626.       File was successfully opened.
  4627.       File was successfully closed.
  4628.    ****************************************************************************/
  4629. }
  4630.  
  4631.  
  4632. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4633.  
  4634. Example of close 
  4635.  
  4636.      fclose - Close Stream 
  4637.      creat - Create New File 
  4638.      open - Open File 
  4639.      _sopen - Open Shared File 
  4640.      <io.h> 
  4641.  
  4642.  
  4643. ΓòÉΓòÉΓòÉ 4.31. collequiv - Return List of Equivalent Collating Elements ΓòÉΓòÉΓòÉ
  4644.  
  4645.  
  4646. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4647.  
  4648. #include <collate.h>
  4649. int collequiv(collel_t c, collel_t **list);
  4650.  
  4651.  
  4652. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4653.  
  4654. Language Level:  Extension 
  4655.  
  4656. collequiv finds all the collating elements that have the same primary weight as 
  4657. c, and stores them in an array. (The primary weight is the initial value used 
  4658. to determine how the character is collated or ordered.) It then updates the 
  4659. list to point to the first element of the array of found collating elements. 
  4660.  
  4661. The list of elements is valid until the next call to setlocale with categories 
  4662. LC_ALL, LC_COLLATE, or LC_CTYPE. Another call to collequiv could override the 
  4663. current list. 
  4664.  
  4665. Note: 
  4666.  
  4667.    1. If c has the weight IGNORE in the LC_COLLATE category, the list created 
  4668.       contains all the characters specified as IGNORE. 
  4669.  
  4670.    2. The list contains only characters defined in the charmap file in the 
  4671.       current locale. 
  4672.  
  4673.    3. The list is built statically in the locale, and is freed when the locale 
  4674.       is deleted. 
  4675.  
  4676.  Return Value 
  4677.  collequiv returns the number of collating elements with the equivalent weight. 
  4678.  If the value of c is not in the valid range of collating elements in the 
  4679.  current locale, collequiv returns -1. 
  4680.  
  4681.  
  4682. ΓòÉΓòÉΓòÉ <hidden> Example of collequiv ΓòÉΓòÉΓòÉ
  4683.  
  4684. /************************************************************************
  4685.  
  4686. This example prints the collating elements that have an equivalent weight as 
  4687. the collating element passed in argv[1]. 
  4688.  
  4689. ************************************************************************/
  4690.  
  4691. #include <stdio.h>
  4692. #include <locale.h>
  4693. #include <collate.h>
  4694. #include <wchar.h>
  4695.  
  4696. int main(int argc, char *argv[])
  4697. {
  4698.    collel_t e, *rp;
  4699.    int      i;
  4700.  
  4701.    setlocale(LC_ALL, LC_C_FRANCE);
  4702.    if ((collel_t)-1 == (e = strtocoll(argv[1]))) {
  4703.       printf("'%s' collating element not defined\n", argv[1]);
  4704.       exit(1);
  4705.    }
  4706.    if (-1 == (i = collequiv(e, &rp))) {
  4707.       printf("Invalid collating element '%s'\n", argv[1]);
  4708.       exit(1);
  4709.    }
  4710.    for (; i > 0; rp++, i--) {
  4711.       if (ismccollel(*rp))
  4712.          printf("'%s' ", colltostr(*rp));
  4713.       else if (iswprint(*rp))
  4714.               printf("'%lc' ", *rp);
  4715.            else
  4716.               printf("'%x' ", *rp);
  4717.    }
  4718.    return 0;
  4719.  
  4720.    /****************************************************************************
  4721.       Assuming you compile this example as collequi.exe
  4722.       and invoke it as:  collequi *
  4723.  
  4724.       The output should be:
  4725.       '*' 'Du ' 'Des ' 'De ' 'D'' 'Les ' 'Le ' 'La ' 'L'' 'du ' 'des ' 'de '
  4726.       'd'' 'les ' 'le ' 'la ' 'l''
  4727.  
  4728.    ****************************************************************************/
  4729. }
  4730.  
  4731.  
  4732. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4733.  
  4734. Exampleof collequiv 
  4735.  
  4736.      cclass - Return Characters in Character Class 
  4737.      collorder - Return List of Collating Elements 
  4738.      collrange - Calculate Range of Collating Elements 
  4739.      colltostr - Return String for Collating Element 
  4740.      getmccoll - Get Next Collating Element from String 
  4741.      getwmccoll - Get Next Collating Element from Wide String 
  4742.      ismccollel - Identify Multi-Character Collating Element 
  4743.      maxcoll - Return Maximum Collating Element 
  4744.      strtocoll - Return Collating Element for String 
  4745.      <collate.h> 
  4746.  
  4747.  
  4748. ΓòÉΓòÉΓòÉ 4.32. collorder - Return List of Collating Elements ΓòÉΓòÉΓòÉ
  4749.  
  4750.  
  4751. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4752.  
  4753. #include <collate.h>
  4754. int collorder(collel_t **list);
  4755.  
  4756.  
  4757. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4758.  
  4759. Language Level:  Extension 
  4760.  
  4761. collorder finds the number of collating elements in the collate order list and 
  4762. sets list to point to the collate order list. The list returned is valid until 
  4763. another call to setlocale. 
  4764.  
  4765. Note: 
  4766.  
  4767.    1. Collating elements specified with the weight of IGNORE in the LC_COLLATE 
  4768.       category are defined as having the lowest weight. 
  4769.  
  4770.    2. The list contains only characters defined in the charmap file in the 
  4771.       current locale. 
  4772.  
  4773.    3. The list is built statically in the locale, and is freed when the locale 
  4774.       is deleted. 
  4775.  
  4776.  Return Value 
  4777.  collorder returns the number of collating elements in the collate order list. 
  4778.  
  4779.  
  4780. ΓòÉΓòÉΓòÉ <hidden> Example of collorder ΓòÉΓòÉΓòÉ
  4781.  
  4782. /************************************************************************
  4783.  
  4784. This example uses collorder to create a list of all the collating elements. 
  4785.  
  4786. ************************************************************************/
  4787.  
  4788. #include <stdio.h>
  4789. #include <locale.h>
  4790. #include <collate.h>
  4791. #include <wchar.h>
  4792.  
  4793. int main(void)
  4794. {
  4795.    collel_t *rp;
  4796.    int      i;
  4797.  
  4798.    setlocale(LC_ALL, LC_C_FRANCE);
  4799.    i = collorder(&rp);
  4800.    for (; i > 0; rp++, i--) {
  4801.       if (ismccollel(*rp))
  4802.          printf("'%s' ", colltostr(*rp));
  4803.       else if (iswprint(*rp))
  4804.               printf("'%lc' ", *rp);
  4805.            else
  4806.               printf("'%x' ", *rp);
  4807.    }
  4808.    return 0;
  4809.  
  4810.    /****************************************************************************
  4811.       The output should be similar to :
  4812.        :
  4813.        :
  4814.       ' ' '!' '"' '#' '$' '%' '&' '(' ''' ')' '-' '*' 'Du ' 'Des ' 'De ' 'D''
  4815.       'Les ' 'Le ' 'La ' 'L'' 'du ' 'des ' 'de ' 'd'' 'les ' 'le ' 'la ' 'l''
  4816.       '+' ',' '.' '/'
  4817.       '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' ':' ';' '<' '=' '>' '?'
  4818.       '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O'
  4819.       'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '[' '\' ']' '^' '_'
  4820.        :
  4821.    ****************************************************************************/
  4822. }
  4823.  
  4824.  
  4825. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4826.  
  4827. Example 
  4828.  
  4829.      cclass - Return Characters in Character Class 
  4830.      collequiv - Return List of Equivalent Collating Elements 
  4831.      collrange - Calculate Range of Collating Elements 
  4832.      colltostr - Return String for Collating Element 
  4833.      getmccoll - Get Next Collating Element from String 
  4834.      getwmccoll - Get Next Collating Element from Wide String 
  4835.      ismccollel - Identify Multi-Character Collating Element 
  4836.      maxcoll - Return Maximum Collating Element 
  4837.      strtocoll - Return Collating Element for String 
  4838.      <collate.h> 
  4839.  
  4840.  
  4841. ΓòÉΓòÉΓòÉ 4.33. collrange - Calculate Range of Collating Elements ΓòÉΓòÉΓòÉ
  4842.  
  4843.  
  4844. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4845.  
  4846. #include <collate.h>
  4847. int collrange(collel_t start, collel_t end, collel_t **list);
  4848.  
  4849.  
  4850. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4851.  
  4852. Language Level:  Extension 
  4853.  
  4854. collrange finds the collating elements whose primary weights are between the 
  4855. start and end elements, inclusive, and stores them in an array. It then updates 
  4856. list to point to the array of found collating elements. The list is valid until 
  4857. the next call to setlocale. 
  4858.  
  4859. Note: 
  4860.  
  4861.    1. Collating elements specified with the weight of IGNORE in the LC_COLLATE 
  4862.       category are defined as having the lowest weight. Therefore, such 
  4863.       elements can only be specified as the starting collating element. 
  4864.  
  4865.    2. The list contains only characters defined in the charmap file in the 
  4866.       current locale. 
  4867.  
  4868.    3. The list is built statically in the locale and is freed when the locale 
  4869.       is deleted. 
  4870.  
  4871.  Return Value 
  4872.  collrange returns the number of elements that fall between the range of 
  4873.  weights. If the end point collates earlier than the start point, collrange 
  4874.  returns 0. If either start or end are out of range, collrange returns -1. It 
  4875.  does not set errno. 
  4876.  
  4877.  
  4878. ΓòÉΓòÉΓòÉ <hidden> Example of collrange ΓòÉΓòÉΓòÉ
  4879.  
  4880. /************************************************************************
  4881.  
  4882. This example uses collrange to print the collating elements in the range passed 
  4883. in argv[1] and argv[2]. 
  4884.  
  4885. ************************************************************************/
  4886.  
  4887. #include <stdio.h>
  4888. #include <locale.h>
  4889. #include <collate.h>
  4890. #include <wchar.h>
  4891.  
  4892. int main(int argc, char *argv[])
  4893. {
  4894.    collel_t s, e, *rp;
  4895.    int      i;
  4896.  
  4897.    setlocale(LC_ALL, LC_C_FRANCE);
  4898.    if ((collel_t)-1 == (s = strtocoll(argv[1]))) {
  4899.       printf("'%s' collating element not defined\n", argv[1]);
  4900.       exit(1);
  4901.    }
  4902.    if ((collel_t)-1 == (e = strtocoll(argv[2]))) {
  4903.       printf("'%s' collating element not defined\n", argv[2]);
  4904.       exit(1);
  4905.    }
  4906.    if (-1 == (i = collrange(s, e, &rp))) {
  4907.       printf("Invalid range for '%s' to '%s'\n", argv[1], argv[2]);
  4908.       exit(1);
  4909.    }
  4910.    for (; i > 0; rp++, i--) {
  4911.       if (ismccollel(*rp))
  4912.          printf("'%s' ", colltostr(*rp));
  4913.       else if (iswprint(*rp))
  4914.               printf("'%lc' ", *rp);
  4915.            else
  4916.               printf("'%x' ", *rp);
  4917.    }
  4918.    return 0;
  4919.  
  4920.    /****************************************************************************
  4921.       Assuming you compile this example as collrang.exe
  4922.       and invoke it as:  collrang A z
  4923.  
  4924.       The output should be:
  4925.  
  4926.       'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R'
  4927.       'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '[' '\' ']' '^' '_' '`' 'a' 'b' 'c' 'd'
  4928.       'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v'
  4929.       'w' 'x' 'y' 'z'
  4930.    ****************************************************************************/
  4931. }
  4932.  
  4933.  
  4934. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  4935.  
  4936. Example 
  4937.  
  4938.      cclass - Return Characters in Character Class 
  4939.      collequiv - Return List of Equivalent Collating Elements 
  4940.      collorder - Return List of Collating Elements 
  4941.      colltostr - Return String for Collating Element 
  4942.      getmccoll - Get Next Collating Element from String 
  4943.      getwmccoll - Get Next Collating Element from Wide String 
  4944.      ismccollel - Identify Multi-Character Collating Element 
  4945.      maxcoll - Return Maximum Collating Element 
  4946.      strtocoll - Return Collating Element for String 
  4947.      <collate.h> 
  4948.  
  4949.  
  4950. ΓòÉΓòÉΓòÉ 4.34. colltostr - Return String for Collating Element ΓòÉΓòÉΓòÉ
  4951.  
  4952.  
  4953. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  4954.  
  4955. #include <collate.h>
  4956. char *colltostr(collel_t c);
  4957.  
  4958.  
  4959. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  4960.  
  4961. Language Level:  Extension 
  4962.  
  4963. colltostr is the inverse of strtocoll; it converts the collating element c to 
  4964. the string for that collating element. 
  4965.  
  4966. You could use the returned array from collrange or collequiv and call 
  4967. ismccollel for each element, only calling colltostr if ismccollel is true for 
  4968. the element. 
  4969.  
  4970. The string returned is valid until another call to setlocale. 
  4971.  
  4972. Note:  The string is built statically in the locale and is freed when the 
  4973. locale is deleted. 
  4974.  
  4975. Return Value 
  4976. colltostr returns the string for the collating element. If c is a single 
  4977. character or out of range, colltostr returns NULL. 
  4978.  
  4979.  
  4980. ΓòÉΓòÉΓòÉ <hidden> Example of colltostr ΓòÉΓòÉΓòÉ
  4981.  
  4982. /************************************************************************
  4983.  
  4984. This example prints all the collating elements in the collating sequence, using 
  4985. colltostr to get the string for the multi-character collating elements. 
  4986.  
  4987. ************************************************************************/
  4988.  
  4989. #include <stdio.h>
  4990. #include <locale.h>
  4991. #include <collate.h>
  4992. #include <wchar.h>
  4993.  
  4994. int main(void)
  4995. {
  4996.    collel_t *rp;
  4997.    int      i;
  4998.  
  4999.    setlocale(LC_ALL, LC_C_FRANCE);
  5000.    i = collorder(&rp);
  5001.    for (; i > 0; rp++, i--) {
  5002.       if (ismccollel(*rp))
  5003.          printf("'%s' ", colltostr(*rp));
  5004.       else if (iswprint(*rp))
  5005.               printf("'%lc' ", *rp);
  5006.            else
  5007.               printf("'%x' ", *rp);
  5008.    }
  5009.    return 0;
  5010.  
  5011.    /****************************************************************************
  5012.       The output should be similar to :
  5013.        :
  5014.        :
  5015.       ' ' '!' '"' '#' '$' '%' '&' '(' ''' ')' '-' '*' 'Du ' 'Des ' 'De ' 'D''
  5016.       'Les ' 'Le ' 'La ' 'L'' 'du ' 'des ' 'de ' 'd'' 'les ' 'le ' 'la ' 'l''
  5017.       '+' ',' '.' '/'
  5018.       '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' ':' ';' '<' '=' '>' '?'
  5019.       '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O'
  5020.       'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '[' '\' ']' '^' '_'
  5021.        :
  5022.    ****************************************************************************/
  5023. }
  5024.  
  5025.  
  5026. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5027.  
  5028. Example 
  5029.  
  5030.      cclass - Return Characters in Character Class 
  5031.      collequiv - Return List of Equivalent Collating Elements 
  5032.      collorder - Return List of Collating Elements 
  5033.      collrange - Calculate Range of Collating Elements 
  5034.      colltostr - Return String for Collating Element 
  5035.      getmccoll - Get Next Collating Element from String 
  5036.      getwmccoll - Get Next Collating Element from Wide String 
  5037.      ismccollel - Identify Multi-Character Collating Element 
  5038.      maxcoll - Return Maximum Collating Element 
  5039.      strtocoll - Return Collating Element for String 
  5040.      <collate.h> 
  5041.  
  5042.  
  5043. ΓòÉΓòÉΓòÉ 4.35. _control87 - Set Floating-Point Control Word ΓòÉΓòÉΓòÉ
  5044.  
  5045.  
  5046. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5047.  
  5048. #include <float.h>  /* also in <builtin.h> */
  5049. unsigned int _control87(unsigned int new, unsigned int mask);
  5050.  
  5051.  
  5052. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5053.  
  5054. Language Level:  Extension 
  5055.  
  5056. _control87 gets the current floating-point control word and then sets it. The 
  5057. floating-point control word specifies the precision, rounding, and infinity 
  5058. modes of the floating-point chip. 
  5059.  
  5060. You can mask or unmask current floating-point exceptions using _control87. If 
  5061. the value for the mask is equal to 0, _control87 gets the floating-point 
  5062. control word. If the mask is nonzero, _control87 sets a new value for the 
  5063. control word in the manner described below, and returns the previous value of 
  5064. the control word. For any bit in the mask equal to 1, the corresponding bit in 
  5065. new updates the control word. This is equivalent to the expression: 
  5066.  
  5067.    fpcntrl = ((fpcntrl & ~ mask) Γöé (new & mask))
  5068.  
  5069. where fpcntrl is the floating-point control word. 
  5070.  
  5071. _control87 is used for the current thread only. It does not affect any other 
  5072. threads that may be processing. 
  5073.  
  5074. Warning: If you change the content of the floating-point control word: 
  5075.  
  5076.      The behavior of the math functions with regard to domain and range errors 
  5077.       may be undefined. 
  5078.      Math functions may not handle infinity and NaN values correctly. 
  5079.      Some floating-point exceptions may not occur, while other new ones may 
  5080.       occur. 
  5081.      Resetting the EM_INEXACT bit may cause SIG_FPE exceptions, which decrease 
  5082.       performance. 
  5083.      If the precision or rounding bits are modified, you can reduce the 
  5084.       precision available for float and double variables. 
  5085.  For information on bits in the control word and handling floating-point 
  5086.  exceptions, see the User's Guide. 
  5087.  
  5088.  Return Value 
  5089.  The bits in the returned value reflect the floating-point control word before 
  5090.  the call. 
  5091.  
  5092.  
  5093. ΓòÉΓòÉΓòÉ <hidden> Example of _control187 ΓòÉΓòÉΓòÉ
  5094.  
  5095. /************************************************************************
  5096.  
  5097. This example prints the initial control word in hexadecimal, and then 
  5098. illustrates different representations of 0.1, depending on the precision. 
  5099.  
  5100. ************************************************************************/
  5101.  
  5102. #include <stdio.h>
  5103. #include <float.h>
  5104.  
  5105. double a = .13;
  5106.  
  5107. int main(void)
  5108. {
  5109.    printf("control = 0x%.4x\n", _control87(CW_DEFAULT, 0));/* Get control word*/
  5110.    printf("a*a = .0169 = %.15e\n", a *a);
  5111.    _control87(PC_24, MCW_PC);            /* Set precision to 24 bits          */
  5112.    printf("a*a = .0169 (rounded to 24 bits) = %.15e\n", a *a);
  5113.    _control87(CW_DEFAULT, 0xffff);             /* Restore to initial default  */
  5114.    printf("a*a = .0169 = %.15e\n", a *a);
  5115.    return 0;
  5116.  
  5117.    /****************************************************************************
  5118.       The output should be similar to:
  5119.  
  5120.        control = 0x0362
  5121.        a*a = .0169 = 1.690000000000000e-02
  5122.        a*a = .0169 (rounded to 24 bits) = 1.690000057220459e-02
  5123.        a*a = .0169 = 1.690000000000000e-02
  5124.    ****************************************************************************/
  5125. }
  5126.  
  5127.  
  5128. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5129.  
  5130. Example of _control87 
  5131.  
  5132.      _clear87 - Clear Floating-Point Status Word 
  5133.      _status87 - Get Floating-Point Status Word 
  5134.      _fpreset - Reset Floating-Point Unit 
  5135.      Floating Point Variables 
  5136.      signal - Handle Interrupt Signals 
  5137.      <float.h> 
  5138.  
  5139.  
  5140. ΓòÉΓòÉΓòÉ 4.36. cos - Calculate Cosine ΓòÉΓòÉΓòÉ
  5141.  
  5142.  
  5143. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5144.  
  5145. #include <math.h>
  5146. double cos(double x);
  5147.  
  5148.  
  5149. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5150.  
  5151. Language Level: ANSI, SAA, POSIX, XPG4 
  5152.  
  5153. cos calculates the cosine of x. The value x is expressed in radians. If x is 
  5154. too large, a partial loss of significance in the result may occur. 
  5155.  
  5156. Return Value 
  5157. cos returns the cosine of x. 
  5158.  
  5159.  
  5160. ΓòÉΓòÉΓòÉ <hidden> Example of cos ΓòÉΓòÉΓòÉ
  5161.  
  5162. /************************************************************************
  5163.  
  5164. This example calculates y to be the cosine of x. 
  5165.  
  5166. ************************************************************************/
  5167.  
  5168. #include <math.h>
  5169.  
  5170. int main(void)
  5171. {
  5172.    double x,y;
  5173.  
  5174.    x = 7.2;
  5175.    y = cos(x);
  5176.    printf("cos( %lf ) = %lf\n", x, y);
  5177.    return 0;
  5178.  
  5179.    /****************************************************************************
  5180.       The output should be:
  5181.  
  5182.       cos( 7.200000 ) = 0.608351
  5183.    ****************************************************************************/
  5184. }
  5185.  
  5186.  
  5187. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5188.  
  5189. Example of cos 
  5190.  
  5191.      acos - Calculate Arccosine 
  5192.      cosh - Calculate Hyperbolic Cosine 
  5193.      _facos - Calculate Arccosine 
  5194.      _fcos - Calculate Cosine 
  5195.      _fcossin - Calculate Cosine and Sine 
  5196.      _fsincos - Calculate Sine and Cosine 
  5197.      sin - Calculate Sine 
  5198.      sinh - Calculate Hyperbolic Sine 
  5199.      tan - Calculate Tangent 
  5200.      tanh - Calculate Hyperbolic Tangent 
  5201.      <math.h> 
  5202.  
  5203.  
  5204. ΓòÉΓòÉΓòÉ 4.37. cosh - Calculate Hyperbolic Cosine ΓòÉΓòÉΓòÉ
  5205.  
  5206.  
  5207. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5208.  
  5209. #include <math.h>
  5210. double cosh(double x);
  5211.  
  5212.  
  5213. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5214.  
  5215. Language Level: ANSI, SAA, POSIX, XPG4 
  5216.  
  5217. cosh calculates the hyperbolic cosine of x. The value x is expressed in 
  5218. radians. 
  5219.  
  5220. Return Value 
  5221. cosh returns the hyperbolic cosine of x. If the result is too large, cosh 
  5222. returns the value HUGE_VAL and sets errno to ERANGE. 
  5223.  
  5224.  
  5225. ΓòÉΓòÉΓòÉ <hidden> Example of cosh ΓòÉΓòÉΓòÉ
  5226.  
  5227. /************************************************************************
  5228.  
  5229. This example calculates y to be the hyperbolic cosine of x. 
  5230.  
  5231. ************************************************************************/
  5232.  
  5233. #include <math.h>
  5234.  
  5235. int main(void)
  5236. {
  5237.    double x,y;
  5238.  
  5239.    x = 7.2;
  5240.    y = cosh(x);
  5241.    printf("cosh( %lf ) = %lf\n", x, y);
  5242.    return 0;
  5243.  
  5244.    /****************************************************************************
  5245.      The output should be:
  5246.  
  5247.      cosh( 7.200000 ) = 669.715755
  5248.    ****************************************************************************/
  5249. }
  5250.  
  5251.  
  5252. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5253.  
  5254. Example of cosh 
  5255.  
  5256.      acos - Calculate Arccosine 
  5257.      cos - Calculate Cosine 
  5258.      _facos - Calculate Arccosine 
  5259.      _fcos - Calculate Cosine 
  5260.      _fcossin - Calculate Cosine and Sine 
  5261.      _fsincos - Calculate Sine and Cosine 
  5262.      sin - Calculate Sine 
  5263.      sinh - Calculate Hyperbolic Sine 
  5264.      tan - Calculate Tangent 
  5265.      tanh - Calculate Hyperbolic Tangent 
  5266.      <math.h> 
  5267.  
  5268.  
  5269. ΓòÉΓòÉΓòÉ 4.38. _cprintf - Print Characters to Screen ΓòÉΓòÉΓòÉ
  5270.  
  5271.  
  5272. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5273.  
  5274. #include <conio.h>
  5275. int _cprintf(char *format-string, argument-list);
  5276.  
  5277.  
  5278. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5279.  
  5280. Language Level:  Extension 
  5281.  
  5282. _cprintf formats and sends a series of characters and values directly to the 
  5283. screen, using the _putch function to send each character. 
  5284.  
  5285. The format-string has the same form and function as the format-string parameter 
  5286. for printf. Format specifications in the format-string determine the output 
  5287. format for any argument-list that follows. See printf for a description of the 
  5288. format-string. 
  5289.  
  5290. Note:  Unlike the fprintf, printf, and sprintf functions, _cprintf does not 
  5291. translate line feed characters into output of a carriage return followed by a 
  5292. line feed. 
  5293.  
  5294. Return Value 
  5295. _cprintf returns the number of characters printed. 
  5296.  
  5297.  
  5298. ΓòÉΓòÉΓòÉ <hidden> Example of _cprintf ΓòÉΓòÉΓòÉ
  5299.  
  5300. /************************************************************************
  5301.  
  5302. The following program uses _cprintf to write strings to the screen. 
  5303.  
  5304. ************************************************************************/
  5305.  
  5306. #include <conio.h>
  5307.  
  5308. int main(void)
  5309. {
  5310.    char buffer[24];
  5311.  
  5312.    _cprintf("\nPlease enter a filename:\n");
  5313.    _cscanf("%23s", buffer);
  5314.    _cprintf("\nThe file name you entered was %23s.", buffer);
  5315.    return 0;
  5316.  
  5317.    /****************************************************************************
  5318.       The output should be similar to :
  5319.  
  5320.        Please enter a filename:
  5321.                               file.dat
  5322.        The filename you entered was                file.dat.
  5323.    ****************************************************************************/
  5324. }
  5325.  
  5326.  
  5327. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5328.  
  5329. Example of _cprintf 
  5330.  
  5331.      _cscanf - Read Data from Keyboard 
  5332.      fprintf - Write Formatted Data to a Stream 
  5333.      printf - Print Formatted Characters 
  5334.      _putch - Write Character to Screen 
  5335.      sprintf - Print Formatted Data to Buffer 
  5336.      <conio.h> 
  5337.  
  5338.  
  5339. ΓòÉΓòÉΓòÉ 4.39. _cputs - Write String to Screen ΓòÉΓòÉΓòÉ
  5340.  
  5341.  
  5342. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5343.  
  5344. #include <conio.h>
  5345. int _cputs(char *str);
  5346.  
  5347.  
  5348. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5349.  
  5350. Language Level:  Extension 
  5351.  
  5352. _cputs writes the string that str points to directly to the screen. The string 
  5353. str must end with a null character (\0). The _cputs function does not 
  5354. automatically add a carriage return followed by a line feed to the string. 
  5355.  
  5356. Return Value 
  5357. If successful, _cputs returns 0. Otherwise, it returns a nonzero value. 
  5358.  
  5359.  
  5360. ΓòÉΓòÉΓòÉ <hidden> Example of _cputs ΓòÉΓòÉΓòÉ
  5361.  
  5362. /************************************************************************
  5363.  
  5364. This example outputs a prompt to the screen. 
  5365.  
  5366. ************************************************************************/
  5367.  
  5368. #include <conio.h>
  5369.  
  5370. int main(void)
  5371. {
  5372.    char *buffer = "Insert data disk in drive a: \r\n";
  5373.  
  5374.    _cputs(buffer);
  5375.    return 0;
  5376.  
  5377.    /****************************************************************************
  5378.       The output should be:
  5379.  
  5380.       Insert data disk in drive a:
  5381.    ****************************************************************************/
  5382. }
  5383.  
  5384.  
  5385. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5386.  
  5387. Example of _cputs 
  5388.  
  5389.      _cgets - Read String of Characters from Keyboard 
  5390.      fputs - Write String 
  5391.      _putch - Write Character to Screen 
  5392.      puts - Write a String 
  5393.      <conio.h> 
  5394.  
  5395.  
  5396. ΓòÉΓòÉΓòÉ 4.40. creat - Create New File ΓòÉΓòÉΓòÉ
  5397.  
  5398.  
  5399. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5400.  
  5401. #include <io.h>
  5402. #include <sys\stat.h>
  5403. int creat(char *pathname, int pmode);
  5404.  
  5405.  
  5406. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5407.  
  5408. Language Level:  XPG4, Extension 
  5409.  
  5410. creat either creates a new file or opens and truncates an existing file. If the 
  5411. file specified by pathname does not exist, creat creates a new file with the 
  5412. given permission setting and opens it for writing in text mode. If the file 
  5413. already exists, and the read-only attribute and sharing permissions allow 
  5414. writing, creat truncates the file to length 0. This action destroys the 
  5415. previous contents of the file and opens it for writing in text mode. creat 
  5416. always opens a file in text mode for reading and writing. 
  5417.  
  5418. The permission setting pmode applies to newly created files only. The new file 
  5419. receives the specified permission setting after you close it for the first 
  5420. time. The pmode integer expression contains one or both of the constants 
  5421. S_IWRITE and S_IREAD, defined in <sys\stat.h>. The values of the pmode argument 
  5422. and their meanings are: 
  5423.  
  5424.  Value                   Meaning 
  5425.  S_IREAD                 Reading permitted 
  5426.  S_IWRITE                Writing permitted 
  5427.  S_IREAD | S_IWRITE      Reading and writing permitted. 
  5428.  
  5429.  If you do not give permission to write to the file, it is a read-only file. On 
  5430.  the OS/2 operating system, you cannot give write-only permission. Thus, the 
  5431.  modes S_IWRITE and S_IREAD | S_IWRITE have the same results. The creat 
  5432.  function applies the current file permission mask to pmode before setting the 
  5433.  permissions. (See umask - Sets File Mask of Current Process for more 
  5434.  information about file permission masks.) 
  5435.  
  5436.  When writing new code, you should use open rather than creat. 
  5437.  
  5438.  Specifying a pmode of S_IREAD is similar to making a file read-only with the 
  5439.  ATTRIB system command. 
  5440.  
  5441.  Note:  In earlier releases of C Set ++, creat began with an underscore 
  5442.  (_creat). Because it is defined by the X/Open standard, the underscore has 
  5443.  been removed. For compatibility, VisualAge C++ will map _creat to creat for 
  5444.  you. 
  5445.  
  5446.  Return Value 
  5447.  creat returns a handle for the created file if the call is successful. A 
  5448.  return value of -1 shows an error, and creat sets errno to one of the 
  5449.  following values: 
  5450.  
  5451.  Value          Meaning 
  5452.  EACCESS        File sharing violated. 
  5453.  EINVAL         The mode specified was not valid. 
  5454.  EMFILE         No more file handles are available. 
  5455.  ENOENT         The path name was not found, or the file name was incorrect. 
  5456.  EOS2ERR        The call to the operating system was not successful. 
  5457.  
  5458.  
  5459. ΓòÉΓòÉΓòÉ <hidden> Example of creat ΓòÉΓòÉΓòÉ
  5460.  
  5461. /************************************************************************
  5462.  
  5463. This example creates the file sample.dat so it can be read from and written to. 
  5464.  
  5465. ************************************************************************/
  5466.  
  5467. #include <sys\stat.h>
  5468. #include <io.h>
  5469. #include <stdio.h>
  5470. #include <stdlib.h>
  5471.  
  5472. int main(void)
  5473. {
  5474.    int fh;
  5475.  
  5476.    fh = creat("sample.dat", S_IREAD|S_IWRITE);
  5477.    if (-1 == fh) {
  5478.       perror("Error in creating sample.dat");
  5479.       return EXIT_FAILURE;
  5480.    }
  5481.    else
  5482.       printf("Successfully created sample.dat.\n");
  5483.    close(fh);
  5484.    return 0;
  5485.  
  5486.    /****************************************************************************
  5487.       The output should:
  5488.  
  5489.        Successfully created sample.dat.
  5490.    ****************************************************************************/
  5491. }
  5492.  
  5493.  
  5494. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5495.  
  5496. Example of creat 
  5497.  
  5498.      chmod - Change File Permission Setting 
  5499.      close - Close File Associated with Handle 
  5500.      open - Open File 
  5501.      fdopen - Associates Input Or Output With File 
  5502.      _sopen - Open Shared File 
  5503.      umask - Sets File Mask of Current Process 
  5504.      <sys\stat.h> 
  5505.      <io.h> 
  5506.  
  5507.  
  5508. ΓòÉΓòÉΓòÉ 4.41. _crotl - _crotr - Rotate Bits of Character Value ΓòÉΓòÉΓòÉ
  5509.  
  5510.  
  5511. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5512.  
  5513. #include <stdlib.h>    /* also in <builtin.h> */
  5514. unsigned char _crotl(unsigned char value, int shift);
  5515. unsigned char _crotr(unsigned char value, int shift);
  5516.  
  5517.  
  5518. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5519.  
  5520. Language Level:  Extension 
  5521.  
  5522. The _crotl and _crotr functions rotate the character value by shift bits. The 
  5523. _crotl function rotates to the left, and _crotr to the right. 
  5524.  
  5525. Note:  Both _crotl and _crotr are built-in functions, which means they are 
  5526. implemented as inline instructions and have no backing code in the library. For 
  5527. this reason: 
  5528.  
  5529.      You cannot take the address of these functions. 
  5530.      You cannot parenthesize a call to either function. (Parentheses specify a 
  5531.       call to the function's backing code, and these functions have none.) 
  5532.  
  5533.  Return Value 
  5534.  
  5535.  Both functions return the rotated value. There is no error return value. 
  5536.  
  5537.  
  5538. ΓòÉΓòÉΓòÉ <hidden> Example of _crotl - _crotr ΓòÉΓòÉΓòÉ
  5539.  
  5540. /************************************************************************
  5541.  
  5542. This example uses _crotl and _crotr with different shift values to rotate the 
  5543. character value: 
  5544.  
  5545. ************************************************************************/
  5546.  
  5547. #include <stdio.h>
  5548. #include <stdlib.h>
  5549.  
  5550. int main(void)
  5551. {
  5552.    unsigned char val = 0X01;
  5553.  
  5554.    printf("The value of 0x%2.2x rotated 4 bits to the left is 0x%2.2x\n", val,
  5555.       _crotl(val, 4));
  5556.    printf("The value of 0x%2.2x rotated 2 bits to the right is 0x%2.2x\n",
  5557.       val, _crotr(val, 2));
  5558.    return 0;
  5559.  
  5560.    /****************************************************************************
  5561.       The output should be:
  5562.  
  5563.       The value of 0x01 rotated 4 bits to the left is 0x10
  5564.       The value of 0x01 rotated 2 bits to the right is 0x40
  5565.    ****************************************************************************/
  5566. }
  5567.  
  5568.  
  5569. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5570.  
  5571. Example of _crotl - _crotr 
  5572.  
  5573.      _lrotl - _lrotr - Rotate Bits of Unsigned Long Value 
  5574.      _rotl - _rotr - Rotate Bits of Unsigned Integer 
  5575.      _srotl - _srotr - Rotate Bits of Unsigned Short Value 
  5576.      <stdlib.h> 
  5577.      <builtin.h> 
  5578.  
  5579.  
  5580. ΓòÉΓòÉΓòÉ 4.42. _CRT_init - Initialize DLL Runtime Environment ΓòÉΓòÉΓòÉ
  5581.  
  5582.  
  5583. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5584.  
  5585. int _CRT_init(void);
  5586. /* no header file - defined in the runtime startup code */
  5587.  
  5588.  
  5589. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5590.  
  5591. Language Level:  Extension 
  5592.  
  5593. _CRT_init initializes the VisualAge C++ runtime environment for a DLL. 
  5594.  
  5595. By default, all DLLs call the VisualAge C++ _DLL_InitTerm function, which in 
  5596. turn calls _CRT_init for you. However, if you are writing your own 
  5597. _DLL_InitTerm function (for example, to perform actions other than runtime 
  5598. initialization and termination), you must call _CRT_init from your version of 
  5599. _DLL_InitTerm before you can call any other runtime functions. 
  5600.  
  5601. If your DLL contains C++ code, you must also call __ctordtorInit after 
  5602. _CRT_init to ensure that static constructors and destructors are initialized 
  5603. properly.  __ctordtorInit is defined in the runtime startup code as: 
  5604.  
  5605.    void __ctordtorInit(void);
  5606.  
  5607. Note:  If you are providing your own version of the _matherr function to be 
  5608.        used in your DLL, you must also call the _exception_dllinit function 
  5609.        after the runtime environment is initialized. Calling this function 
  5610.        ensures that the proper _matherr function will be called during 
  5611.        exception handling. _exception_dllinit is defined in the runtime startup 
  5612.        code as: 
  5613.  
  5614.                  void _Optlink _exception_dllinit( int (*)(struct exception *) );
  5615.  
  5616. The parameter required is the address of your _matherr function. 
  5617.  
  5618.  Return Value 
  5619.  If the runtime environment is successfully initialized, _CRT_init returns 0. A 
  5620.  return code of -1 indicates an error. If an error occurs, an error message is 
  5621.  written to file handle 2, which is the usual destination of stderr. 
  5622.  
  5623.  
  5624. ΓòÉΓòÉΓòÉ <hidden> Example of _CRT_init ΓòÉΓòÉΓòÉ
  5625.  
  5626. /************************************************************************
  5627.  
  5628. This example shows the _DLL_InitTerm function from the VisualAge C++ sample 
  5629. program for building DLLs, which calls _CRT_init to initialize the library 
  5630. environment. 
  5631.  
  5632. ************************************************************************/
  5633.  
  5634. #define  INCL_DOSMODULEMGR
  5635. #define  INCL_DOSPROCESS
  5636. #include <os2.h>
  5637. #include <stdlib.h>
  5638. #include <stdio.h>
  5639. #include <string.h>
  5640.  
  5641. /* _CRT_init is the C run-time environment initialization function.         */
  5642. /* It will return 0 to indicate success and -1 to indicate failure.         */
  5643.  
  5644. int _CRT_init(void);
  5645. #ifdef   STATIC_LINK
  5646.  
  5647. /* _CRT_term is the C run-time environment termination function.            */
  5648. /* It only needs to be called when the C run-time functions are statically  */
  5649. /* linked.                                                                  */
  5650.  
  5651. void _CRT_term(void);
  5652. #else
  5653.  
  5654. /* A clean up routine registered with DosExitList must be used if runtime   */
  5655. /* calls are required and the runtime is dynamically linked.  This will     */
  5656. /* guarantee that this clean up routine is run before the library DLL is    */
  5657. /* terminated.                                                              */
  5658.  
  5659. static void _System cleanup(ULONG ulReason);
  5660. #endif
  5661. size_t nSize;
  5662. int *pArray;
  5663.  
  5664. /* _DLL_InitTerm is the function that gets called by the operating system   */
  5665. /* loader when it loads and frees this DLL for each process that accesses   */
  5666. /* this DLL.  However, it only gets called the first time the DLL is loaded */
  5667. /* and the last time it is freed for a particular process.  The system      */
  5668. /* linkage convention MUST be used because the operating system loader is   */
  5669. /* calling this function.                                                   */
  5670.  
  5671. unsigned long _System _DLL_InitTerm(unsigned long hModule, unsigned long
  5672.                                     ulFlag)
  5673. {
  5674.    size_t i;
  5675.    APIRET rc;
  5676.    char namebuf[CCHMAXPATH];
  5677.  
  5678.    /* If ulFlag is zero then the DLL is being loaded so initialization should*/
  5679.    /* be performed.  If ulFlag is 1 then the DLL is being freed so          */
  5680.    /* termination should be performed.                                      */
  5681.  
  5682.    switch (ulFlag) {
  5683.       case 0 :
  5684.  
  5685.          /*******************************************************************/
  5686.          /* The C run-time environment initialization function must be      */
  5687.          /* called before any calls to C run-time functions that are not    */
  5688.          /* inlined.                                                        */
  5689.          /*******************************************************************/
  5690.  
  5691.          if (_CRT_init() == -1)
  5692.             return 0UL;
  5693. #ifndef  STATIC_LINK
  5694.  
  5695.          /*******************************************************************/
  5696.          /* A DosExitList routine must be used to clean up if runtime calls */
  5697.          /* are required and the runtime is dynamically linked.             */
  5698.          /*******************************************************************/
  5699.  
  5700.             if (rc = DosExitList(0x0000FF00|EXLST_ADD, cleanup))
  5701.             printf("DosExitList returned %lu\n", rc);
  5702. #endif
  5703.          if (rc = DosQueryModuleName(hModule, CCHMAXPATH, namebuf))
  5704.             printf("DosQueryModuleName returned %lu\n", rc);
  5705.          else
  5706.             printf("The name of this DLL is %s\n", namebuf);
  5707.          srand(17);
  5708.          nSize = (rand()%128)+32;
  5709.          printf("The array size for this process is %u\n", nSize);
  5710.          if ((pArray = malloc(nSize *sizeof(int))) == NULL) {
  5711.             printf("Could not allocate space for unsorted array.\n");
  5712.             return 0UL;
  5713.          }
  5714.          for (i = 0; i < nSize; ++i)
  5715.             pArray[i] = rand();
  5716.          break;
  5717.       case 1 :
  5718. #ifdef   STATIC_LINK
  5719.          printf("The array will now be freed.\n");
  5720.          free(pArray);
  5721.          _CRT_term();
  5722. #endif
  5723.          break;
  5724.       default  :
  5725.          printf("ulFlag = %lu\n", ulFlag);
  5726.          return 0UL;
  5727.    }
  5728.  
  5729.    /* A non-zero value must be returned to indicate success.                */
  5730.  
  5731.    return 1UL;
  5732. }
  5733. #ifndef  STATIC_LINK
  5734. static void cleanup(ULONG ulReason)
  5735. {
  5736.    if (!ulReason) {
  5737.       printf("The array will now be freed.\n");
  5738.       free(pArray);
  5739.    }
  5740.    DosExitList(EXLST_EXIT, cleanup);
  5741.    return ;
  5742. }
  5743. #endif
  5744.  
  5745.  
  5746. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5747.  
  5748. Example of _CRT_init 
  5749.  
  5750.      Building Dynamic Link Libraries in the Programming Guide 
  5751.      _CRT_term - Terminate DLL Runtime Environment 
  5752.      _DLL_InitTerm - Initialize and Terminate DLL Environment 
  5753.      _rmem_init - Initialize Memory Functions for Subsystem DLL 
  5754.      _rmem_term - Terminate Memory Functions for Subsystem DLL 
  5755.      _tmem_init - Initialize Memory Functions for Subsystem DLL 
  5756.      _tmem_term - Terminate Memory Functions for Subsystem DLL 
  5757.  
  5758.  
  5759. ΓòÉΓòÉΓòÉ 4.43. _CRT_term - Terminate DLL Runtime Environment ΓòÉΓòÉΓòÉ
  5760.  
  5761.  
  5762. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5763.  
  5764. void _CRT_term(void);
  5765. /* no header file - defined in runtime startup code */
  5766.  
  5767.  
  5768. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5769.  
  5770. Language Level:  Extension 
  5771.  
  5772. _CRT_term terminates the VisualAge C++ runtime environment. It is only needed 
  5773. for DLLs where the C runtime functions are statically linked. 
  5774.  
  5775. By default, all DLLs call the VisualAge C++ _DLL_InitTerm function, which in 
  5776. turn calls _CRT_term for you. However, if you are writing your own 
  5777. _DLL_InitTerm function (for example, to perform actions other than runtime 
  5778. initialization and termination), and your DLL statically links to the C runtime 
  5779. libraries, you need to call _CRT_term from your _DLL_InitTerm function. 
  5780.  
  5781. If your DLL contains C++ code, you must also call __ctordtorTerm before you 
  5782. call _CRT_term to ensure that static constructors and destructors are 
  5783. terminated correctly. __ctordtorTerm is defined in the runtime startup code as: 
  5784.  
  5785.    void __ctordtorTerm(void);
  5786.  
  5787. Once you have called _CRT_term, you cannot call any other library functions. 
  5788.  
  5789. If your DLL is dynamically linked, you cannot call library functions in the 
  5790. termination section of your _DLL_InitTerm function. If your termination routine 
  5791. requires calling library functions, you must register the termination routine 
  5792. with DosExitList. Note that all DosExitList routines are called before DLL 
  5793. termination routines. 
  5794.  
  5795. Return Value 
  5796. There is no return value for _CRT_term. 
  5797.  
  5798.  
  5799. ΓòÉΓòÉΓòÉ <hidden> Example of _CRT_term ΓòÉΓòÉΓòÉ
  5800.  
  5801. /************************************************************************
  5802.  
  5803. This example shows the _DLL_InitTerm function from the VisualAge C++ sample 
  5804. program for building DLLs, which calls _CRT_term to terminate the library 
  5805. environment. 
  5806.  
  5807. ************************************************************************/
  5808.  
  5809. #define  INCL_DOSMODULEMGR
  5810. #define  INCL_DOSPROCESS
  5811. #include <os2.h>
  5812. #include <stdlib.h>
  5813. #include <stdio.h>
  5814. #include <string.h>
  5815.  
  5816. /* _CRT_init is the C run-time environment initialization function.         */
  5817. /* It will return 0 to indicate success and -1 to indicate failure.         */
  5818.  
  5819. int _CRT_init(void);
  5820. #ifdef   STATIC_LINK
  5821.  
  5822. /* _CRT_term is the C run-time environment termination function.            */
  5823. /* It only needs to be called when the C run-time functions are statically  */
  5824. /* linked.                                                                  */
  5825.  
  5826. void _CRT_term(void);
  5827. #else
  5828.  
  5829. /* A clean up routine registered with DosExitList must be used if runtime   */
  5830. /* calls are required and the runtime is dynamically linked.  This will     */
  5831. /* guarantee that this clean up routine is run before the library DLL is    */
  5832. /* terminated.                                                              */
  5833.  
  5834. static void _System cleanup(ULONG ulReason);
  5835. #endif
  5836. size_t nSize;
  5837. int *pArray;
  5838.  
  5839. /* _DLL_InitTerm is the function that gets called by the operating system   */
  5840. /* loader when it loads and frees this DLL for each process that accesses   */
  5841. /* this DLL.  However, it only gets called the first time the DLL is loaded */
  5842. /* and the last time it is freed for a particular process.  The system      */
  5843. /* linkage convention MUST be used because the operating system loader is   */
  5844. /* calling this function.                                                   */
  5845.  
  5846. unsigned long _System _DLL_InitTerm(unsigned long hModule, unsigned long
  5847.                                     ulFlag)
  5848. {
  5849.    size_t i;
  5850.    APIRET rc;
  5851.    char namebuf[CCHMAXPATH];
  5852.  
  5853.    /* If ulFlag is zero then the DLL is being loaded so initialization should*/
  5854.    /* be performed.  If ulFlag is 1 then the DLL is being freed so          */
  5855.    /* termination should be performed.                                      */
  5856.  
  5857.    switch (ulFlag) {
  5858.       case 0 :
  5859.  
  5860.          /*******************************************************************/
  5861.          /* The C run-time environment initialization function must be      */
  5862.          /* called before any calls to C run-time functions that are not    */
  5863.          /* inlined.                                                        */
  5864.          /*******************************************************************/
  5865.  
  5866.          if (_CRT_init() == -1)
  5867.             return 0UL;
  5868. #ifndef  STATIC_LINK
  5869.  
  5870.          /*******************************************************************/
  5871.          /* A DosExitList routine must be used to clean up if runtime calls */
  5872.          /* are required and the runtime is dynamically linked.             */
  5873.          /*******************************************************************/
  5874.  
  5875.             if (rc = DosExitList(0x0000FF00|EXLST_ADD, cleanup))
  5876.             printf("DosExitList returned %lu\n", rc);
  5877. #endif
  5878.          if (rc = DosQueryModuleName(hModule, CCHMAXPATH, namebuf))
  5879.             printf("DosQueryModuleName returned %lu\n", rc);
  5880.          else
  5881.             printf("The name of this DLL is %s\n", namebuf);
  5882.          srand(17);
  5883.          nSize = (rand()%128)+32;
  5884.          printf("The array size for this process is %u\n", nSize);
  5885.          if ((pArray = malloc(nSize *sizeof(int))) == NULL) {
  5886.             printf("Could not allocate space for unsorted array.\n");
  5887.             return 0UL;
  5888.          }
  5889.          for (i = 0; i < nSize; ++i)
  5890.             pArray[i] = rand();
  5891.          break;
  5892.       case 1 :
  5893. #ifdef   STATIC_LINK
  5894.          printf("The array will now be freed.\n");
  5895.          free(pArray);
  5896.          _CRT_term();
  5897. #endif
  5898.          break;
  5899.       default  :
  5900.          printf("ulFlag = %lu\n", ulFlag);
  5901.          return 0UL;
  5902.    }
  5903.  
  5904.    /* A non-zero value must be returned to indicate success.                */
  5905.  
  5906.    return 1UL;
  5907. }
  5908. #ifndef  STATIC_LINK
  5909. static void cleanup(ULONG ulReason)
  5910. {
  5911.    if (!ulReason) {
  5912.       printf("The array will now be freed.\n");
  5913.       free(pArray);
  5914.    }
  5915.    DosExitList(EXLST_EXIT, cleanup);
  5916.    return ;
  5917. }
  5918. #endif
  5919.  
  5920.  
  5921. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5922.  
  5923. Example of _CRT_term 
  5924.  
  5925.      Building Dynamic Link Libraries in the Programming Guide 
  5926.      _CRT_init - Initialize DLL Runtime Environment 
  5927.      _DLL_InitTerm - Initialize and Terminate DLL Environment 
  5928.      _rmem_init - Initialize Memory Functions for Subsystem DLL 
  5929.      _rmem_term - Terminate Memory Functions for Subsystem DLL 
  5930.      _tmem_init - Initialize Memory Functions for Subsystem DLL 
  5931.      _tmem_term - Terminate Memory Functions for Subsystem DLL 
  5932.  
  5933.  
  5934. ΓòÉΓòÉΓòÉ 4.44. csid - Determine Character Set ID for Multibyte Character ΓòÉΓòÉΓòÉ
  5935.  
  5936.  
  5937. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5938.  
  5939. #include <stdlib.h>
  5940. int csid(const char *c);
  5941.  
  5942.  
  5943. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  5944.  
  5945. Language Level:  Extension 
  5946.  
  5947. csid queries the locale and determines the character-set identifier for the 
  5948. specified character c. 
  5949.  
  5950. Return Value 
  5951. csid returns the character-set identifier, or -1 if the character is not valid. 
  5952.  
  5953.  
  5954. ΓòÉΓòÉΓòÉ <hidden> Example of csid ΓòÉΓòÉΓòÉ
  5955.  
  5956. /************************************************************************
  5957.  
  5958. This example checks the character-set ID for a character. 
  5959.  
  5960. ************************************************************************/
  5961.  
  5962. #include <locale.h>
  5963. #include <stdio.h>
  5964. #include <stdlib.h>
  5965.  
  5966. int main(void)
  5967. {
  5968.    char *string = "A";
  5969.    int   rc;
  5970.  
  5971.    rc = csid(string);
  5972.    printf("character '%s' is in character set id %i\n", string, rc);
  5973.    return 0;
  5974.  
  5975.    /****************************************************************************
  5976.       The output should be similar to :
  5977.  
  5978.       character 'A' is in character set id 0
  5979.    ****************************************************************************/
  5980. }
  5981.  
  5982.  
  5983. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  5984.  
  5985. Example of csid 
  5986.  
  5987.      wcsid - Determine Character Set ID for Wide Character 
  5988.  
  5989.      <stdlib.h> 
  5990.  
  5991.  
  5992. ΓòÉΓòÉΓòÉ 4.45. _cscanf - Read Data from Keyboard ΓòÉΓòÉΓòÉ
  5993.  
  5994.  
  5995. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  5996.  
  5997. #include <conio.h>
  5998. int _cscanf(char *format-string, argument-list);
  5999.  
  6000.  
  6001. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6002.  
  6003. Language Level:  Extension 
  6004.  
  6005. _cscanf reads data directly from the keyboard to the locations given by 
  6006. argument-list, if any are specified. The _cscanf function uses the _getche 
  6007. function to read characters. Each argument must be a pointer to a variable with 
  6008. a type that corresponds to a type specifier in the format-string. 
  6009.  
  6010. The format-string controls the interpretation of the input fields and has the 
  6011. same form and function as the format-string argument for the scanf function. 
  6012. See scanf for a description of the format-string. 
  6013.  
  6014. Note:  Although _cscanf normally echoes the input character, it does not do so 
  6015. if the last action was a call to _ungetch. 
  6016.  
  6017. Return Value 
  6018. _cscanf returns the number of fields that were successfully converted and 
  6019. assigned. The return value does not include fields that were read but not 
  6020. assigned. 
  6021.  
  6022. The return value is EOF for an attempt to read at the end of the file. A return 
  6023. value of 0 means that no fields were assigned. 
  6024.  
  6025.  
  6026. ΓòÉΓòÉΓòÉ <hidden> Example of _cscanf ΓòÉΓòÉΓòÉ
  6027.  
  6028. /************************************************************************
  6029.  
  6030. This example uses _cscanf to read strings from the screen. 
  6031.  
  6032. ************************************************************************/
  6033.  
  6034. #include <conio.h>
  6035.  
  6036. int main(void)
  6037. {
  6038.    char buffer[24];
  6039.  
  6040.    _cprintf("\nPlease enter a filename:\n");
  6041.    _cscanf("%23s", buffer);
  6042.    _cprintf("\nThe file name you entered was %23s.", buffer);
  6043.    return 0;
  6044.  
  6045.    /****************************************************************************
  6046.       The output should be similar to :
  6047.  
  6048.       Please enter a filename:
  6049.                               file.dat
  6050.       The filename you entered was                file.dat.
  6051.    ****************************************************************************/
  6052. }
  6053.  
  6054.  
  6055. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  6056.  
  6057. Example of _cscanf 
  6058.  
  6059.      fscanf - Read Formatted Data 
  6060.      _getch - _getche - Read Character from Keyboard 
  6061.      scanf - Read Data 
  6062.      sscanf - Read Data 
  6063.      _ungetch - Push Character Back to Keyboard 
  6064.      <conio.h> 
  6065.  
  6066.  
  6067. ΓòÉΓòÉΓòÉ 4.46. ctime - Convert Time to Character String ΓòÉΓòÉΓòÉ
  6068.  
  6069.  
  6070. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  6071.  
  6072. #include <time.h>
  6073. char *ctime(const time_t *time);
  6074.  
  6075.  
  6076. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6077.  
  6078. Language Level: ANSI, SAA, POSIX, XPG4 
  6079.  
  6080. ctime converts the time value pointed to by time to local time in the form of a 
  6081. character string.  A time value is usually obtained by a call to the time 
  6082. function. 
  6083.  
  6084. The string result produced by ctime contains exactly 26 characters and has the 
  6085. format: 
  6086.  
  6087.    "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"
  6088. For example: 
  6089.  
  6090.    Mon Jul 16 02:03:55 1987\n\0
  6091.  
  6092. ctime uses a 24-hour clock format.  The days are abbreviated to: Sun, Mon, Tue, 
  6093. Wed, Thu, Fri, and Sat. The months are abbreviated to: Jan, Feb, Mar, Apr, May, 
  6094. Jun, Jul, Aug, Sep, Oct, Nov, and Dec. All fields have a constant width. Dates 
  6095. with only one digit are preceded with a blank space. The new-line character 
  6096. (\n) and the null character (\0) occupy the last two positions of the string. 
  6097.  
  6098. The time and date functions begin at 00:00:00 Universal Time, January 1, 1970. 
  6099.  
  6100. Return Value 
  6101. ctime returns a pointer to the character string result.  There is no error 
  6102. return value. A call to ctime is equivalent to: 
  6103.  
  6104.    asctime(localtime(&anytime))
  6105.  
  6106. Note:  The asctime, ctime, and other time functions may use a common, 
  6107.        statically allocated buffer for holding the return string.  Each call to 
  6108.        one of these functions may destroy the result of the previous call. 
  6109.  
  6110.  
  6111. ΓòÉΓòÉΓòÉ <hidden> Example of ctime ΓòÉΓòÉΓòÉ
  6112.  
  6113. /************************************************************************
  6114.  
  6115. This example polls the system clock using ctime. It then prints a message 
  6116. giving the current date and time. 
  6117.  
  6118. ************************************************************************/
  6119.  
  6120. #include <time.h>
  6121. #include <stdio.h>
  6122.  
  6123. int main(void)
  6124. {
  6125.    time_t ltime;
  6126.  
  6127.    time(<ime);
  6128.    printf("The time is %s", ctime(<ime));
  6129.    return 0;
  6130.  
  6131.    /****************************************************************************
  6132.       The output should be similar to :
  6133.  
  6134.       The time is Thu Dec 15 18:10:23 1994
  6135.    ****************************************************************************/
  6136. }
  6137.  
  6138.  
  6139. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  6140.  
  6141. Example of ctime 
  6142.  
  6143.      asctime - Convert Time to Character String 
  6144.      gmtime - Convert Time 
  6145.      localtime - Convert Time 
  6146.      mktime - Convert Local Time 
  6147.      strftime - Convert to Formatted Time 
  6148.      time - Determine Current Time 
  6149.      <time.h> 
  6150.  
  6151.  
  6152. ΓòÉΓòÉΓòÉ 4.47. _cwait - Wait for Child Process ΓòÉΓòÉΓòÉ
  6153.  
  6154.  
  6155. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  6156.  
  6157. #include <process.h>
  6158. int _cwait(int *stat_loc, int process_id, int action_code);
  6159.  
  6160.  
  6161. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6162.  
  6163. Language Level:  Extension 
  6164.  
  6165. _cwait delays the completion of a parent process until the child process 
  6166. specified by process_id ends. 
  6167.  
  6168. The process_id is the value returned by the _spawn function that started the 
  6169. child process. If the specified child process ends before _cwait is called, 
  6170. _cwait returns to the calling process immediately with a value of -1. If the 
  6171. value of process_id is 0, the parent process waits until all of its child 
  6172. processes end. 
  6173.  
  6174. If the variable pointed to by stat_loc is NULL, _cwait does not use it. If it 
  6175. is not NULL, _cwait places information about the return status and the return 
  6176. code of the child process in the location pointed to by stat_loc. 
  6177.  
  6178. If the child process ended normally with a call to the OS/2 DosExit API, the 
  6179. lowest-order byte of the variable pointed to by stat_loc is 0.  The next 
  6180. highest-order byte contains the lowest-order byte of the argument passed to 
  6181. DosExit by the child process. The value of this byte depends on how the child 
  6182. process caused the system to call DosExit.  If the child called exit, _exit, or 
  6183. return from main, or used a DosExit coded into the program, the byte contains 
  6184. the lowest-order byte of the argument the child passed to exit, _exit, or 
  6185. return. The value of the byte is undefined if the child caused a DosExit call 
  6186. simply by reaching the end of main. 
  6187.  
  6188. If the child process ended abnormally (without a call to DosExit), the 
  6189. lowest-order byte of the variable pointed to by stat_loc contains the return 
  6190. code from the OS/2 DosWaitChild API, and the next higher-order byte is 0. See 
  6191. the OS/2 online reference for details about the DosWaitChild return codes. 
  6192.  
  6193. The action_code specifies when the parent process is to start running again. 
  6194. Values for action_code include: 
  6195.  
  6196.  Action Code Meaning 
  6197.  WAIT_CHILD 
  6198.            The parent process waits until the specified child process ends. 
  6199.  WAIT_GRANDCHILD 
  6200.            The parent process waits until the child process and all of the 
  6201.            child processes of that process end. 
  6202.  
  6203.  The action code values are defined in <process.h>. 
  6204.  
  6205.  Note:  Because the size of an int is only 2 bytes in 16-bit compilers, if you 
  6206.  are migrating a 16-bit program, some parts of your programs may have to be 
  6207.  rewritten if they use this function. 
  6208.  
  6209.  An alternative to this function is the DosWaitChild API call. 
  6210.  
  6211.  Return Value 
  6212.  At the normal end of the child process, _cwait returns the process identifier 
  6213.  of the child to the parent process. If a child process ends abnormally, _cwait 
  6214.  returns -1 to the parent process and sets errno to EINTR. In the case of an 
  6215.  error, _cwait returns immediately with a value of -1 and sets errno to one of 
  6216.  the following values: 
  6217.  
  6218.  Value     Meaning 
  6219.  EINVAL    Incorrect action code. 
  6220.  ECHILD    No child process exists, or the process identifier is incorrect. 
  6221.  
  6222.  
  6223. ΓòÉΓòÉΓòÉ <hidden> Example of _cwait ΓòÉΓòÉΓòÉ
  6224.  
  6225. /************************************************************************
  6226.  
  6227. This example creates a new process called child.exe.  The parent calls _cwait 
  6228. and waits for the child to end.  The parent then displays the child's return 
  6229. information in hexadecimal. 
  6230.  
  6231. ************************************************************************/
  6232.  
  6233. #include <stdio.h>
  6234. #include <process.h>
  6235. #include <errno.h>
  6236.  
  6237. int stat_child;
  6238.  
  6239. int main(void)
  6240. {
  6241.    int i,result;
  6242.  
  6243.    /* spawn a child and 'cwait' for it to finish                              */
  6244.  
  6245.    if ((result = _spawnl(P_NOWAIT, "child", "child", "1", NULL)) != -1) {
  6246.       if ((i = _cwait(&stat_child, result, WAIT_CHILD)) != result)
  6247.          printf("Error ...expected pid from child");
  6248.       else {
  6249.          if (0 == errno) {
  6250.             printf("Child process ended successfully and ...\n");
  6251.             printf("program returned to the Parent process.\n");
  6252.          }
  6253.          else
  6254.             printf("Child process had an error\n");
  6255.       }
  6256.    }
  6257.    else
  6258.       printf("Error ...could not spawn a child process\n");
  6259.    return 0;
  6260.  
  6261.    /****************************************************************************
  6262.  
  6263.       If the source code for child.exe is:
  6264.  
  6265.       #include <stdio.h>
  6266.  
  6267.       int main(void) {
  6268.  
  6269.          puts("This line was written by child.exe");
  6270.          return 0;
  6271.       }
  6272.  
  6273.       The output should be similar to :
  6274.  
  6275.       This line was written by child.exe
  6276.       Child process ended successfully and ...
  6277.       program returned to the Parent process.
  6278.    ****************************************************************************/
  6279. }
  6280.  
  6281.  
  6282. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  6283.  
  6284. Example of cwait 
  6285.  
  6286.      exit - End Program 
  6287.      _exit - End Process 
  6288.      _spawnl - _spawnvpe - Start and Run Child Processes 
  6289.      wait - Wait for Child Process 
  6290.      return 
  6291.      <process.h> 
  6292.  
  6293.  
  6294. ΓòÉΓòÉΓòÉ 4.48. __cxchg - Exchange Character Value with Memory ΓòÉΓòÉΓòÉ
  6295.  
  6296.  
  6297. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  6298.  
  6299. #include <builtin.h>
  6300. signed char _Builtin __cxchg(volatile signed char *lockptr,
  6301.                              signed char value);
  6302.  
  6303.  
  6304. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6305.  
  6306. Language Level:  Extension 
  6307.  
  6308. __cxchg puts the specified value in the memory location pointed to by lockptr, 
  6309. and returns the value that was previously in that location. 
  6310.  
  6311. Use this function to implement fast-RAM semaphores to serialize access to a 
  6312. critical resource (so that only one thread can use it at a time). You can also 
  6313. use OS/2 semaphores to serialize resource access, but they are slower. 
  6314. Typically you would create both a fast-RAM semaphore and an OS/2 semaphore for 
  6315. the resource. For more details about OS/2 semaphores and how to use them, see 
  6316. the Control Program Guide and Reference. 
  6317.  
  6318. To implement a fast-RAM semaphore, allocate a volatile memory location (for 
  6319. __cxchg, it must be a signed char), and statically initialize it to 0 to 
  6320. indicate that the resource is free (not being used). To give a thread access to 
  6321. the resource, call __cxchg from the thread to exchange a nonzero value with 
  6322. that memory location. If __cxchg returns 0, the thread can access the resource; 
  6323. it has also set the memory location so that other threads can tell the resource 
  6324. is in use. When your thread no longer needs the resource, call __cxchg again to 
  6325. reset the memory location to 0. 
  6326.  
  6327. If __cxchg returns a nonzero value, another thread is already using the 
  6328. resource, and the calling thread must wait for access. You could then use the 
  6329. OS/2 semaphore to inform your waiting thread when the resource is unlocked by 
  6330. the thread currently using it. 
  6331.  
  6332. It is important that you set the memory to a nonzero value when you are using 
  6333. the resource.  You can use the same nonzero value for all threads, or a unique 
  6334. value for each. 
  6335.  
  6336. Note:  __cxchg is a built-in function, which means it is implemented as an 
  6337. inline instruction and has no backing code in the library.  For this reason: 
  6338.  
  6339.      You cannot take the address of __cxchg. 
  6340.      You cannot parenthesize a call to __cxchg. (Parentheses specify a call to 
  6341.       the function's backing code, and __cxchg has none.) 
  6342.  
  6343.  Return Value 
  6344.  __cxchg returns the previous value stored in the memory location pointed to by 
  6345.  lockptr. 
  6346.  
  6347.  
  6348. ΓòÉΓòÉΓòÉ <hidden> Example of __cxchg ΓòÉΓòÉΓòÉ
  6349.  
  6350. /************************************************************************
  6351.  
  6352. This example creates five separate threads, each associated with a State. At 
  6353. most two threads can have a State of Eating at the same time. When a thread 
  6354. calls PickUpChopSticks, that function checks the states of the preceding 
  6355. threads to make sure they are not already Eating, If the call to __cxchg is 
  6356. successful, the thread has locked the Lock semaphore and can change its State 
  6357. to Eating. It then calls __cxchg a second time to unlock the semaphore, and 
  6358. returns. 
  6359.  
  6360. If __cxchg cannot lock the semaphore, another thread has it locked.  The 
  6361. current thread then suspends itself briefly with DosSleep and tries again. The 
  6362. semaphore is used to ensure that two threads cannot simultaneously change their 
  6363. State to Eating, which would cause a deadlock. (Note that although the 
  6364. semaphore solves the problem of deadlock, it is not an optimal solution; some 
  6365. threads may never get the semaphore or the State of Eating.) 
  6366.  
  6367. Note:  You must compile this example with the multithread (/Gm) option. The 
  6368. example runs in an infinite loop; press Ctrl-C to end it. 
  6369.  
  6370. ************************************************************************/
  6371.  
  6372. #pragma strings(readonly)
  6373.  
  6374. #define INCL_DOS
  6375. #include <os2.h>
  6376. #include <stdlib.h>
  6377. #include <stdio.h>
  6378. #include <builtin.h>
  6379.  
  6380. typedef enum {
  6381.    Thinking,
  6382.    Eating,
  6383.    Hungry
  6384. } States;
  6385.  
  6386. #define UNLOCKED 0
  6387. #define LOCKED   1
  6388. #define NUM_PHILOSOPHERS 5
  6389.  
  6390. static volatile signed char Lock;
  6391. static States State[NUM_PHILOSOPHERS];
  6392. static const int NameMap[NUM_PHILOSOPHERS] = {0, 1, 2, 3, 4};
  6393. static const char * const Names[NUM_PHILOSOPHERS] = {"Plato",
  6394.                                                      "Socrates",
  6395.                                                      "Kant",
  6396.                                                      "Hegel",
  6397.                                                      "Nietsche"};
  6398.  
  6399. void PickUpChopSticks(int Ident);
  6400. void PutDownChopSticks(int Ident);
  6401. void Think(int Ident);
  6402. void Eat(int Ident);
  6403. void _Optlink StartPhilosopher(void *pIdent);
  6404.  
  6405. void _Optlink StartPhilosopher(void *pIdent)
  6406. {
  6407.    int Ident = *(int *)pIdent;
  6408.    while (1) {
  6409.       State[Ident] = Hungry;
  6410.       printf("%s hungry.\n", Names[Ident]);
  6411.       PickUpChopSticks(Ident);
  6412.       Eat(Ident);
  6413.       PutDownChopSticks(Ident);
  6414.       Think(Ident);
  6415.    }
  6416. }
  6417.  
  6418. int main(int argc, char *argv[], char *envp[])
  6419. {
  6420.    int           i;
  6421.    unsigned long tid;
  6422.  
  6423.    for (i = 0; i < NUM_PHILOSOPHERS; i++) {
  6424.       tid = _beginthread(StartPhilosopher, NULL, 8192, (void *)&NameMap[i]);
  6425.       if (tid == -1) {
  6426.          printf("Unable to start %s.\n", Names[i]);
  6427.       }
  6428.       else {
  6429.          printf("%s started with Thread Id = %d.\n", Names[i], tid);
  6430.       }
  6431.    }
  6432.    DosWaitThread(&tid, DCWW_WAIT);
  6433.  
  6434.    return 0;
  6435. }
  6436.  
  6437. void PickUpChopSticks(int Ident)
  6438. {
  6439.    while (1) {
  6440.       if (State[(Ident + NUM_PHILOSOPHERS - 1) % NUM_PHILOSOPHERS] != Eating &&
  6441.           State[(Ident + 1) % NUM_PHILOSOPHERS] != Eating                    &&
  6442.           !__cxchg(&Lock, LOCKED)) {
  6443.             State[Ident] = Eating;
  6444.             __cxchg(&Lock, UNLOCKED);
  6445.             return;
  6446.       }
  6447.       else {
  6448.          DosSleep(1);
  6449.       }
  6450.    }
  6451. }
  6452.  
  6453. void PutDownChopSticks(int Ident)
  6454. {
  6455.    State[Ident] = Thinking;
  6456. }
  6457.  
  6458. void Eat(int Ident)
  6459. {
  6460.    printf("%s eating.\n", Names[Ident]);
  6461.    DosSleep(1);
  6462. }
  6463.  
  6464. void Think(int Ident)
  6465. {
  6466.    printf("%s thinking.\n", Names[Ident]);
  6467.    DosSleep(1);
  6468. }
  6469.  
  6470.    /****************************************************************************
  6471.       The output should be similar to :
  6472.  
  6473.       Plato started with Thread Id = 2.
  6474.       Socrates started with Thread Id = 3.
  6475.       Kant started with Thread Id = 4.
  6476.       Hegel started with Thread Id = 5.
  6477.       Nietsche started with Thread Id = 6.
  6478.       Plato hungry.
  6479.       Plato eating.
  6480.       Socrates hungry.
  6481.       Kant hungry.
  6482.       Kant eating.
  6483.       Hegel hungry.
  6484.       Nietsche hungry.
  6485.       Kant thinking.
  6486.       Plato thinking.
  6487.       Plato hungry.
  6488.       Plato eating.
  6489.       Kant hungry.
  6490.       Kant eating.
  6491.          :
  6492.    ****************************************************************************/
  6493.  
  6494.  
  6495. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  6496.  
  6497. Exampleof __cxchg 
  6498.  
  6499.      __lxchg - Exchange Integer Value with Memory 
  6500.      __sxchg - Exchange Integer Value with Memory 
  6501.      <builtin.h> 
  6502.  
  6503.  
  6504. ΓòÉΓòÉΓòÉ 4.49. _debug_calloc - Allocate and Initialize Memory ΓòÉΓòÉΓòÉ
  6505.  
  6506.  
  6507. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  6508.  
  6509. #include <stdlib.h>   /* also in <malloc.h> */
  6510. void *_debug_calloc(size_t num, size_t size,
  6511.                     const char *file, size_t line);
  6512.  
  6513.  
  6514. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6515.  
  6516. Language Level:  Extension 
  6517.  
  6518. _debug_calloc is the debug version of calloc. Like calloc, it allocates memory 
  6519. from the default heap for an array of num elements, each of length size bytes. 
  6520. It then initializes all bits of each element to 0. 
  6521.  
  6522. In addition, _debug_calloc makes an implicit call to _heap_check, and stores 
  6523. the name of the file file and the line number line where the storage is 
  6524. allocated. This information can be used later by the _heap_check and 
  6525. _dump_allocated or _dump_allocated_delta functions. 
  6526.  
  6527. To use _debug_calloc, you must compile with the debug memory (/Tm) compiler 
  6528. option. This option maps all calloc calls to _debug_calloc (you can also call 
  6529. _debug_calloc explicitly). 
  6530.  
  6531. Note:  The /Tm option maps all calls to memory management functions (including 
  6532. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  6533. call from being mapped, parenthesize the function name. 
  6534.  
  6535. To reallocate or free memory allocated by _debug_calloc, use _debug_realloc and 
  6536. _debug_free; you can also use realloc and free if you do not want debug 
  6537. information about the operation. 
  6538.  
  6539. Heap-specific and tiled versions of this function (_debug_ucalloc and 
  6540. _debug_tcalloc) are also available. _debug_calloc always allocates memory from 
  6541. the default heap. 
  6542.  
  6543. Return Value 
  6544. _debug_calloc returns a pointer to the reserved space. If not enough memory is 
  6545. available, or if num or size is 0, _debug_calloc returns NULL. 
  6546.  
  6547.  
  6548. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_calloc ΓòÉΓòÉΓòÉ
  6549.  
  6550. /************************************************************************
  6551.  
  6552. This example reserves storage of 100 bytes.  It then attempts to write to 
  6553. storage that was not allocated.  When _debug_calloc is called again, 
  6554. _heap_check detects the error, generates several messages, and stops the 
  6555. program. 
  6556.  
  6557. Note:  You must compile this example with the /Tm option to map the calloc 
  6558. calls to _debug_calloc. 
  6559.  
  6560. ************************************************************************/
  6561.  
  6562. #include <stdlib.h>
  6563. #include <stdio.h>
  6564. #include <string.h>
  6565.  
  6566. int main(void)
  6567. {
  6568.    char *ptr1, *ptr2;
  6569.  
  6570.    if (NULL == (ptr1 = calloc(1, 100))) {
  6571.       puts("Could not allocate memory block.");
  6572.       exit(EXIT_FAILURE);
  6573.    }
  6574.    memset(ptr1, 'a', 105);    /* overwrites storage that was not allocated    */
  6575.    ptr2 = calloc(2, 20);      /* this call to calloc invokes _heap_check      */
  6576.    puts("_debug_calloc did not detect that a memory block was overwritten.");
  6577.    return 0;
  6578.  
  6579.    /****************************************************************************
  6580.       The output should be similar to:
  6581.  
  6582.       End of allocated object 0x00073890 was overwritten at 0x000738f4.
  6583.       The first eight bytes of the memory block (in hex) are: 6161616161616161.
  6584.       This memory block was (re)allocated at line number 9 in _debug_callo.c.
  6585.       Heap state was valid at line 9 of _debug_callo.c.
  6586.       Memory error detected at line 14 of _debug_callo.c.
  6587.    ****************************************************************************/
  6588. }
  6589.  
  6590.  
  6591. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  6592.  
  6593. Example of _debug_calloc 
  6594.  
  6595.      Memory Management in the Programming Guide 
  6596.      Debugging Your Heaps in the Programming Guide 
  6597.      Differentiating between Memory Management Functions 
  6598.      <malloc.h> 
  6599.      <stdlib.h> 
  6600.      calloc - Reserve and Initialize Storage 
  6601.      _debug_ucalloc - Reserve and Initialize Memory from User Heap 
  6602.      _debug_free - Release Memory 
  6603.      _debug_malloc - Allocate Memory 
  6604.      _debug_realloc - Reallocate Memory Block 
  6605.      _dump_allocated - Get Information about Allocated Memory 
  6606.      _dump_allocated_delta - Get Information about Allocated Memory 
  6607.      _heap_check - Validate Default Memory Heap 
  6608.  
  6609.  
  6610. ΓòÉΓòÉΓòÉ 4.50. _debug_free - Release Memory ΓòÉΓòÉΓòÉ
  6611.  
  6612.  
  6613. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  6614.  
  6615. #include <stdlib.h>    /* also in <malloc.h> */
  6616. void _debug_free(void *ptr, const char *file,
  6617.                         size_t line);
  6618.  
  6619.  
  6620. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6621.  
  6622. Language Level:  Extension 
  6623.  
  6624. _debug_free is the debug version of free. Like free, it frees the block of 
  6625. memory pointed to by ptr. _debug_free also sets each block of freed memory to 
  6626. 0xFB, so you can easily locate instances where your program uses the data in 
  6627. freed memory. 
  6628.  
  6629. In addition, _debug_free makes an implicit call to the _heap_check, and stores 
  6630. the file name file and the line number line where the memory is freed. This 
  6631. information can be used later by the _heap_check and _dump_allocated or 
  6632. _dump_allocated_delta functions. 
  6633.  
  6634. To use _debug_free, you must compile with the debug memory (/Tm) compiler 
  6635. option. This option maps all free calls to _debug_free (you can also call 
  6636. _debug_free explicitly). 
  6637.  
  6638. Note:  The /Tm option maps all calls to memory management functions (including 
  6639. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  6640. call from being mapped, parenthesize the function name. 
  6641.  
  6642. Because _debug_free always checks what heap the memory was allocated from, you 
  6643. can use _debug_free to free memory blocks allocated by the regular, tiled, 
  6644. heap-specific, or debug versions of the memory management functions. However, 
  6645. if the memory was not allocated by the memory management functions, or was 
  6646. previously freed, _debug_free generates an error message and the program ends. 
  6647.  
  6648. A tiled version of this function, _debug_tfree, is also available. 
  6649.  
  6650. Return Value 
  6651. There is no return value. 
  6652.  
  6653.  
  6654. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_free ΓòÉΓòÉΓòÉ
  6655.  
  6656. /************************************************************************
  6657.  
  6658. This example reserves two blocks, one of 10 bytes and the other of 20 bytes. 
  6659. It then frees the first block and attempts to overwrite the freed storage. When 
  6660. _debug_free is called a second time, _heap_check detects the error, prints out 
  6661. several messages, and stops the program. 
  6662.  
  6663. Note:  You must compile this example with the /Tm option to map the free calls 
  6664. to _debug_free. 
  6665.  
  6666. ************************************************************************/
  6667.  
  6668. #include <stdlib.h>
  6669. #include <stdio.h>
  6670.  
  6671. int main(void)
  6672. {
  6673.    char *ptr1, *ptr2;
  6674.  
  6675.    if (NULL == (ptr1 = malloc(10)) || NULL == (ptr2 = malloc(20))) {
  6676.       puts("Could not allocate memory block.");
  6677.       exit(EXIT_FAILURE);
  6678.    }
  6679.    free(ptr1);
  6680.    memset(ptr1, 'a', 5);      /* overwrites storage that has been freed       */
  6681.    free(ptr2);                 /* this call to free invokes _heap_check       */
  6682.    puts("_debug_free did not detect that a freed memory block was overwritten.");
  6683.    return 0;
  6684.  
  6685.    /****************************************************************************
  6686.       The output should be similar to:
  6687.  
  6688.       Free heap was overwritten at 0x00073890.
  6689.       Heap state was valid at line 12 of _debug_free.c.
  6690.       Memory error detected at line 14 of _debug_free.c.
  6691.    ****************************************************************************/
  6692. }
  6693.  
  6694.  
  6695. ΓòÉΓòÉΓòÉ <hidden> Information ΓòÉΓòÉΓòÉ
  6696.  
  6697. Example of _debug_free 
  6698.  
  6699.      Memory Management in the Programming Guide 
  6700.      Debugging Your Heaps in the Programming Guide 
  6701.      Differentiating between Memory Management Functions 
  6702.      _debug_calloc - Allocate and Initialize Memory 
  6703.      _debug_malloc - Allocate Memory 
  6704.      _debug_realloc - Reallocate Memory Block 
  6705.      _dump_allocated - Get Information about Allocated Memory 
  6706.      _dump_allocated_delta - Get Information about Allocated Memory 
  6707.      free - Release Storage Blocks 
  6708.      _heap_check - Validate Default Memory Heap 
  6709.      <malloc.h> 
  6710.      <stdlib.h> 
  6711.  
  6712.  
  6713. ΓòÉΓòÉΓòÉ 4.51. _debug_heapmin - Release Unused Memory in the Default Heap ΓòÉΓòÉΓòÉ
  6714.  
  6715.  
  6716. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  6717.  
  6718. #include <stdlib.h>  /* also in <malloc.h> */
  6719. int _debug_heapmin(const char *file, size_t line);
  6720.  
  6721.  
  6722. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6723.  
  6724. Language Level:  Extension 
  6725.  
  6726. _debug_heapmin is the debug version of _heapmin. Like _heapmin, It returns all 
  6727. unused memory from the default runtime heap to the operating system. 
  6728.  
  6729. In addition, _debug_heapmin makes an implicit call to _heap_check, and stores 
  6730. the file name file and the line number line where the memory is returned.  This 
  6731. information can be used later by the _heap_check function. 
  6732.  
  6733. To use _debug_heapmin, you must compile with the debug memory (/Tm) compiler 
  6734. option. This option maps all _heapmin calls to _debug_heapmin (you can also 
  6735. call _debug_heapmin explicitly). 
  6736.  
  6737. Note:  The /Tm option maps all calls to memory management functions (including 
  6738. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  6739. call from being mapped, parenthesize the function name. 
  6740.  
  6741. Heap-specific and tiled versions of this function (_debug_uheapmin and 
  6742. _debug_theapmin) are also available. _debug_heapmin always operates on the 
  6743. default heap. 
  6744.  
  6745. Return Value 
  6746. If successful, _debug_heapmin returns 0; otherwise, it returns -1. 
  6747.  
  6748.  
  6749. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_heapmin ΓòÉΓòÉΓòÉ
  6750.  
  6751. /************************************************************************
  6752.  
  6753. This example allocates 10000 bytes of storage, changes the storage size to 10 
  6754. bytes, and then uses _debug_heapmin to return the unused memory to the 
  6755. operating system. The program then attempts to overwrite memory that was not 
  6756. allocated. When _debug_heapmin is called again, _heap_check detects the error, 
  6757. generates several messages, and stops the program. 
  6758.  
  6759. Note:  You must compile this example with the /Tm option to map the _heapmin 
  6760. calls to _debug_heapmin. 
  6761.  
  6762. ************************************************************************/
  6763.  
  6764. #include <stdlib.h>
  6765. #include <stdio.h>
  6766.  
  6767. int main(void)
  6768. {
  6769.    char *ptr;
  6770.  
  6771.    /* Allocate a large object from the system */
  6772.    if (NULL == (ptr = malloc(100000))) {
  6773.       puts("Could not allocate memory block.");
  6774.       exit(EXIT_FAILURE);
  6775.    }
  6776.    ptr = realloc(ptr, 10);
  6777.    _heapmin();                /* No allocation problems to detect             */
  6778.  
  6779.    *(ptr - 1) = 'a';          /* Overwrite memory that was not allocated      */
  6780.    _heapmin();                /* This call to _heapmin invokes _heap_check    */
  6781.  
  6782.    puts("_debug_heapmin did not detect that a non-allocated memory block"
  6783.         "was overwritten.");
  6784.    return 0;
  6785.  
  6786.    /****************************************************************************
  6787.       Possible output is:
  6788.  
  6789.       Header information of object 0x000738b0 was overwritten at 0x000738ac.
  6790.       The first eight bytes of the memory block (in hex) are: AAAAAAAAAAAAAAAA.
  6791.       This memory block was (re)allocated at line number 13 in _debug_heapm.c.
  6792.       Heap state was valid at line 14 of _debug_heapm.c.
  6793.       Memory error detected at line 17 of _debug_heapm.c.
  6794.    ****************************************************************************/
  6795. }
  6796.  
  6797.  
  6798. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  6799.  
  6800. Example of _debug_heapmin 
  6801.  
  6802.      Memory Management in the Programming Guide 
  6803.      Debugging Your Heaps in the Programming Guide 
  6804.      Differentiating between Memory Management Functions 
  6805.      _debug_heapmin - Release Unused Memory in the Default Heap 
  6806.      _dump_allocated - Get Information about Allocated Memory 
  6807.      _dump_allocated_delta - Get Information about Allocated Memory 
  6808.      _heapmin - Release Unused Memory from Default Heap 
  6809.      _heap_check - Validate Default Memory Heap 
  6810.      <malloc.h> 
  6811.      <stdlib.h> 
  6812.  
  6813.  
  6814. ΓòÉΓòÉΓòÉ 4.52. _debug_malloc - Allocate Memory ΓòÉΓòÉΓòÉ
  6815.  
  6816.  
  6817. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  6818.  
  6819. #include <stdlib.h>  /* also in <malloc.h> */
  6820. void *_debug_malloc(size_t size,
  6821.                     const char *file, size_t line);
  6822.  
  6823.  
  6824. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6825.  
  6826. Language Level:  Extension 
  6827.  
  6828. _debug_malloc is the debug version of malloc. Like malloc, it reserves a block 
  6829. of storage of size bytes from the default heap. _debug_malloc also sets all the 
  6830. memory it allocates to 0xAA, so you can easily locate instances where your 
  6831. program uses the data in the memory without initializing it first. 
  6832.  
  6833. In addition, _debug_malloc makes an implicit call to _heap_check, and stores 
  6834. the file name file and the line number line where the storage is allocated. 
  6835. This information can later be used by the _heap_check and _dump_allocated or 
  6836. _dump_allocated_delta functions. 
  6837.  
  6838. To use _debug_malloc, you must compile with the debug memory (/Tm) compiler 
  6839. option. This option maps all malloc calls to _debug_malloc (you can also call 
  6840. _debug_malloc explicitly). 
  6841.  
  6842. Note:  The /Tm option maps all calls to memory management functions (including 
  6843. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  6844. call from being mapped, parenthesize the function name. 
  6845.  
  6846. To reallocate or free memory allocated by _debug_malloc, use _debug_realloc and 
  6847. _debug_free; you can also use realloc and free if you do not want debug 
  6848. information about the operation. 
  6849.  
  6850. Heap-specific and tiled versions of this function (_debug_umalloc and 
  6851. _debug_tmalloc) are also available. _debug_malloc always allocates memory from 
  6852. the default heap. 
  6853.  
  6854. Return Value 
  6855. _debug_malloc returns a pointer to the reserved space. If not enough memory is 
  6856. available or if size is 0, _debug_malloc returns NULL. 
  6857.  
  6858.  
  6859. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_malloc ΓòÉΓòÉΓòÉ
  6860.  
  6861. /************************************************************************
  6862.  
  6863. This example allocates 100 bytes of storage.  It then attempts to write to 
  6864. storage that was not allocated. When _debug_malloc is called again, _heap_check 
  6865. detects the error, generates several messages, and stops the program. 
  6866.  
  6867. Note:  You must compile this example with the /Tm option to map the malloc 
  6868. calls to _debug_malloc. 
  6869.  
  6870. ************************************************************************/
  6871.  
  6872. #include <stdlib.h>
  6873. #include <stdio.h>
  6874.  
  6875. int main(void)
  6876. {
  6877.    char *ptr1, *ptr2;
  6878.  
  6879.    if (NULL == (ptr1 = malloc(100))) {
  6880.       puts("Could not allocate memory block.");
  6881.       exit(EXIT_FAILURE);
  6882.    }
  6883.    *(ptr1 - 1) = 'a';        /* overwrites storage that was not allocated    */
  6884.    ptr2 = malloc(10);        /* this call to malloc invokes _heap_check      */
  6885.    puts("_debug_malloc did not detect that a memory block was overwritten.");
  6886.    return 0;
  6887.  
  6888.    /****************************************************************************
  6889.       Possible output is:
  6890.  
  6891.       Header information of object 0x00073890 was overwritten at 0x0007388c.
  6892.       The first eight bytes of the memory block (in hex) are: AAAAAAAAAAAAAAAA.
  6893.       This memory block was (re)allocated at line number 8 in _debug_mallo.c.
  6894.       Heap state was valid at line 8 of _debug_mallo.c.
  6895.       Memory error detected at line 13 of _debug_mallo.c.
  6896.    ****************************************************************************/
  6897. }
  6898.  
  6899.  
  6900. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  6901.  
  6902. Example of _debug_malloc 
  6903.  
  6904.      Memory Management in the Programming Guide 
  6905.      Debugging Your Heaps in the Programming Guide 
  6906.      Differentiating between Memory Management Functions 
  6907.      _debug_calloc - Allocate and Initialize Memory 
  6908.      _debug_free - Release Memory 
  6909.      _debug_realloc - Reallocate Memory Block 
  6910.      _debug_umalloc - Reserve Memory Blocks from User Heap 
  6911.      _dump_allocated - Get Information about Allocated Memory 
  6912.      _dump_allocated_delta - Get Information about Allocated Memory 
  6913.      _heap_check - Validate Default Memory Heap 
  6914.      malloc - Reserve Storage Block 
  6915.      <malloc.h> 
  6916.      <stdlib.h> 
  6917.  
  6918.  
  6919. ΓòÉΓòÉΓòÉ 4.53. _debug_realloc - Reallocate Memory Block ΓòÉΓòÉΓòÉ
  6920.  
  6921.  
  6922. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  6923.  
  6924. #include <stdlib.h>  /* also in <malloc.h> */
  6925. void *_debug_realloc(void *ptr, size_t size,
  6926.                      const char *file, size_t line);
  6927.  
  6928.  
  6929. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  6930.  
  6931. Language Level:  Extension 
  6932.  
  6933. _debug_realloc is the debug version of realloc. Like realloc, it reallocates 
  6934. the block of memory pointed to by ptr to a new size, specified in bytes. It 
  6935. also sets any new memory  it allocates to 0xAA, so you can easily locate 
  6936. instances where your program tries to use the data in that memory without 
  6937. initializing it first. 
  6938.  
  6939. In addition, _debug_realloc makes an implicit call to _heap_check, and stores 
  6940. the file name file and the line number line where the storage is reallocated. 
  6941. This information can be used later by the _heap_check and _dump_allocated or 
  6942. _dump_allocated_delta functions. 
  6943.  
  6944. If ptr is NULL, _debug_realloc behaves like _debug_malloc (or malloc) and 
  6945. allocates the block of memory. 
  6946.  
  6947. To use _debug_realloc, you must compile with the debug memory (/Tm) compiler 
  6948. option. This option maps all realloc calls to _debug_realloc (you can also call 
  6949. _debug_realloc explicitly). 
  6950.  
  6951. Note:  The /Tm option maps all calls to memory management functions (including 
  6952. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  6953. call from being mapped, parenthesize the function name. 
  6954.  
  6955. Because _debug_realloc always checks what heap the memory was allocated from, 
  6956. you can use _debug_realloc to reallocate memory blocks allocated by the 
  6957. regular, tiled heap-specific, or debug versions of the memory management 
  6958. functions.  However, if the memory was not allocated by the memory management 
  6959. functions, or was previously freed, _debug_realloc generates an error message 
  6960. and the program ends. 
  6961.  
  6962. A tiled version of this function, _debug_trealloc, is also available. 
  6963.  
  6964. Return Value 
  6965. _debug_realloc returns a pointer to the reallocated memory block. The ptr 
  6966. argument to _debug_realloc is not the same as the return value; _debug_realloc 
  6967. always changes the memory location to help you locate references to the memory 
  6968. that were not freed before the memory was reallocated. 
  6969.  
  6970. If size is 0, _debug_realloc returns NULL. If not enough memory is available to 
  6971. expand the block to the given size, the original block is unchanged and NULL is 
  6972. returned. 
  6973.  
  6974.  
  6975. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_realloc ΓòÉΓòÉΓòÉ
  6976.  
  6977. /************************************************************************
  6978.  
  6979. This example uses _debug_realloc to allocate 100 bytes of storage. It then 
  6980. attempts to write to storage that was not allocated. When _debug_realloc is 
  6981. called again, _heap_check detects the error, generates several messages, and 
  6982. stops the program. 
  6983.  
  6984. Note:  You must compile this example with the /Tm option to map the realloc 
  6985. calls to _debug_realloc. 
  6986.  
  6987. ************************************************************************/
  6988.  
  6989. #include <stdlib.h>
  6990. #include <stdio.h>
  6991.  
  6992. int main(void)
  6993. {
  6994.    char *ptr;
  6995.  
  6996.    if (NULL == (ptr = realloc(NULL, 100))) {
  6997.       puts("Could not allocate memory block.");
  6998.       exit(EXIT_FAILURE);
  6999.    }
  7000.    memset(ptr, 'a', 105);     /* overwrites storage that was not allocated    */
  7001.    ptr = realloc(ptr, 200);   /* this call to realloc invokes _heap_check     */
  7002.    puts("_debug_realloc did not detect that a memory block was overwritten." );
  7003.    return 0;
  7004.  
  7005.    /****************************************************************************
  7006.       The output should be similar to:
  7007.  
  7008.       End of allocated object 0x00073890 was overwritten at 0x000738f4.
  7009.       The first eight bytes of the memory block (in hex) are: 6161616161616161.
  7010.       This memory block was (re)allocated at line number 8 in _debug_reall.c.
  7011.       Heap state was valid at line 8 of _debug_reall.c.
  7012.       Memory error detected at line 13 of _debug_reall.c.
  7013.    ****************************************************************************/
  7014. }
  7015.  
  7016.  
  7017. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7018.  
  7019. Example of _debug_realloc 
  7020.  
  7021.      Memory Management in the Programming Guide 
  7022.      Debugging Your Heaps in the Programming Guide 
  7023.      Differentiating between Memory Management Functions 
  7024.      _debug_calloc - Allocate and Initialize Memory 
  7025.      _debug_free - Release Memory 
  7026.      _debug_malloc - Allocate Memory 
  7027.      _dump_allocated - Get Information about Allocated Memory 
  7028.      _dump_allocated_delta - Get Information about Allocated Memory 
  7029.      _heap_check - Validate Default Memory Heap 
  7030.      realloc - Change Reserved Storage Block Size 
  7031.      <malloc.h> 
  7032.      <stdlib.h> 
  7033.  
  7034.  
  7035. ΓòÉΓòÉΓòÉ 4.54. _debug_tcalloc - Reserve and Initialize Tiled Memory ΓòÉΓòÉΓòÉ
  7036.  
  7037.  
  7038. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7039.  
  7040. #include <stdlib.h>   /* also in <malloc.h>  */
  7041. void *_debug_tcalloc(size_t num, size_t size,
  7042.                      const char *file, size_t line);
  7043.  
  7044.  
  7045. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7046.  
  7047. Language Level:  Extension 
  7048.  
  7049. _debug_tcalloc is the debug version of _tcalloc. Like _tcalloc, it allocates 
  7050. tiled memory from the tiled runtime heap for an array of num elements, each of 
  7051. length size bytes. It then initializes all bits of each element to 0. 
  7052.  
  7053. In addition, _debug_tcalloc makes an implicit call to _theap_check, and stores 
  7054. the name of the file file and the line number line where the storage is 
  7055. allocated. This information can be used later by the _theap_check and 
  7056. _tdump_allocated or _tdump_allocated_delta functions. 
  7057.  
  7058. To use _debug_tcalloc, you must compile with the debug memory and tiled memory 
  7059. compiler options (/Tm /Gt). These options map all calloc calls to 
  7060. _debug_tcalloc (you can also call _debug_tcalloc explicitly). 
  7061.  
  7062. Note:  The /Tm /Gt options map all calls to regular memory management functions 
  7063. to their tiled debug versions. To prevent a call from being mapped, 
  7064. parenthesize the function name. 
  7065.  
  7066. To reallocate or free memory allocated with _debug_tcalloc, use _debug_trealloc 
  7067. and _debug_tfree; you can also use _trealloc and _tfree if you don't want debug 
  7068. information about the operation. 
  7069.  
  7070. _debug_tcalloc works just like _debug_calloc except that it allocates tiled 
  7071. memory instead of regular memory. If you have objects that may be accessed by 
  7072. 16-bit code, you should store them in tiled memory. Tiled memory is guaranteed 
  7073. not to cross 64K boundaries, as long as the object is less than 64K in size. 
  7074. Objects larger than 64K in size are aligned on 64K boundaries, but will also 
  7075. cross 64K boundaries. You can also create your own heaps of tiled memory. See 
  7076. "Managing Memory" in the Programming Guide for more information. 
  7077.  
  7078. Return Value 
  7079. _debug_tcalloc returns a pointer to the reserved space. If size or num was 
  7080. specified as zero, _debug_tcalloc returns NULL. 
  7081.  
  7082.  
  7083. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_tcalloc ΓòÉΓòÉΓòÉ
  7084.  
  7085. /************************************************************************
  7086.  
  7087. This example reserves 100 bytes of tiled memory. It then attempts to write to 
  7088. storage that was not allocated. The second _debug_tcalloc call invokes 
  7089. _theap_check, which detects the error, generates several messages, and stops 
  7090. the program. 
  7091.  
  7092. Note:  You must compile this program with the /Tm /Gt options to map the calloc 
  7093. calls to _debug_tcalloc 
  7094.  
  7095. *********************************************************************** /
  7096.  
  7097. #include <stdlib.h>
  7098. #include <stdio.h>
  7099. #include <string.h>
  7100.  
  7101. int main(void)
  7102. {
  7103.    char *ptr;
  7104.  
  7105.    /* calloc is mapped to _debug_tcalloc */
  7106.    if (NULL == (ptr = calloc(1, 100))) {
  7107.       puts("Could not allocate memory block.\n");
  7108.       exit(EXIT_FAILURE);
  7109.    }
  7110.    memset (ptr, 'x', 105);  /* Overwrites storage that was not allocated */
  7111.    free(ptr);
  7112.    return 0;
  7113.  
  7114.    /****************************************************************************
  7115.       The output should be similar to :
  7116.  
  7117.       End of allocated object 0x00080120 was overwritten at 0x00080184.
  7118.       The first eight bytes of the memory block (in hex) are: 7878787878787878.
  7119.       This memory block was (re)allocated at line number 10 in _debug_tcallo.c.
  7120.       Heap state was valid at line 10 of _debug_tcallo.c.
  7121.       Memory error detected at line 15 of _debug_tcallo.c.
  7122.    ****************************************************************************/
  7123. }
  7124.  
  7125.  
  7126. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7127.  
  7128. Example of _debug_tcalloc 
  7129.  
  7130.      "Managing Memory" in the Programming Guide 
  7131.      "Debugging Your Heaps" in the Programming Guide 
  7132.      Tiled Debug Functions 
  7133.      calloc - Reserve and Initialize Storage 
  7134.      _debug_calloc - Allocate and Initialize Memory 
  7135.      _debug_tfree - Release Tiled Memory 
  7136.      _debug_tmalloc - Reserve Tiled Memory 
  7137.      _debug_trealloc - Reallocate Tiled Memory Block 
  7138.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  7139.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  7140.      _theap_check - Validate User Memory Heap 
  7141.      <malloc.h> 
  7142.      <stdlib.h> 
  7143.  
  7144.  
  7145. ΓòÉΓòÉΓòÉ 4.55. _debug_tfree - Release Tiled Memory ΓòÉΓòÉΓòÉ
  7146.  
  7147.  
  7148. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7149.  
  7150. #include <stdlib.h>    /* also in <malloc.h> */
  7151. void _debug_tfree(void *ptr, const char *file,
  7152.                   size_t line);
  7153.  
  7154.  
  7155. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7156.  
  7157. Language Level:  Extension 
  7158.  
  7159. _debug_tfree is the debug version of _tfree. Like _tfree, it frees the block of 
  7160. tiled memory pointed to by ptr. _debug_tfree also sets each block of freed 
  7161. memory to 0xFB, so you can easily locate instances where your program uses the 
  7162. data in freed memory. 
  7163.  
  7164. In addition, _debug_tfree makes an implicit call to the _theap_check, and 
  7165. stores the file name file and the line number line where the memory is freed. 
  7166. This information can be used later by the _theap_check and _tdump_allocated or 
  7167. _tdump_allocated_delta functions. 
  7168.  
  7169. To use _debug_tfree, you must compile with the debug memory and tiled memory 
  7170. compiler options (/Tm /Gt). These options map all free calls to _debug_tfree 
  7171. (you can also call _debug_tfree explicitly). 
  7172.  
  7173. Note:  The /Tm /Gt options map all calls to regular memory management functions 
  7174. to their tiled debug versions. To prevent a call from being mapped, 
  7175. parenthesize the function name. 
  7176.  
  7177. _debug_tfree works just like _debug_free except that it frees tiled memory 
  7178. instead of regular memory. If you have objects that may be accessed by 16-bit 
  7179. code, you should store them in tiled memory. Tiled memory is guaranteed not to 
  7180. cross 64K boundaries, as long as the object is less than 64K in size. Objects 
  7181. larger than 64K in size are aligned on 64K boundaries, but will also cross 64K 
  7182. boundaries. You can also create your own heaps of tiled memory. See "Managing 
  7183. Memory" in the Programming Guide for more information. 
  7184.  
  7185. Return Value 
  7186. There is no return value. 
  7187.  
  7188.  
  7189. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_tfree ΓòÉΓòÉΓòÉ
  7190.  
  7191. /************************************************************************
  7192.  
  7193. This example allocates a 100-byte block of memory. It then frees the block 
  7194. twice. The second _debug_tfree call invokes _theap_check, which detects the 
  7195. error, generates several messages, and stops the program. 
  7196.  
  7197. Note:  You must compile this example with the /Tm /Gt options to map the free 
  7198. calls to _debug_tfree. 
  7199.  
  7200. *********************************************************************** /
  7201.  
  7202. #include <stdlib.h>
  7203. #include <stdio.h>
  7204.  
  7205. int main(void)
  7206. {
  7207.    char *ptr;
  7208.  
  7209.    if (NULL == (ptr = malloc(100))) {
  7210.       puts("Could not allocate memory block.\n");
  7211.       exit(EXIT_FAILURE);
  7212.    }
  7213.    free(ptr);   /* free the object */
  7214.    free(ptr);   /* free the object again should cause an error */
  7215.    return 0;
  7216.  
  7217.    /****************************************************************************
  7218.       The output should be similar to :
  7219.  
  7220.       Object 0x00080120 provided is either invalid or was overwritten at
  7221.       0x0008011c.
  7222.       Memory error detected at line 13 of _debug_tfree.c.
  7223.    ****************************************************************************/
  7224. }
  7225.  
  7226.  
  7227. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7228.  
  7229. Example of _debug_tfree 
  7230.  
  7231.      "Managing Memory" in the Programming Guide 
  7232.      "Debugging Your Heaps" in the Programming Guide 
  7233.      Tiled Debug Functions 
  7234.      _debug_free - Release Memory 
  7235.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  7236.      _debug_tmalloc - Reserve Tiled Memory 
  7237.      _debug_trealloc - Reallocate Tiled Memory Block 
  7238.      free - Release Storage Blocks 
  7239.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  7240.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  7241.      _tfree - Free Tiled Storage Block 
  7242.      _theap_check - Validate User Memory Heap 
  7243.      <malloc.h> 
  7244.      <stdlib.h> 
  7245.  
  7246.  
  7247. ΓòÉΓòÉΓòÉ 4.56. _debug_theapmin - Release Unused Tiled Memory ΓòÉΓòÉΓòÉ
  7248.  
  7249.  
  7250. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7251.  
  7252. #include <stdlib.h>   /* also in <malloc.h> */
  7253. int _debug_theapmin(const char *file, size_t line);
  7254.  
  7255.  
  7256. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7257.  
  7258. Language Level:  Extension 
  7259.  
  7260. _debug_theapmin is the debug version of _theapmin. Like _theapmin, it returns 
  7261. all unused blocks of tiled memory to the tiled runtime heap. 
  7262.  
  7263. In addition, _debug_theapmin makes an implicit call to _theap_check to validate 
  7264. the heap. 
  7265.  
  7266. To use _debug_theapmin, you must compile with the debug memory and tiled memory 
  7267. compiler options (/Tm /Gt). These options map all _heapmin calls to 
  7268. _debug_theapmin (you can also call _debug_theapmin explicitly). 
  7269.  
  7270. Note:  The /Tm /Gt options map all calls to regular memory management functions 
  7271. to their tiled debug versions. To prevent a call from being mapped, 
  7272. parenthesize the function name. 
  7273.  
  7274. _debug_theapmin works just like _debug_heapmin except that it releases only 
  7275. memory allocated with the tiled memory management functions. 
  7276.  
  7277. Return Value 
  7278. If successful, _debug_theapmin returns 0. A non-zero return value indicates 
  7279. failure. If the heap specified is not valid, _debug_theapmin generates an error 
  7280. message with the file name and line number where the call to _debug_theapmin 
  7281. was made. 
  7282.  
  7283.  
  7284. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_theapmin ΓòÉΓòÉΓòÉ
  7285.  
  7286. /************************************************************************
  7287.  
  7288. This example allocates 60000 bytes of memory, then frees it. The freed memory 
  7289. is kept in the default runtime heap until the call to _debug_theapmin returns 
  7290. it to the operating system. Because no errors are detected by _theap_check, no 
  7291. messages are generated. 
  7292.  
  7293. Note:  You must compile this example with the /Tm /Gt options to map the 
  7294. _heapmin calls to _debug_theapmin. 
  7295.  
  7296. *********************************************************************** /
  7297.  
  7298. #include <stdlib.h>
  7299. #include <stdio.h>
  7300.  
  7301. int main(void)
  7302. {
  7303.    char *ptr;
  7304.  
  7305.    /* Allocate a large object from the system. */
  7306.    if (NULL == (ptr = malloc(60000))) {
  7307.       puts("Could not allocate memory block.\n");
  7308.       exit(EXIT_FAILURE);
  7309.    }
  7310.    memset(ptr, 'x', 60000);
  7311.  
  7312.    /* The free will keep large object in runtime. */
  7313.    free(ptr);
  7314.  
  7315.    /* _debug_theapmin will attempt to return the freed object to the system. */
  7316.    if (0 != _heapmin()) {
  7317.       puts("_debug_theapmin returns failed.\n");
  7318.       exit(EXIT_FAILURE);
  7319.    }
  7320.    return 0;
  7321. }
  7322.  
  7323.  
  7324. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7325.  
  7326. Example of _debug_theapmin 
  7327.  
  7328.      "Managing Memory" in the Programming Guide 
  7329.      "Debugging Your Heaps" in the Programming Guide 
  7330.      Tiled Debug Functions 
  7331.      _debug_heapmin - Release Unused Memory in the Default Heap 
  7332.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  7333.      _debug_tfree - Release Tiled Memory 
  7334.      _debug_tmalloc - Reserve Tiled Memory 
  7335.      _heapmin - Release Unused Memory from Default Heap 
  7336.      _theap_check - Validate User Memory Heap 
  7337.      <malloc.h> 
  7338.      <stdlib.h> 
  7339.  
  7340.  
  7341. ΓòÉΓòÉΓòÉ 4.57. _debug_tmalloc - Reserve Tiled Memory ΓòÉΓòÉΓòÉ
  7342.  
  7343.  
  7344. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7345.  
  7346. #include <stdlib.h>   /* also in <malloc.h> */
  7347. void *_debug_tmalloc(size_t size,
  7348.                      const char *file, size_t line);
  7349.  
  7350.  
  7351. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7352.  
  7353. Language Level:  Extension 
  7354.  
  7355. _debug_tmalloc is the debug version of _tmalloc. Like _tmalloc, it allocates 
  7356. tiled memory from the tiled runtime heap for an object of length size bytes. 
  7357. _debug_tmalloc also sets all the memory it allocates to 0xAA, so you can easily 
  7358. locate instances where your program uses the data in the memory without 
  7359. initializing it first. 
  7360.  
  7361. In addition, _debug_tmalloc makes an implicit call to _theap_check, and stores 
  7362. the name of the file file and the line number line where the storage is 
  7363. allocated. This information can be used later by the _theap_check and 
  7364. _tdump_allocated or _tdump_allocated_delta functions. 
  7365.  
  7366. To use _debug_tmalloc, you must compile with the debug memory and tiled memory 
  7367. compiler options (/Tm /Gt). These options map all malloc calls to 
  7368. _debug_tmalloc (you can also call _debug_tmalloc explicitly). 
  7369.  
  7370. Note:  The /Tm /Gt options map all calls to regular memory management functions 
  7371. to their tiled debug versions. To prevent a call from being mapped, 
  7372. parenthesize the function name. 
  7373.  
  7374. _debug_tmalloc works just like _debug_malloc except that it allocates tiled 
  7375. memory instead of regular memory. If you have objects that may be accessed by 
  7376. 16-bit code, you should store them in tiled memory. Tiled memory is guaranteed 
  7377. not to cross 64K boundaries, as long as the object is less than 64K in size. 
  7378. Objects larger than 64K in size are aligned on 64K boundaries, but will also 
  7379. cross 64K boundaries. You can also create your own heaps of tiled memory. See 
  7380. "Managing Memory" in the Programming Guide for more information. 
  7381.  
  7382. To reallocate or free memory allocated with _debug_tmalloc, use _debug_trealloc 
  7383. and _debug_tfree; you can also use _trealloc and _tfree if you don't want debug 
  7384. information about the operation. 
  7385.  
  7386. Return Value 
  7387. _debug_tmalloc returns a pointer to the reserved space. If size was specified 
  7388. as zero, _debug_tmalloc returns NULL. 
  7389.  
  7390.  
  7391. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_tmalloc ΓòÉΓòÉΓòÉ
  7392.  
  7393. /************************************************************************
  7394.  
  7395. This example allocates 100 bytes of memory, then tries to write to memory that 
  7396. was not allocated. The call to _debug_tfree invokes _theap_check, which detects 
  7397. the error, generates several messages, and stops the program. 
  7398.  
  7399. Note:  You must compile this example with the /Tm /Gt options to map the free 
  7400. calls to _debug_tfree. 
  7401.  
  7402. *********************************************************************** /
  7403.  
  7404. #include <stdlib.h>
  7405. #include <stdio.h>
  7406. #include <string.h>
  7407.  
  7408. int main(void)
  7409. {
  7410.    char *ptr;
  7411.  
  7412.    /* malloc is mapped to _debug_tmalloc */
  7413.    if (NULL == (ptr = malloc(100))) {
  7414.       puts("Could not allocate memory block.\n");
  7415.       exit(EXIT_FAILURE);
  7416.    }
  7417.    memset (ptr, 'x', 105);  /* Overwrites storage that was not allocated */
  7418.    free(ptr);
  7419.    return 0;
  7420.  
  7421.    /****************************************************************************
  7422.       The output should be similar to :
  7423.  
  7424.       End of allocated object 0x00080120 was overwritten at 0x00080184.
  7425.       The first eight bytes of the memory block (in hex) are: 7878787878787878.
  7426.       This memory block was (re)allocated at line number 10 in _debug_tmallo.c.
  7427.       Heap state was valid at line 10 of _debug_tmallo.c.
  7428.       Memory error detected at line 15 of _debug_tmallo.c.
  7429.    ****************************************************************************/
  7430. }
  7431.  
  7432.  
  7433. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7434.  
  7435. Example of _debug_tmalloc 
  7436.  
  7437.      "Managing Memory" in the Programming Guide 
  7438.      "Debugging Your Heaps" in the Programming Guide 
  7439.      Tiled Debug Functions 
  7440.      _debug_malloc - Allocate Memory 
  7441.      _debug_tfree - Release Tiled Memory 
  7442.      _debug_tmalloc - Reserve Tiled Memory 
  7443.      _debug_trealloc - Reallocate Tiled Memory Block 
  7444.      malloc - Reserve Storage Block 
  7445.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  7446.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  7447.      _theap_check - Validate User Memory Heap 
  7448.      <malloc.h> 
  7449.      <stdlib.h> 
  7450.  
  7451.  
  7452. ΓòÉΓòÉΓòÉ 4.58. _debug_trealloc - Reallocate Tiled Memory Block ΓòÉΓòÉΓòÉ
  7453.  
  7454.  
  7455. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7456.  
  7457. #include <stdlib.h>   /* also in <malloc.h> */
  7458. void *_debug_trealloc(void *ptr, size_t size,
  7459.                      const char *file, size_t line);
  7460.  
  7461.  
  7462. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7463.  
  7464. Language Level:  Extension 
  7465.  
  7466. The _debug_trealloc function is the debug version of _trealloc. Like _trealloc, 
  7467. it reallocates the block of tiled memory pointed to by ptr to a new size, 
  7468. specified in bytes. The block of memory must have been allocated using a tiled 
  7469. memory management function. _debug_trealloc also sets any new memory it 
  7470. allocates to 0xAA, so you can easily locate instances where your program tries 
  7471. to use the data in memory without initializing it first. 
  7472.  
  7473. In addition, _debug_trealloc makes an implicit call to _theap_check, and stores 
  7474. the file name file and the line number line where the storage is reallocated. 
  7475. This information can be used later by the _theap_check and _tdump_allocated or 
  7476. _tdump_allocated_delta functions. 
  7477.  
  7478. If ptr is NULL, _debug_trealloc behaves like _debug_tmalloc (or malloc) and 
  7479. allocates the block of memory. 
  7480.  
  7481. To use _debug_trealloc, you must compile with the debug memory and tiled memory 
  7482. compiler options (/Tm /Gt). These options map all realloc calls to 
  7483. _debug_trealloc (you can also call _debug_trealloc explicitly). 
  7484.  
  7485. Note:  The /Tm /Gt options map all calls to regular memory management functions 
  7486. to their tiled debug versions. To prevent a call from being mapped, 
  7487. parenthesize the function name. 
  7488.  
  7489. _debug_trealloc works just like _debug_realloc except that it reallocates tiled 
  7490. memory instead of regular memory. If you have objects that may be accessed by 
  7491. 16-bit code, you should store them in tiled memory. Tiled memory is guaranteed 
  7492. not to cross 64K boundaries, as long as the object is less than 64K in size. 
  7493. Objects larger than 64K in size are aligned on 64K boundaries, but will also 
  7494. cross 64K boundaries. Tiled memory from the VisualAge C++ runtime heap is 
  7495. limited to 512 MB per process. You can also create your own heaps of tiled 
  7496. memory, which can be larger in size.  See "Managing Memory" in the Programming 
  7497. Guide for more information. 
  7498.  
  7499. Return Value 
  7500. _debug_trealloc returns a pointer to the reallocated memory block. The ptr 
  7501. argument to _debug_trealloc is not necessarily the same as the return value, 
  7502. because the _debug_trealloc might change the memory location. 
  7503.  
  7504. If size is 0, _debug_trealloc returns NULL. If not enough memory is available 
  7505. to expand the block to the given size, the original block is unchanged and NULL 
  7506. is returned. 
  7507.  
  7508.  
  7509. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_trealloc ΓòÉΓòÉΓòÉ
  7510.  
  7511. /************************************************************************
  7512.  
  7513. This example uses _debug_tmalloc to allocate 5 bytes of storage, then attempts 
  7514. to write to storage that was not allocated. The call to _debug_trealloc invokes 
  7515. _theap_check, which detects the error, generates several messages, and stops 
  7516. the program. 
  7517.  
  7518. Note:  You must compile this example with the /Tm /Gt options to map the 
  7519. realloc calls to _debug_trealloc. 
  7520.  
  7521. *********************************************************************** /
  7522.  
  7523. #include <stdlib.h>
  7524. #include <stdio.h>
  7525.  
  7526. int main(void)
  7527. {
  7528.    char *ptr;
  7529.  
  7530.    if (NULL == (ptr = malloc(5))) {
  7531.       puts("Could not allocate memory block.\n");
  7532.       exit(EXIT_FAILURE);
  7533.    }
  7534.    memset (ptr, 'x', 7);  /* Overwrites storage that was not allocated */
  7535.  
  7536.    /* realloc is mapped to _debug_trealloc */
  7537.    if (NULL == (ptr = realloc(ptr, 10))) {
  7538.       puts("Could not allocate memory block.\n");
  7539.       exit(EXIT_FAILURE);
  7540.    }
  7541.    free(ptr);
  7542.    return 0;
  7543.  
  7544.    /****************************************************************************
  7545.       The output should be similar to :
  7546.  
  7547.       End of allocated object 0x00080120 was overwritten at 0x00080125.
  7548.       The first eight bytes of the memory block (in hex) are: 78787878787878DD.
  7549.       This memory block was (re)allocated at line number 8 in _debug_treallo.c.
  7550.       Heap state was valid at line 8 of _debug_treallo.c.
  7551.       Memory error detected at line 15 of _debug_treallo.c.
  7552.    ****************************************************************************/
  7553. }
  7554.  
  7555.  
  7556. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7557.  
  7558. Example of _debug_trealloc 
  7559.  
  7560.      "Managing Memory" in the Programming Guide 
  7561.      "Debugging Your Heaps" in the Programming Guide 
  7562.      Tiled Debug Functions 
  7563.      _debug_realloc - Reallocate Memory Block 
  7564.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  7565.      _debug_tfree - Release Tiled Memory 
  7566.      _debug_theapmin - Release Unused Tiled Memory 
  7567.      _debug_tmalloc - Reserve Tiled Memory 
  7568.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  7569.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  7570.      _theap_check - Validate User Memory Heap 
  7571.      _trealloc - Reallocate Tiled Storage Block 
  7572.      <malloc.h> 
  7573.      <stdlib.h> 
  7574.  
  7575.  
  7576. ΓòÉΓòÉΓòÉ 4.59. _debug_ucalloc - Reserve and Initialize Memory from User Heap ΓòÉΓòÉΓòÉ
  7577.  
  7578.  
  7579. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7580.  
  7581. #include <umalloc.h>
  7582. void *_debug_ucalloc(Heap_t heap, size_t num, size_t size,
  7583.                      const char *file, size_t line);
  7584.  
  7585.  
  7586. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7587.  
  7588. Language Level:  Extension 
  7589.  
  7590. _debug_ucalloc is the debug version of _ucalloc. Like _ucalloc, it allocates 
  7591. memory from the heap you specify for an array of num elements, each of length 
  7592. size bytes. It then initializes all bits of each element to 0. 
  7593.  
  7594. In addition, _debug_ucalloc makes an implicit call to _uheap_check, and stores 
  7595. the name of the file file and the line number line where the storage is 
  7596. allocated. This information can be used later by the _uheap_check and 
  7597. _udump_allocated or _udump_allocated_delta functions. 
  7598.  
  7599. To use _debug_ucalloc, you must compile with the debug memory (/Tm) compiler 
  7600. option. the /Tm compiler option. This option maps all _ucalloc calls to 
  7601. _debug_ucalloc (you can also call _debug_ucalloc explicitly). 
  7602.  
  7603. Note:  The /Tm option maps all calls to memory management functions (including 
  7604. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  7605. call from being mapped, parenthesize the function name. 
  7606.  
  7607. _debug_ucalloc works just like _debug_calloc except that you specify the heap 
  7608. to use; _debug_calloc always allocates from the default heap. 
  7609.  
  7610. If the heap does not have enough memory for the request, _debug_ucalloc calls 
  7611. the getmore_fn that you specified when you created the heap with _ucreate. 
  7612.  
  7613. To reallocate or free memory allocated with _debug_ucalloc, use the 
  7614. non-heap-specific _debug_realloc and _debug_free. These functions always check 
  7615. what heap the memory was allocated from. 
  7616.  
  7617. Return Value 
  7618. _debug_ucalloc returns a pointer to the reserved space. If size or num was 
  7619. specified as zero, or if your getmore_fn cannot provide enough memory, 
  7620. _debug_ucalloc returns NULL. Passing _debug_ucalloc a heap that is not valid 
  7621. results in undefined behavior. 
  7622.  
  7623.  
  7624. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_ucalloc ΓòÉΓòÉΓòÉ
  7625.  
  7626. /************************************************************************
  7627.  
  7628. This example creates a user heap and allocates memory from it with 
  7629. _debug_ucalloc.  It then attempts to write to memory that was not allocated. 
  7630. When _debug_free is called, _uheap_check detects the error, generates several 
  7631. messages, and stops the program. 
  7632.  
  7633. Note:  You must compile this example with the /Tm option to map the _ucalloc 
  7634. calls to _debug_ucalloc and free to _debug_free. 
  7635.  
  7636. *********************************************************************** /
  7637.  
  7638. #include <stdlib.h>
  7639. #include <stdio.h>
  7640. #include <umalloc.h>
  7641. #include <string.h>
  7642.  
  7643. int main(void)
  7644. {
  7645.    Heap_t  myheap;
  7646.    char    *ptr;
  7647.  
  7648.    /* Use default heap as user heap */
  7649.    myheap = _udefault(NULL);
  7650.  
  7651.    if (NULL == (ptr = _ucalloc(myheap, 100, 1))) {
  7652.       puts("Cannot allocate memory from user heap.");
  7653.       exit(EXIT_FAILURE);
  7654.    }
  7655.    memset(ptr, 'x', 105);   /* Overwrites storage that was not allocated */
  7656.    free(ptr);
  7657.    return 0;
  7658.  
  7659.    /****************************************************************************
  7660.       The output should be similar to :
  7661.  
  7662.       End of allocated object 0x00073890 was overwritten at 0x000738f4.
  7663.       The first eight bytes of the memory block (in hex) are: 7878787878787878.
  7664.       This memory block was (re)allocated at line number 14 in _debug_ucallo.c.
  7665.       Heap state was valid at line 14 of _debug_ucallo.c.
  7666.       Memory error detected at line 19 of _debug_ucallo.c.
  7667.    ****************************************************************************/
  7668. }
  7669.  
  7670.  
  7671. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7672.  
  7673. Example of _debug_ucalloc 
  7674.  
  7675.      "Managing Memory" in the Programming Guide 
  7676.      "Debugging Your Heaps" in the Programming Guide 
  7677.      Differentiating between Memory Management Functions 
  7678.      calloc - Reserve and Initialize Storage 
  7679.      _debug_calloc - Allocate and Initialize Memory 
  7680.      _debug_free - Release Memory 
  7681.      _debug_umalloc - Reserve Memory Blocks from User Heap 
  7682.      _ucalloc - Reserve and Initialize Memory from User Heap 
  7683.      _ucreate - Create a Memory Heap 
  7684.      _udump_allocated - Get Information about Allocated Memory in Heap 
  7685.      _uheap_check - Validate User Memory Heap 
  7686.      <umalloc.h> 
  7687.  
  7688.  
  7689. ΓòÉΓòÉΓòÉ 4.60. _debug_uheapmin - Release Unused Memory in User Heap ΓòÉΓòÉΓòÉ
  7690.  
  7691.  
  7692. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7693.  
  7694. #include <umalloc.h>
  7695. int _debug_uheapmin(Heap_t heap, const char *file, size_t line);
  7696.  
  7697.  
  7698. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7699.  
  7700. Language Level:  Extension 
  7701.  
  7702. _debug_uheapmin is the debug version of _uheapmin. Like _uheapmin, it returns 
  7703. all unused memory blocks from the specified heap to the operating system. 
  7704.  
  7705. To return the memory, _debug_uheapmin calls the release_fn you supplied when 
  7706. you created the heap with _ucreate. If you do not supply a release_fn, 
  7707. _debug_uheapmin has no effect and returns 0. 
  7708.  
  7709. In addition, _debug_uheapmin makes an implicit call to _uheap_check to validate 
  7710. the heap. 
  7711.  
  7712. _debug_uheapmin works just like _debug_heapmin except that you specify the heap 
  7713. to use; _debug_heapmin always uses the default heap. 
  7714.  
  7715. To use _debug_uheapmin, you must compile with the debug memory (/Tm) compiler 
  7716. option. This option maps all _uheapmin calls to _debug_uheapmin (you can also 
  7717. call _debug_uheapmin explicitly). 
  7718.  
  7719. Note:  The /Tm option maps all calls to memory management functions (including 
  7720. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  7721. call from being mapped, parenthesize the function name. 
  7722.  
  7723. Return Value 
  7724. If successful, _debug_uheapmin returns 0. A nonzero return value indicates 
  7725. failure. If the heap specified is not valid, _debug_uheapmin generates an error 
  7726. message with the file name and line number where the call to _debug_uheapmin 
  7727. was made. 
  7728.  
  7729.  
  7730. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_uheapmin ΓòÉΓòÉΓòÉ
  7731.  
  7732. /************************************************************************
  7733.  
  7734. This example creates a heap and allocates memory from it, then uses 
  7735. _debug_heapmin to release the memory. 
  7736.  
  7737. Note:  You must compile this example with the /Tm option to map the _uheapmin 
  7738. calls to _debug_uheapmin. 
  7739.  
  7740. *********************************************************************** /
  7741.  
  7742. #include <stdlib.h>
  7743. #include <stdio.h>
  7744. #include <umalloc.h>
  7745.  
  7746. int main(void)
  7747. {
  7748.    Heap_t  myheap;
  7749.    char    *ptr;
  7750.  
  7751.    /* Use default heap as user heap */
  7752.    myheap = _udefault(NULL);
  7753.  
  7754.    /* Allocate a large object */
  7755.    if (NULL == (ptr = _umalloc(myheap, 60000))) {
  7756.       puts("Cannot allocate memory from user heap.\n");
  7757.       exit(EXIT_FAILURE);
  7758.    }
  7759.    memset(ptr, 'x', 60000);
  7760.    free(ptr);
  7761.  
  7762.    /* _debug_uheapmin will attempt to return the freed object to the system */
  7763.    if (0 != _uheapmin(myheap)) {
  7764.       puts("_debug_uheapmin returns failed.\n");
  7765.       exit(EXIT_FAILURE);
  7766.    }
  7767.    return 0;
  7768. }
  7769.  
  7770.  
  7771. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7772.  
  7773. Example of _debug_uheapmin 
  7774.  
  7775.      "Managing Memory" in the Programming Guide 
  7776.      "Debugging Your Heaps" in the Programming Guide 
  7777.      Differentiating between Memory Management Functions 
  7778.      _heapmin - Release Unused Memory from Default Heap 
  7779.      _ucreate - Create a Memory Heap 
  7780.      _udump_allocated - Get Information about Allocated Memory in Heap 
  7781.      _uheap_check - Validate User Memory Heap 
  7782.      _uheapmin - Release Unused Memory in User Heap 
  7783.      <umalloc.h> 
  7784.  
  7785.  
  7786. ΓòÉΓòÉΓòÉ 4.61. _debug_umalloc - Reserve Memory Blocks from User Heap ΓòÉΓòÉΓòÉ
  7787.  
  7788.  
  7789. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7790.  
  7791. #include <umalloc.h>
  7792. void *_debug_umalloc(Heap_t heap, size_t size,
  7793.                      const char *file, size_t line);
  7794.  
  7795.  
  7796. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7797.  
  7798. Language Level:  Extension 
  7799.  
  7800. _debug_umalloc is the debug version of _umalloc. Like _umalloc, it reserves 
  7801. storage space from the heap you specify for a block of size bytes. 
  7802. _debug_umalloc also sets all the memory it allocates to 0xAA, so you can easily 
  7803. locate instances where your program uses the data in the memory without 
  7804. initializing it first. 
  7805.  
  7806. In addition, _debug_umalloc makes an implicit call to _uheap_check, and stores 
  7807. the name of the file file and the line number line where the storage is 
  7808. allocated. This information can be used later by the _uheap_check and 
  7809. _udump_allocated or _udump_allocated_delta functions. _debug_umalloc also sets 
  7810. all the memory it allocates to 0xAA; this can help you debug problems where 
  7811. your program uses the data in the memory without initializing it. 
  7812.  
  7813. _debug_umalloc works just like _debug_malloc except that you specify the heap 
  7814. to use; _debug_malloc always allocates from the default heap. 
  7815.  
  7816. If the heap does not have enough memory for the request, _debug_umalloc calls 
  7817. the getmore_fn that you specified when you created the heap with _ucreate. 
  7818.  
  7819. To use _debug_umalloc, you must compile with the debug memory (/Tm) compiler 
  7820. option. This option maps all _umalloc calls to _debug_umalloc (you can also 
  7821. call _debug_umalloc explicitly). 
  7822.  
  7823. Note:  The /Tm option maps all calls to memory management functions (including 
  7824. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  7825. call from being mapped, parenthesize the function name. 
  7826.  
  7827. To reallocate or free memory allocated with _debug_umalloc, use the 
  7828. non-heap-specific _debug_realloc and _debug_free. These functions always check 
  7829. what heap the memory was allocated from. 
  7830.  
  7831. Return Value: 
  7832. _debug_umalloc returns a pointer to the reserved space. If size was specified 
  7833. as zero, or the getmore_fn cannot provide enough memory, _debug_umalloc returns 
  7834. NULL. Passing _debug_umalloc a heap that is not valid results in undefined 
  7835. behavior. 
  7836.  
  7837.  
  7838. ΓòÉΓòÉΓòÉ <hidden> Example of _debug_umalloc ΓòÉΓòÉΓòÉ
  7839.  
  7840. /************************************************************************
  7841.  
  7842. This example creates a heap myheap and uses _debug_umalloc to allocate 100 
  7843. bytes from it. It then attempts to overwrite storage that was not allocated. 
  7844. The call to _debug_free invokes _uheap_check, which detects the error, 
  7845. generates messages, and ends the program. 
  7846.  
  7847. Note:  You must compile this example with the /Tm option to map _umalloc to 
  7848. _debug_umalloc and free to _debug_free. 
  7849.  
  7850.  ***********************************************************************
  7851.  
  7852. #include <stdlib.h>
  7853. #include <stdio.h>
  7854. #include <umalloc.h>
  7855. #include <string.h>
  7856.  
  7857. int main(void)
  7858. {
  7859.    Heap_t  myheap;
  7860.    char    *ptr;
  7861.  
  7862.    /* Use default heap as user heap */
  7863.    myheap = _udefault(NULL);
  7864.  
  7865.    if (NULL == (ptr = _umalloc(myheap, 100))) {
  7866.       puts("Cannot allocate memory from user heap.\n");
  7867.       exit(EXIT_FAILURE);
  7868.    }
  7869.    memset(ptr, 'x', 105);   /* Overwrites storage that was not allocated */
  7870.    free(ptr);
  7871.    return 0;
  7872.  
  7873.    /****************************************************************************
  7874.       The output should be similar to :
  7875.  
  7876.       End of allocated object 0x00073890 was overwritten at 0x000738f4.
  7877.       The first eight bytes of the memory block (in hex) are: 7878787878787878.
  7878.       This memory block was (re)allocated at line number 14 in _debug_umallo.c.
  7879.       Heap state was valid at line 14 of _debug_umallo.c.
  7880.       Memory error detected at line 19 of _debug_umallo.c.
  7881.    ****************************************************************************/
  7882. }
  7883.  
  7884.  
  7885. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7886.  
  7887. Example of _debug_umalloc 
  7888.  
  7889.      "Managing Memory" in the Programming Guide 
  7890.      "Debugging Your Heaps" in the Programming Guide 
  7891.      Differentiating between Memory Management Functions 
  7892.      _debug_free - Release Memory 
  7893.      _debug_malloc - Allocate Memory 
  7894.      _debug_ucalloc - Reserve and Initialize Memory from User Heap 
  7895.      malloc - Reserve Storage Block 
  7896.      _ucreate - Create a Memory Heap 
  7897.      _udump_allocated - Get Information about Allocated Memory in Heap 
  7898.      _umalloc - Reserve Memory Blocks from User Heap 
  7899.      _uheap_check - Validate User Memory Heap 
  7900.      <umalloc.h> 
  7901.  
  7902.  
  7903. ΓòÉΓòÉΓòÉ 4.62. difftime - Compute Time Difference ΓòÉΓòÉΓòÉ
  7904.  
  7905.  
  7906. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7907.  
  7908. #include <time.h>
  7909. double difftime(time_t time2, time_t time1);
  7910.  
  7911.  
  7912. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7913.  
  7914. Language Level: ANSI, SAA, POSIX, XPG4 
  7915.  
  7916. difftime computes the difference in seconds between time2 and time1. 
  7917.  
  7918. Return Value 
  7919. The difftime function returns the elapsed time in seconds from time1 to time2 
  7920. as a double precision number.  Type time_t is defined in <time.h>. 
  7921.  
  7922.  
  7923. ΓòÉΓòÉΓòÉ <hidden> Example of difftime ΓòÉΓòÉΓòÉ
  7924.  
  7925. /************************************************************************
  7926.  
  7927. This example shows a timing application using difftime.  The example calculates 
  7928. how long, on average, it takes to find the prime numbers from 2 to 10000. 
  7929.  
  7930. ************************************************************************/
  7931.  
  7932. #include <time.h>
  7933. #include <stdio.h>
  7934.  
  7935. #define  RUNS          1000
  7936. #define  SIZE          10000
  7937.  
  7938. int mark[SIZE];
  7939.  
  7940. int main(void)
  7941. {
  7942.    time_t start,finish;
  7943.    int i,loop,n,num;
  7944.  
  7945.    time(&start);
  7946.  
  7947.    /*  This loop finds the prime numbers between 2 and SIZE                   */
  7948.  
  7949.    for (loop = 0; loop < RUNS; ++loop) {
  7950.       for (n = 0; n < SIZE; ++n)
  7951.          mark[n] = 0;
  7952.  
  7953.       /*  This loops marks all the composite numbers with -1                  */
  7954.  
  7955.       for (num = 0, n = 2; n < SIZE; ++n)
  7956.          if (!mark[n]) {
  7957.             for (i = 2*n; i < SIZE; i += n)
  7958.                mark[i] = -1;
  7959.             ++num;
  7960.          }
  7961.    }
  7962.    time(&finish);
  7963.    printf("Program takes an average of %f seconds to find %d primes.\n",
  7964.       difftime(finish, start)/RUNS, num);
  7965.    return 0;
  7966.  
  7967.    /****************************************************************************
  7968.       The output should be similar to :
  7969.  
  7970.       Program takes an average of 0.106000 seconds to find 1229 primes.
  7971.    ****************************************************************************/
  7972. }
  7973.  
  7974.  
  7975. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  7976.  
  7977. Example of difftime 
  7978.  
  7979.      asctime - Convert Time to Character String 
  7980.      ctime - Convert Time to Character String 
  7981.      gmtime - Convert Time 
  7982.      localtime - Convert Time 
  7983.      mktime - Convert Local Time 
  7984.      strftime - Convert to Formatted Time 
  7985.      time - Determine Current Time 
  7986.      <time.h> 
  7987.  
  7988.  
  7989. ΓòÉΓòÉΓòÉ 4.63. _disable - Disable Interrupts ΓòÉΓòÉΓòÉ
  7990.  
  7991.  
  7992. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  7993.  
  7994. #include <builtin.h>
  7995. void _disable( void );
  7996.  
  7997.  
  7998. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  7999.  
  8000. Language Level:  Extension 
  8001.  
  8002. _disable disables interrupts by executing the CLI machine instruction. It 
  8003. disables interrupts until the instruction after a call to _enable has been 
  8004. executed. 
  8005.  
  8006. Note:  _disable is a built-in function, which means it is implemented as an 
  8007. inline instruction and has no backing code in the library.  For this reason: 
  8008.  
  8009.      You cannot take the address of _disable. 
  8010.      You cannot parenthesize a call to _disable. (Parentheses specify a call 
  8011.       to the function's backing code, and _disable has none.) 
  8012.  
  8013.  You can run code containing this function only at ring zero. Otherwise, an 
  8014.  invalid instruction exception is generated. 
  8015.  
  8016.  Return Value 
  8017.  This function has no return value. 
  8018.  
  8019.  
  8020. ΓòÉΓòÉΓòÉ <hidden> Example of _disable ΓòÉΓòÉΓòÉ
  8021.  
  8022. /************************************************************************
  8023.  
  8024. In this example, _disable disables interrupts by executing a CLI instruction. 
  8025.  
  8026. ************************************************************************/
  8027.  
  8028. #include <builtin.h>
  8029.  
  8030. int main(void)
  8031. {
  8032.    /* ------------------------------------------------------ */
  8033.    /* The expected assembler instruction looks like this :   */
  8034.    /*       CLI                                              */
  8035.    /* -------------------------------------------------------*/
  8036.    _disable();
  8037.    return 0;
  8038. }
  8039.  
  8040.  
  8041. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  8042.  
  8043. Example of disable 
  8044.  
  8045.      _enable - Enable Interrupts 
  8046.      _interrupt - Call Interrupt  Procedure 
  8047.      <builtin.h> 
  8048.  
  8049.  
  8050. ΓòÉΓòÉΓòÉ 4.64. div  - Calculate Quotient and Remainder ΓòÉΓòÉΓòÉ
  8051.  
  8052.  
  8053. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  8054.  
  8055. #include <stdlib.h>
  8056. div_t div(int numerator, int denominator);
  8057.  
  8058.  
  8059. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  8060.  
  8061. Language Level: ANSI, SAA, POSIX, XPG4 
  8062.  
  8063. div calculates the quotient and remainder of the division of numerator by 
  8064. denominator. 
  8065.  
  8066. Return Value 
  8067. div returns a structure of type div_t, containing both the quotient int quot 
  8068. and the remainder int rem.  If the return value cannot be represented, its 
  8069. value is undefined. If denominator is 0, an exception will be raised. 
  8070.  
  8071.  
  8072. ΓòÉΓòÉΓòÉ <hidden> Example of div ΓòÉΓòÉΓòÉ
  8073.  
  8074. /************************************************************************
  8075.  
  8076. This example uses div to calculate the quotients and remainders for a set of 
  8077. two dividends and two divisors. 
  8078.  
  8079. ************************************************************************/
  8080.  
  8081. #include <stdlib.h>
  8082. #include <stdio.h>
  8083.  
  8084. int main(void)
  8085. {
  8086.    int num[2] =  { 45,-45 };
  8087.    int den[2] =  { 7,-7 };
  8088.    div_t ans;              /* div_t is a struct type containing two ints:
  8089.                               'quot' stores quotient; 'rem' stores remainder */
  8090.    short i,j;
  8091.  
  8092.    printf("Results of division:\n");
  8093.    for (i = 0; i < 2; i++)
  8094.       for (j = 0; j < 2; j++) {
  8095.          ans = div(num[i], den[j]);
  8096.          printf("Dividend: %6ld  Divisor: %6ld", num[i], den[j]);
  8097.          printf("  Quotient: %6ld  Remainder: %6ld\n", ans.quot, ans.rem);
  8098.       }
  8099.    return 0;
  8100.  
  8101.    /****************************************************************************
  8102.       The output should be:
  8103.  
  8104.       Results of division:
  8105.       Dividend:  45  Divisor:   7  Quotient:   6  Remainder:   3
  8106.       Dividend:  45  Divisor:  -7  Quotient:  -6  Remainder:   3
  8107.       Dividend: -45  Divisor:   7  Quotient:  -6  Remainder:  -3
  8108.       Dividend: -45  Divisor:  -7  Quotient:   6  Remainder:  -3
  8109.    ****************************************************************************/
  8110. }
  8111.  
  8112.  
  8113. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  8114.  
  8115. Example of div 
  8116.  
  8117.      ldiv - Perform Long Division 
  8118.      <stdlib.h> 
  8119.  
  8120.  
  8121. ΓòÉΓòÉΓòÉ 4.65. _DLL_InitTerm - Initialize and Terminate DLL Environment ΓòÉΓòÉΓòÉ
  8122.  
  8123.  
  8124. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  8125.  
  8126. unsigned long _System _DLL_InitTerm(unsigned long modhandle,
  8127.                                     unsigned long flag);
  8128. /* no header file - defined in runtime startup code */
  8129.  
  8130.  
  8131. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  8132.  
  8133. Language Level:  Extension 
  8134.  
  8135. _DLL_InitTerm is the initialization and termination entry point for a DLL. When 
  8136. each new process gains access to the DLL, _DLL_InitTerm initializes the 
  8137. necessary environment for the DLL, including storage, semaphores, and 
  8138. variables. When each process frees its access to the DLL, _DLL_InitTerm 
  8139. terminates the DLL environment created for that process. 
  8140.  
  8141. The default _DLL_InitTerm function supplied by VisualAge C++ performs the 
  8142. actions required to initialize and terminate the runtime environment, or for 
  8143. subsystem DLLs, to initialize and terminate memory functions. It is called 
  8144. automatically when you link to the DLL. If your DLL requires initialization or 
  8145. termination actions in addition to the actions performed in the default 
  8146. function, you will need to create your own _DLL_InitTerm function. 
  8147.  
  8148. If the value of the flag parameter is 0, the DLL environment is initialized. If 
  8149. the value of the flag parameter is 1, the DLL environment is ended. 
  8150.  
  8151. The modhandle parameter is the module handle assigned by the operating system 
  8152. for this DLL. You can use the module handle as a parameter to various OS/2 API 
  8153. calls. For example, you can call DosQueryModuleName with the module handle to 
  8154. return the fully-qualified path name of the DLL, which tells you where the DLL 
  8155. was loaded from. 
  8156.  
  8157. Because it is called by the operating system loader, you must compile your 
  8158. _DLL_InitTerm function with _System linkage. 
  8159.  
  8160. For more information on creating your own _DLL_InitTerm function, see the 
  8161. chapter Building Dynamic Link Libraries in the Programming Guide. 
  8162.  
  8163. Note:  A _DLL_InitTerm function for a subsystem DLL has the same prototype, but 
  8164. the content of the function is different because there is no runtime 
  8165. environment to initialize or terminate. For more information on building 
  8166. subsystem DLLs, see the section Building a Subsystem DLL in the Programming 
  8167. Guide. 
  8168.  
  8169. Return Value 
  8170. The return code from _DLL_InitTerm tells the loader if the initialization or 
  8171. termination was performed successfully. If the call was successful, 
  8172. _DLL_InitTerm returns a nonzero value. A return code of 0 indicates that the 
  8173. function failed. If a failure is indicated, the loader will not load the 
  8174. program that is accessing the DLL. 
  8175.  
  8176.  
  8177. ΓòÉΓòÉΓòÉ <hidden> Example of _DLL_Initterm ΓòÉΓòÉΓòÉ
  8178.  
  8179. /************************************************************************
  8180.  
  8181. This example shows the _DLL_InitTerm function from the VisualAge C++ sample 
  8182. program for building DLLs. 
  8183.  
  8184. ************************************************************************/
  8185.  
  8186. #define  INCL_DOSMODULEMGR
  8187. #define  INCL_DOSPROCESS
  8188. #include <os2.h>
  8189. #include <stdlib.h>
  8190. #include <stdio.h>
  8191. #include <string.h>
  8192.  
  8193. /* _CRT_init is the C run-time environment initialization function.         */
  8194. /* It will return 0 to indicate success and -1 to indicate failure.         */
  8195.  
  8196. int _CRT_init(void);
  8197. #ifdef   STATIC_LINK
  8198.  
  8199. /* _CRT_term is the C run-time environment termination function.            */
  8200. /* It only needs to be called when the C run-time functions are statically  */
  8201. /* linked.                                                                  */
  8202.  
  8203. void _CRT_term(void);
  8204. #else
  8205.  
  8206. /* A clean up routine registered with DosExitList must be used if runtime   */
  8207. /* calls are required and the runtime is dynamically linked.  This will     */
  8208. /* guarantee that this clean up routine is run before the library DLL is    */
  8209. /* terminated.                                                              */
  8210.  
  8211. static void _System cleanup(ULONG ulReason);
  8212. #endif
  8213. size_t nSize;
  8214. int *pArray;
  8215.  
  8216. /* _DLL_InitTerm is the function that gets called by the operating system   */
  8217. /* loader when it loads and frees this DLL for each process that accesses   */
  8218. /* this DLL.  However, it only gets called the first time the DLL is loaded */
  8219. /* and the last time it is freed for a particular process.  The system      */
  8220. /* linkage convention MUST be used because the operating system loader is   */
  8221. /* calling this function.                                                   */
  8222.  
  8223. unsigned long _System _DLL_InitTerm(unsigned long hModule, unsigned long
  8224.                                     ulFlag)
  8225. {
  8226.    size_t i;
  8227.    APIRET rc;
  8228.    char namebuf[CCHMAXPATH];
  8229.  
  8230.    /* If ulFlag is zero then the DLL is being loaded so initialization should*/
  8231.    /* be performed.  If ulFlag is 1 then the DLL is being freed so          */
  8232.    /* termination should be performed.                                      */
  8233.  
  8234.    switch (ulFlag) {
  8235.       case 0 :
  8236.  
  8237.          /*******************************************************************/
  8238.          /* The C run-time environment initialization function must be      */
  8239.          /* called before any calls to C run-time functions that are not    */
  8240.          /* inlined.                                                        */
  8241.          /*******************************************************************/
  8242.  
  8243.          if (_CRT_init() == -1)
  8244.             return 0UL;
  8245. #ifndef  STATIC_LINK
  8246.  
  8247.          /*******************************************************************/
  8248.          /* A DosExitList routine must be used to clean up if runtime calls */
  8249.          /* are required and the runtime is dynamically linked.             */
  8250.          /*******************************************************************/
  8251.  
  8252.             if (rc = DosExitList(0x0000FF00|EXLST_ADD, cleanup))
  8253.             printf("DosExitList returned %lu\n", rc);
  8254. #endif
  8255.          if (rc = DosQueryModuleName(hModule, CCHMAXPATH, namebuf))
  8256.             printf("DosQueryModuleName returned %lu\n", rc);
  8257.          else
  8258.             printf("The name of this DLL is %s\n", namebuf);
  8259.          srand(17);
  8260.          nSize = (rand()%128)+32;
  8261.          printf("The array size for this process is %u\n", nSize);
  8262.          if ((pArray = malloc(nSize *sizeof(int))) == NULL) {
  8263.             printf("Could not allocate space for unsorted array.\n");
  8264.             return 0UL;
  8265.          }
  8266.          for (i = 0; i < nSize; ++i)
  8267.             pArray[i] = rand();
  8268.          break;
  8269.       case 1 :
  8270. #ifdef   STATIC_LINK
  8271.          printf("The array will now be freed.\n");
  8272.          free(pArray);
  8273.          _CRT_term();
  8274. #endif
  8275.          break;
  8276.       default  :
  8277.          printf("ulFlag = %lu\n", ulFlag);
  8278.          return 0UL;
  8279.    }
  8280.  
  8281.    /* A non-zero value must be returned to indicate success.                */
  8282.  
  8283.    return 1UL;
  8284. }
  8285. #ifndef  STATIC_LINK
  8286. static void cleanup(ULONG ulReason)
  8287. {
  8288.    if (!ulReason) {
  8289.       printf("The array will now be freed.\n");
  8290.       free(pArray);
  8291.    }
  8292.    DosExitList(EXLST_EXIT, cleanup);
  8293.    return ;
  8294. }
  8295. #endif
  8296.  
  8297.  
  8298. ΓòÉΓòÉΓòÉ <hidden> Example of _DLL_InitTerm for a Subsystem ΓòÉΓòÉΓòÉ
  8299.  
  8300. /************************************************************************
  8301.  
  8302. The following example shows the _DLL_InitTerm function from the VisualAge C++ 
  8303. sample for building subsystem DLLs. 
  8304.  
  8305. ************************************************************************/
  8306.  
  8307.  
  8308. /* _DLL_InitTerm() - called by the loader for DLL initialization/termination  */
  8309. /* This function must return a non-zero value if successful and a zero value  */
  8310. /* if unsuccessful.                                                           */
  8311.  
  8312. unsigned long _DLL_InitTerm( unsigned long hModule, unsigned long ulFlag )
  8313.    {
  8314.    APIRET rc;
  8315.  
  8316.    /* If ulFlag is zero then initialization is required:                      */
  8317.    /*    If the shared memory pointer is NULL then the DLL is being loaded    */
  8318.    /*    for the first time so acquire the named shared storage for the       */
  8319.    /*    process control structures.  A linked list of process control        */
  8320.    /*    structures will be maintained.  Each time a new process loads this   */
  8321.    /*    DLL, a new process control structure is created and it is inserted   */
  8322.    /*    at the end of the list by calling DLLREGISTER.                       */
  8323.    /*                                                                         */
  8324.    /* If ulFlag is 1 then termination is required:                            */
  8325.    /*    Call DLLDEREGISTER which will remove the process control structure   */
  8326.    /*    and free the shared memory block from its virtual address space.     */
  8327.  
  8328.    switch( ulFlag )
  8329.       {
  8330.    case 0:
  8331.          if ( !ulProcessCount )
  8332.             {
  8333.             _rmem_init();
  8334.             /* Create the shared mutex semaphore.                             */
  8335.  
  8336.             if ( ( rc = DosCreateMutexSem( SHARED_SEMAPHORE_NAME,
  8337.                                            &hmtxSharedSem,
  8338.                                            0,
  8339.                                            FALSE ) ) != NO_ERROR )
  8340.                {
  8341.                printf( "DosCreateMutexSem rc = %lu\n", rc );
  8342.                return 0;
  8343.                }
  8344.             }
  8345.  
  8346.          /* Register the current process.                                     */
  8347.  
  8348.          if ( DLLREGISTER( ) )
  8349.             return 0;
  8350.  
  8351.          break;
  8352.  
  8353.       case 1:
  8354.          /* De-register the current process.                                  */
  8355.  
  8356.          if ( DLLDEREGISTER( ) )
  8357.             return 0;
  8358.  
  8359.          _rmem_term();
  8360.  
  8361.          break;
  8362.  
  8363.       default:
  8364.          return 0;
  8365.       }
  8366.  
  8367.    /* Indicate success.  Non-zero means success!!!                            */
  8368.  
  8369.    return 1;
  8370.    }
  8371.  
  8372.  
  8373. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  8374.  
  8375. Example of _DLL_Initterm 
  8376.  
  8377. Example of _DLL_Initterm for a Subsystem 
  8378.  
  8379.      Building a Dynamic Link Library in the Programming Guide 
  8380.      Building a Subsystem DLL in the Programming Guide 
  8381.      _CRT_init - Initialize DLL Runtime Environment 
  8382.      _CRT_term - Terminate DLL Runtime Environment 
  8383.      _rmem_init - Initialize Memory Functions for Subsystem DLL 
  8384.      _rmem_term - Terminate Memory Functions for Subsystem DLL 
  8385.      _tmem_init - Initialize Memory Functions for Subsystem DLL 
  8386.      _tmem_term - Terminate Memory Functions for Subsystem DLL 
  8387.  
  8388.  
  8389. ΓòÉΓòÉΓòÉ 4.66. _dump_allocated - Get Information about Allocated Memory ΓòÉΓòÉΓòÉ
  8390.  
  8391.  
  8392. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  8393.  
  8394. #include <stdlib.h>   /* also in <malloc.h> */
  8395. void _dump_allocated(int nbytes);
  8396.  
  8397.  
  8398. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  8399.  
  8400. Language Level:  Extension 
  8401.  
  8402. _dump_allocated prints information to stderr about each memory block that is 
  8403. currently allocated and was allocated using the debug memory management 
  8404. functions (_debug_calloc, _debug_malloc, and so on). 
  8405.  
  8406. Use nbytes to specify how many bytes of each memory block are to be printed. If 
  8407. nbytes is a: 
  8408.  
  8409.  Negative value Prints all bytes of each block. 
  8410.  
  8411.  0             Prints no bytes. 
  8412.  
  8413.  Positive value Prints the specified number of bytes or the entire block, 
  8414.                whichever is smaller. 
  8415.  
  8416.  Call _dump_allocated at points in your code where you want a report of the 
  8417.  currently allocated memory. For example, a good place to call _dump_allocated 
  8418.  is a point where most of the memory is already freed and you want to find a 
  8419.  memory leak, such as at the end of a program. 
  8420.  
  8421.  _dump_allocated prints the information to stderr, but you can change the 
  8422.  destination with the _set_crt_msg_handle function. You can also use 
  8423.  _dump_allocated_delta to display information only about the memory that was 
  8424.  allocated since the previous call to _dump_allocated or _dump_allocated_delta. 
  8425.  
  8426.  To use _dump_allocated and the debug memory management functions, you must 
  8427.  compile with the debug memory (/Tm) compiler option. 
  8428.  
  8429.  Note:  The /Tm option maps all calls to memory management functions (including 
  8430.  tiled and heap-specific versions) to their debug counterparts. To prevent a 
  8431.  call from being mapped, parenthesize the function name. 
  8432.  
  8433.  Heap-specific and tiled versions of this function (_udump_allocated and 
  8434.  _tdump_allocated) are also available. _dump_allocated always prints 
  8435.  information about memory allocated from the default heap. 
  8436.  
  8437.  Return Value 
  8438.  There is no return value. 
  8439.  
  8440.  
  8441. ΓòÉΓòÉΓòÉ <hidden> Example of _dump_allocated ΓòÉΓòÉΓòÉ
  8442.  
  8443. /************************************************************************
  8444.  
  8445. This example allocates three memory blocks, and then calls _dump_allocated to 
  8446. dump information and the first 8 bytes for each memory block. 
  8447.  
  8448. Note:  You must compile this example with the /Tm option to map the memory 
  8449. management functions to their debug versions. 
  8450.  
  8451. ************************************************************************/
  8452.  
  8453. rules=none.
  8454.  
  8455. #include <stdlib.h>
  8456. #include <string.h>
  8457. #include <stdio.h>
  8458.  
  8459. #define  INIT_STR      "It\0works"
  8460. #define  INIT_STR_LEN  (sizeof(INIT_STR) - 1)
  8461.  
  8462. int main(void) {
  8463.    char *pBlock1;
  8464.    char *pBlock2;
  8465.    char *pBlock3;
  8466.  
  8467.    if (NULL == (pBlock1 = malloc(35))) {   /* allocate first memory block     */
  8468.       printf("Could not allocate first memory block.\n");
  8469.       return  EXIT_FAILURE;
  8470.    }
  8471.  
  8472.    memcpy(pBlock1, INIT_STR, INIT_STR_LEN); /* initialize first memory block  */
  8473.    if (NULL == (pBlock2 = calloc(2, 120))) { /* allocate second memory block  */
  8474.       printf("Could not allocate second memory block.\n");
  8475.       return  EXIT_FAILURE;
  8476.    }
  8477.  
  8478.    memcpy(pBlock2, INIT_STR, INIT_STR_LEN); /* initialize second memory block */
  8479.    if (NULL == (pBlock3 = realloc(NULL, 2235))) {/* allocate third
  8480.                                                              memory block     */
  8481.       printf("Could not allocate third memory block.\n");
  8482.       return  EXIT_FAILURE;
  8483.    }
  8484.  
  8485.    memcpy(pBlock3, INIT_STR, INIT_STR_LEN); /* initialize third memory block  */
  8486.    if (NULL == (pBlock3 = realloc(pBlock3, 300))) {       /* reallocate third */
  8487.                                       /* memory block to different size       */
  8488.  
  8489.       printf("Could not reallocate third memory block.\n");
  8490.       return  EXIT_FAILURE;
  8491.    }
  8492.  
  8493.    _dump_allocated(8);    /* show first eight bytes of each memory block      */
  8494.    return 0;
  8495.  
  8496.    /****************************************************************************
  8497.       The output should be similar to:
  8498.  
  8499.       -------------------------------------------------------------------------------
  8500.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  8501.       -------------------------------------------------------------------------------
  8502.       Address: 0x00074310      Size: 0x0000012C (300)
  8503.       This memory block was (re)allocated at line number 32 in _dump_alloc.c.
  8504.       Memory contents:  49740077 6F726B73                      [It.works        ]
  8505.       -------------------------------------------------------------------------------
  8506.       Address: 0x000738F0      Size: 0x000000F0 (240)
  8507.       This memory block was (re)allocated at line number 19 in _dump_alloc.c.
  8508.       Memory contents:  49740077 6F726B73                      [It.works        ]
  8509.       -------------------------------------------------------------------------------
  8510.       Address: 0x00073890      Size: 0x00000023 (35)
  8511.       This memory block was (re)allocated at line number 13 in _dump_alloc.c.
  8512.       Memory contents:  49740077 6F726B73                      [It.works        ]
  8513.       -------------------------------------------------------------------------------
  8514.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  8515.       -------------------------------------------------------------------------------
  8516.    ****************************************************************************/
  8517. }
  8518.  
  8519.  
  8520. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  8521.  
  8522. Example of _dump_allocated 
  8523.  
  8524.      Memory Management in the Programming Guide 
  8525.      Debugging Your Heaps in the Programming Guide 
  8526.      Differentiating between Memory Management Functions 
  8527.      _debug_calloc - Allocate and Initialize Memory 
  8528.      _debug_free - Release Memory 
  8529.      _debug_malloc - Allocate Memory 
  8530.      _debug_realloc - Reallocate Memory Block 
  8531.      _dump_allocated_delta - Get Information about Allocated Memory 
  8532.      _heap_check - Validate Default Memory Heap 
  8533.      _udump_allocated - Get Information about Allocated Memory in Heap 
  8534.      <malloc.h> 
  8535.      <stdlib.h> 
  8536.  
  8537.  
  8538. ΓòÉΓòÉΓòÉ 4.67. _dump_allocated_delta - Get Information about Allocated Memory ΓòÉΓòÉΓòÉ
  8539.  
  8540.  
  8541. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  8542.  
  8543. #include <stdlib.h>     /* also in <malloc.h> */
  8544. void _dump_allocated_delta(int nbytes);
  8545.  
  8546.  
  8547. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  8548.  
  8549. Language Level:  Extension 
  8550.  
  8551. _dump_allocated_delta prints information to stderr about each memory block 
  8552. allocated by a debug memory management function (_debug_malloc and so on) since 
  8553. the last call to _dump_allocated_delta or _dump_allocated. 
  8554.  
  8555. _dump_allocated_delta and _dump_allocated print the same type of information to 
  8556. stderr, but _dump_allocated displays information about all blocks that have 
  8557. been allocated since the start of your program. 
  8558.  
  8559. Use nbytes to specify how many bytes of each memory block are to be printed. If 
  8560. nbytes is a: 
  8561.  
  8562.  Negative value  Prints all bytes of each block. 
  8563.  0               Prints no bytes. 
  8564.  Positive value  Prints the specified number of bytes or the entire block, 
  8565.                  whichever is smaller. 
  8566.  
  8567.  _dump_allocated_delta prints the information to stderr, but you can change the 
  8568.  destination with the _set_crt_msg_handle function. 
  8569.  
  8570.  A heap-specific version of this function, _udump_allocated_delta, is also 
  8571.  available. _dump_allocated_delta always displays information about the default 
  8572.  heap. 
  8573.  
  8574.  To use _dump_allocated_delta and the debug versions of the memory management 
  8575.  functions, specify the debug memory (/Tm) compiler option. 
  8576.  
  8577.  Note:  The /Tm option maps all calls to memory management functions (including 
  8578.  tiled and heap-specific versions) are mapped to their debug counterparts. To 
  8579.  prevent a call from being mapped, parenthesize the function name. 
  8580.  
  8581.  Return Value: 
  8582.  There is no return value. 
  8583.  
  8584.  
  8585. ΓòÉΓòÉΓòÉ <hidden> Example of _dump_allocated_delta ΓòÉΓòÉΓòÉ
  8586.  
  8587. /************************************************************************
  8588.  
  8589. This example allocates some memory and calls _dump_allocated to print 
  8590. information about the allocated blocks.  It then allocates more memory, and 
  8591. calls _dump_allocated_delta again to print information about the allocations 
  8592. since the previous call. 
  8593.  
  8594. Note:  You must compile this example with the /Tm option to map the memory 
  8595. management functions to their debug versions. 
  8596.  
  8597. ************************************************************************/
  8598.  
  8599. #include <stdlib.h>
  8600. #include <stdio.h>
  8601. #include <string.h>
  8602.  
  8603. int main(void)
  8604. {
  8605.    char *ptr1, *ptr2;
  8606.  
  8607.    if (NULL == (ptr1 = malloc(10))) {
  8608.       puts("Could not allocate memory block.");
  8609.       exit(EXIT_FAILURE);
  8610.    }
  8611.    memset(ptr1, 'a', 5);
  8612.    _dump_allocated(10);
  8613.  
  8614.    if (NULL == (ptr2 = malloc(20))) {
  8615.       puts("Could not allocate memory block.");
  8616.       exit(EXIT_FAILURE);
  8617.    }
  8618.    memset(ptr2, 'b', 5);
  8619.    _dump_allocated_delta(10);
  8620.  
  8621.    free(ptr1);
  8622.    free(ptr2);
  8623.    return 0;
  8624.  
  8625.    /****************************************************************************
  8626.       The output should be similar to :
  8627.  
  8628.       -------------------------------------------------------------------------------
  8629.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  8630.       -------------------------------------------------------------------------------
  8631.       Address: 0x00073890      Size: 0x0000000A (10)
  8632.       This memory block was (re)allocated at line number 9 in _dump_alloc_d.c.
  8633.       Memory contents:  61616161 61AAAAAA AAAA                 [aaaaa╨ÿ╨ÿ╨ÿ╨ÿ╨ÿ      ]
  8634.       -------------------------------------------------------------------------------
  8635.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  8636.       -------------------------------------------------------------------------------
  8637.       -------------------------------------------------------------------------------
  8638.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  8639.       -------------------------------------------------------------------------------
  8640.       Address: 0x000738D0      Size: 0x00000014 (20)
  8641.       This memory block was (re)allocated at line number 16 in _dump_alloc_d.c.
  8642.       Memory contents:  62626262 62AAAAAA AAAA                 [bbbbb╨ÿ╨ÿ╨ÿ╨ÿ╨ÿ      ]
  8643.       -------------------------------------------------------------------------------
  8644.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  8645.       -------------------------------------------------------------------------------
  8646.    ****************************************************************************/
  8647. }
  8648.  
  8649.  
  8650. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  8651.  
  8652. Example of _dump_allocated_delta 
  8653.  
  8654.      Differentiating between Memory Management Functions 
  8655.      _debug_calloc - Allocate and Initialize Memory 
  8656.      _debug_malloc - Allocate Memory 
  8657.      _dump_allocated - Get Information about Allocated Memory 
  8658.      _debug_realloc - Reallocate Memory Block 
  8659.      _set_crt_msg_handle - Change Runtime Message Output Destination 
  8660.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  8661.      _udump_allocated_delta - Get Information about Allocated Memory in Heap 
  8662.      <stdlib.h> 
  8663.      <malloc.h> 
  8664.  
  8665.  
  8666. ΓòÉΓòÉΓòÉ 4.68. dup - Associate Second Handle with Open File ΓòÉΓòÉΓòÉ
  8667.  
  8668.  
  8669. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  8670.  
  8671. #include <io.h>
  8672. int dup(int handle);
  8673.  
  8674.  
  8675. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  8676.  
  8677. Language Level:  XPG4, Extension 
  8678.  
  8679. dup associates a second file handle with a currently open file. You can carry 
  8680. out operations on the file using either file handle because all handles 
  8681. associated with a given file use the same file pointer. Creation of a new 
  8682. handle does not affect the type of access allowed for the file. 
  8683.  
  8684. For example, given: 
  8685.  
  8686.    handle2 = dup(handle1)
  8687. handle2 will have the same file access mode (text or binary) as handle1. In 
  8688. addition, if handle1 was originally opened with the O_APPEND flag (described in 
  8689. open - Open File), handle2 will also have that attribute. 
  8690.  
  8691. Warning: Both handles share a single file pointer. If you reposition a file 
  8692. using handle1, the position in the file returned by handle2 will also change. 
  8693.  
  8694. If you duplicate a file handle for an open stream, the resulting file handle 
  8695. has the same restrictions as the original file handle. 
  8696.  
  8697. Note:  In earlier releases of C Set ++, dup began with an underscore (_dup). 
  8698. Because it is defined by the X/Open standard, the underscore has been removed. 
  8699. For compatibility, VisualAge C++ will map _dup to dup for you. 
  8700.  
  8701. Return Value 
  8702. dup returns the next available file handle for the given file. It returns -1 if 
  8703. an error occurs and sets errno to one of the following values: 
  8704.  
  8705.  Value          Meaning 
  8706.  EBADF          The file handle is not valid. 
  8707.  EMFILE         No more file handles are available. 
  8708.  EOS2ERR        The call to the operating system was not successful. 
  8709.  
  8710.  
  8711. ΓòÉΓòÉΓòÉ <hidden> Example of dup ΓòÉΓòÉΓòÉ
  8712.  
  8713. /************************************************************************
  8714.  
  8715. This example makes a second file handle, fh3, refer to the same file as the 
  8716. file handle fh1 using dup. The file handle fh2 is then associated with the file 
  8717. edopen.da2, and finally fh2 is forced to associate with edopen.da1 dup2. 
  8718.  
  8719. ************************************************************************/
  8720.  
  8721. #include <io.h>
  8722. #include <stdio.h>
  8723. #include <stdlib.h>
  8724. #include <fcntl.h>
  8725. #include <sys\stat.h>
  8726.  
  8727. int main(void)
  8728. {
  8729.    int fh1,fh2,fh3;
  8730.  
  8731.    if (-1 == (fh1 = open("edopen.da1", O_CREAT|O_TRUNC|O_RDWR, S_IREAD|S_IWRITE)
  8732.       )) {
  8733.       perror("Unable to open edopen.da1");
  8734.       return EXIT_FAILURE;
  8735.    }
  8736.    if (-1 == (fh3 = dup(fh1))) {     /* fh3 refers to the sample file as fh1  */
  8737.       perror("Unable to dup");
  8738.       close(fh1);
  8739.       return EXIT_FAILURE;
  8740.    }
  8741.    else
  8742.       printf("Successfully performed dup handle.\n");
  8743.    if (-1 == (fh2 = open("edopen.da2", O_CREAT|O_TRUNC|O_RDWR, S_IREAD|S_IWRITE)
  8744.       )) {
  8745.       perror("Unable to open edopen.da2");
  8746.       close(fh1);
  8747.       close(fh3);
  8748.       return EXIT_FAILURE;
  8749.    }
  8750.    if (-1 == dup2(fh1, fh2)) {  /* Force fh2 to the refer to the same file     */
  8751.                                 /* as fh1.                                    */
  8752.       perror("Unable to dup2");
  8753.    }
  8754.    else
  8755.       printf("Successfully performed dup2 handle.\n");
  8756.    close(fh1);
  8757.    close(fh2);
  8758.    close(fh3);
  8759.    return 0;
  8760.  
  8761.    /****************************************************************************
  8762.       The output should be:
  8763.  
  8764.        Successfully performed dup handle.
  8765.        Successfully performed dup2 handle.
  8766.    ****************************************************************************/
  8767. }
  8768.  
  8769.  
  8770. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  8771.  
  8772. Example of dup 
  8773.  
  8774.      close - Close File Associated with Handle 
  8775.      creat - Create New File 
  8776.      dup2 - Associate Second Handle with Open File 
  8777.      open - Open File 
  8778.      _sopen - Open Shared File 
  8779.      <io.h> 
  8780.  
  8781.  
  8782. ΓòÉΓòÉΓòÉ 4.69. dup2 - Associate Second Handle with Open File ΓòÉΓòÉΓòÉ
  8783.  
  8784.  
  8785. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  8786.  
  8787. #include <io.h>
  8788. int dup2(int handle1, int handle2);
  8789.  
  8790.  
  8791. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  8792.  
  8793. Language Level:  XPG4, Extension 
  8794.  
  8795. dup2 makes handle2 refer to the currently open file associated with handle1. 
  8796. You can carry out operations on the file using either file handle because all 
  8797. handles associated with a given file use the same file pointer. 
  8798.  
  8799. handle2 will point to the same file as handle1, but will retain the file access 
  8800. mode (text or binary) that it had before duplication. In addition, if handle2 
  8801. was originally opened with the O_APPEND flag, it will also retain that 
  8802. attribute. If handle2 is associated with an open file at the time of the call, 
  8803. that file is closed. 
  8804.  
  8805. Warning: Both handles share a single file position. If you reposition a file 
  8806. using handle1, the position in the file returned by handle2 will also change. 
  8807.  
  8808. If you duplicate a file handle for an open stream (using fileno), the resulting 
  8809. file handle has the same restrictions as the original file handle. 
  8810.  
  8811. Note:  In earlier releases of C Set ++, dup2 began with an underscore (_dup2). 
  8812. Because it is defined by the X/Open standard, the underscore has been removed. 
  8813. For compatibility, VisualAge C++ will map _dup2 to dup2 for you. 
  8814.  
  8815. Return Value 
  8816. dup2 returns 0 to indicate success. It returns -1 if an error occurs and sets 
  8817. errno to one of the following values: 
  8818.  
  8819.  Value          Meaning 
  8820.  EBADF          The file handle is not valid. 
  8821.  EMFILE         No more file handles are available. 
  8822.  EOS2ERR        The call to the operating system was not successful. 
  8823.  
  8824.  
  8825. ΓòÉΓòÉΓòÉ <hidden> Example of dup2 ΓòÉΓòÉΓòÉ
  8826.  
  8827. /************************************************************************
  8828.  
  8829. This example makes a second file handle, fh3, refer to the same file as the 
  8830. file handle fh1 using dup. The file handle fh2 is then associated with the file 
  8831. edopen.da2, and finally fh2 is forced to associate with edopen.da1 by the dup2 
  8832. function. 
  8833.  
  8834. ************************************************************************/
  8835.  
  8836. #include <io.h>
  8837. #include <stdio.h>
  8838. #include <stdlib.h>
  8839. #include <fcntl.h>
  8840. #include <sys\stat.h>
  8841.  
  8842. int main(void)
  8843. {
  8844.    int fh1,fh2,fh3;
  8845.  
  8846.    if (-1 == (fh1 = open("edopen.da1", O_CREAT|O_TRUNC|O_RDWR, S_IREAD|S_IWRITE)
  8847.       )) {
  8848.       perror("Unable to open edopen.da1");
  8849.       return EXIT_FAILURE;
  8850.    }
  8851.    if (-1 == (fh3 = dup(fh1))) {     /* fh3 refers to the sample file as fh1  */
  8852.       perror("Unable to dup");
  8853.       close(fh1);
  8854.       return EXIT_FAILURE;
  8855.    }
  8856.    else
  8857.       printf("Successfully performed dup handle.\n");
  8858.    if (-1 == (fh2 = open("edopen.da2", O_CREAT|O_TRUNC|O_RDWR, S_IREAD|S_IWRITE)
  8859.       )) {
  8860.       perror("Unable to open edopen.da2");
  8861.       close(fh1);
  8862.       close(fh3);
  8863.       return EXIT_FAILURE;
  8864.    }
  8865.    if (-1 == dup2(fh1, fh2)) {  /* Force fh2 to the refer to the same file     */
  8866.                                 /* as fh1.                                    */
  8867.       perror("Unable to dup2");
  8868.    }
  8869.    else
  8870.       printf("Successfully performed dup2 handle.\n");
  8871.    close(fh1);
  8872.    close(fh2);
  8873.    close(fh3);
  8874.    return 0;
  8875.  
  8876.    /****************************************************************************
  8877.       The output should be:
  8878.  
  8879.        Successfully performed dup handle.
  8880.        Successfully performed dup2 handle.
  8881.    ****************************************************************************/
  8882. }
  8883.  
  8884.  
  8885. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  8886.  
  8887. Example of dup2 
  8888.  
  8889.      close - Close File Associated with Handle 
  8890.      creat - Create New File 
  8891.      dup - Associate Second Handle with Open File 
  8892.      open - Open File 
  8893.      _sopen - Open Shared File 
  8894.      <io.h> 
  8895.  
  8896.  
  8897. ΓòÉΓòÉΓòÉ 4.70. _ecvt - Convert Floating-Point to Character ΓòÉΓòÉΓòÉ
  8898.  
  8899.  
  8900. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  8901.  
  8902. #include <stdlib.h>
  8903. char *_ecvt(double value, int ndigits, int *decptr, int *signptr);
  8904.  
  8905.  
  8906. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  8907.  
  8908. Language Level:  Extension 
  8909.  
  8910. _ecvt converts the floating-point number value to a character string. _ecvt 
  8911. stores ndigits digits of value as a string and adds a null character (\0). If 
  8912. the number of digits in value exceeds ndigits, the low-order digit is rounded. 
  8913. If there are fewer than ndigits digits, the string is padded with zeros. Only 
  8914. digits are stored in the string. 
  8915.  
  8916. You can obtain the position of the decimal point and the sign of value after 
  8917. the call from decptr and signptr. decptr points to an integer value that gives 
  8918. the position of the decimal point with respect to the beginning of the string. 
  8919. A 0 or a negative integer value indicates that the decimal point lies to the 
  8920. left of the first digit. 
  8921.  
  8922. signptr points to an integer that indicates the sign of the converted number. 
  8923. If the integer value is 0, the number is positive. If it is not 0, the number 
  8924. is negative. 
  8925.  
  8926. _ecvt also converts NaN and infinity values to the strings NAN and INFINITY, 
  8927. respectively. For more information on NaN and infinity values, see Infinity and 
  8928. NaN Support. 
  8929.  
  8930. Warning: For each thread, the _ecvt, _fcvt and _gcvt functions use a single, 
  8931. dynamically allocated buffer for the conversion. Any subsequent call that the 
  8932. same thread makes to these functions destroys the result of the previous call. 
  8933.  
  8934. Return Value 
  8935. _ecvt returns a pointer to the string of digits. Because of the limited 
  8936. precision of the double type, no more than 16 decimal digits are significant in 
  8937. any conversion. If it cannot allocate memory to perform the conversion. _ecvt 
  8938. returns NULL and sets errno to ENOMEM. 
  8939.  
  8940.  
  8941. ΓòÉΓòÉΓòÉ <hidden> Example of _ecvt ΓòÉΓòÉΓòÉ
  8942.  
  8943. /************************************************************************
  8944.  
  8945. This example reads in two floating-point numbers, calculates their product, and 
  8946. prints out only the billions digit of its character representation. At most, 16 
  8947. decimal digits of significance can be expected. The output assumes the user 
  8948. enters the numbers 1000000 and 3000. 
  8949.  
  8950. ************************************************************************/
  8951.  
  8952. #include <stdio.h>
  8953. #include <stdlib.h>
  8954. #include <math.h>
  8955.  
  8956. int main(void)
  8957. {
  8958.    float x,y;
  8959.    double z;
  8960.    int w,b,decimal,sign;
  8961.    char *buffer;
  8962.  
  8963.    printf("Enter two floating-point numbers:\n");
  8964.    if (2 != scanf("%e %e", &x, &y)) {
  8965.       printf("input error...\n");
  8966.       return EXIT_FAILURE;
  8967.    }
  8968.    z = x *y;
  8969.    printf("Their product is %g\n", z);
  8970.    w = log10(fabs(z))+1.;
  8971.    buffer = _ecvt(z, w, &decimal, &sign);
  8972.    b = decimal-10;
  8973.    if (b < 0)
  8974.       printf("Their product does not exceed one billion.\n");
  8975.    else
  8976.       if (b > 15)
  8977.          printf("The billions digit of their product is insignificant.\n");
  8978.       else
  8979.          printf("The billions digit of their product is %c.\n", buffer[b]);
  8980.    return 0;
  8981.  
  8982.    /****************************************************************************
  8983.       For the following input:
  8984.  
  8985.       1000000 3000
  8986.  
  8987.       The output should be:
  8988.  
  8989.       Enter two floating-point numbers:
  8990.       1000000 3000
  8991.       Their product is 3e+09
  8992.       The billions digit of their product is 3.
  8993.    ****************************************************************************/
  8994. }
  8995.  
  8996.  
  8997. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  8998.  
  8999. Example of _ecvt 
  9000.  
  9001.      _fcvt - Convert Floating-Point to String 
  9002.      _gcvt - Convert Floating-Point to String 
  9003.      Infinity and NaN Support 
  9004.      <stdlib.h> 
  9005.  
  9006.  
  9007. ΓòÉΓòÉΓòÉ 4.71. _enable - Enable Interrupts ΓòÉΓòÉΓòÉ
  9008.  
  9009.  
  9010. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9011.  
  9012. #include <builtin.h>  /* also defined in <stdlib.h> */
  9013. void _enable( void );
  9014.  
  9015.  
  9016. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9017.  
  9018. Language Level:  Extension 
  9019.  
  9020. _enable enables interrupts by generating the STI machine instruction. 
  9021. Interrupts are enabled after the instruction following STI has been executed. 
  9022. If interrupts are disabled and you call _enable followed immediately by a call 
  9023. to _disable, interrupts remain disabled. 
  9024.  
  9025. Because it is a built-in function and has no backing code in the library: 
  9026.  
  9027.      You cannot take the address of _enable. 
  9028.      You cannot parenthesize an _enable function call because parentheses 
  9029.       specify a call to the backing code for the function in the library. 
  9030.  
  9031.  You can run code containing this function only at ring zero. Otherwise, an 
  9032.  invalid instruction exception will be generated. 
  9033.  
  9034.  Return Value 
  9035.  There is no return value. 
  9036.  
  9037.  
  9038. ΓòÉΓòÉΓòÉ <hidden> Example of _enable ΓòÉΓòÉΓòÉ
  9039.  
  9040. /************************************************************************
  9041.  
  9042. In this example, _enable enables interrupts by executing an STI instruction. 
  9043.  
  9044. ************************************************************************/
  9045.  
  9046. #include <builtin.h>
  9047.  
  9048. int main(void)
  9049. {
  9050.    /* ------------------------------------------------------ */
  9051.    /* The expected assembler instruction looks like this :   */
  9052.    /*       STI                                              */
  9053.    /* ------------------------------------------------------ */
  9054.    _enable();
  9055.    return 0;
  9056. }
  9057.  
  9058.  
  9059. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9060.  
  9061. Example of _enable 
  9062.  
  9063.      _disable - Disable Interrupts 
  9064.      _interrupt - Call Interrupt  Procedure 
  9065.      <builtin.h> 
  9066.  
  9067.  
  9068. ΓòÉΓòÉΓòÉ 4.72. _endthread - Terminate Current Thread ΓòÉΓòÉΓòÉ
  9069.  
  9070.  
  9071. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9072.  
  9073. #include <stdlib.h>  /* also in <process.h> */
  9074. void _endthread(void);
  9075.  
  9076.  
  9077. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9078.  
  9079. Language Level:  Extension 
  9080.  
  9081. _endthread ends a thread that you previously created with _beginthread. When 
  9082. the thread has finished, it automatically ends itself with an implicit call to 
  9083. _endthread. You can also call _endthread explicitly to end the thread before it 
  9084. has completed its function, for example, if some error condition occurs. 
  9085.  
  9086. Note: 
  9087.  
  9088.    1. When using the _beginthread and _endthread functions, you must specify 
  9089.       the /Gm+ compiler option to use the multithread libraries. 
  9090.  
  9091.    2. If you use DosCreateThread, you must explicitly call _endthread to 
  9092.       terminate the thread. 
  9093.  
  9094.  Return Value 
  9095.  There is no return value. 
  9096.  
  9097.  
  9098. ΓòÉΓòÉΓòÉ <hidden> Example of _endthread ΓòÉΓòÉΓòÉ
  9099.  
  9100. /************************************************************************
  9101.  
  9102. In this example, the main program creates two threads, bonjour and au_revoir. 
  9103. The thread bonjour is forcibly terminated by a call to _endthread, while the 
  9104. au_revoir thread ends itself with an implicit call to _endthread. 
  9105.  
  9106. Note:  You must compile this example with the /Gm+ option. 
  9107.  
  9108. ************************************************************************/
  9109.  
  9110. #define  INCL_DOS
  9111. #include <os2.h>
  9112. #include <stdio.h>
  9113. #include <stdlib.h>
  9114. #include <process.h>
  9115.  
  9116. void bonjour(void *arg)
  9117. {
  9118.    int i = 0;
  9119.  
  9120.    while (i++ < 5)
  9121.       printf("Bonjour!\n");
  9122.    _endthread();                         /* This thread ends itself explicitly*/
  9123.    puts("thread should terminate before printing this");
  9124. }
  9125.  
  9126. void au_revoir(void *arg)
  9127. {
  9128.    int i = 0;
  9129.  
  9130.    while (i++ < 5)                      /* This thread makes an implicit      */
  9131.       printf("Au revoir!\n");                     /* call to _endthread       */
  9132. }
  9133.  
  9134. int main(void)
  9135. {
  9136.    unsigned long tid1;
  9137.    unsigned long tid2;
  9138.  
  9139.    tid1 = _beginthread(bonjour, NULL, 8192, NULL);
  9140.    tid2 = _beginthread(au_revoir, NULL, 8192, NULL);
  9141.    if (-1 == tid1 || -1 == tid2) {
  9142.       printf("Unable to start threads.\n");
  9143.       return EXIT_FAILURE;
  9144.    }
  9145.    DosWaitThread(&tid2, DCWW_WAIT);            /* wait until threads 1 and 2  */
  9146.    DosWaitThread(&tid1, DCWW_WAIT);             /* have been completed        */
  9147.    return 0;
  9148.  
  9149.    /****************************************************************************
  9150.       The output should be similar to:
  9151.  
  9152.       Au revoir!
  9153.       Au revoir!
  9154.       Au revoir!
  9155.       Au revoir!
  9156.       Au revoir!
  9157.       Bonjour!
  9158.       Bonjour!
  9159.       Bonjour!
  9160.       Bonjour!
  9161.       Bonjour!
  9162.    ****************************************************************************/
  9163. }
  9164.  
  9165.  
  9166. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9167.  
  9168. Example of _endthread 
  9169.  
  9170.      _beginthread - Create New Thread 
  9171.      /Gm+ option. in the User's Guide 
  9172.      <stdlib.h> 
  9173.      <process.h> 
  9174.  
  9175.  
  9176. ΓòÉΓòÉΓòÉ 4.73. __eof - Determine End of File ΓòÉΓòÉΓòÉ
  9177.  
  9178.  
  9179. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9180.  
  9181. #include <io.h>
  9182. int __eof (int handle);
  9183.  
  9184.  
  9185. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9186.  
  9187. Language Level:  Extension 
  9188.  
  9189. __eof determines whether the file pointer has reached the end-of-file for the 
  9190. file associated with handle. You cannot use __eof on a nonseekable file; it 
  9191. will fail. 
  9192.  
  9193. Return Value 
  9194. __eof returns the value 1 if the current position is the end of the file or 0 
  9195. if it is not. A return value of -1 shows an error, and the system sets errno to 
  9196. the following values: 
  9197.  
  9198.  Value          Meaning 
  9199.  EBADF          File handle is not valid. 
  9200.  EOS2ERR        The call to the operating system was not successful. 
  9201.  
  9202.  
  9203. ΓòÉΓòÉΓòÉ <hidden> Example of __eof ΓòÉΓòÉΓòÉ
  9204.  
  9205. /************************************************************************
  9206.  
  9207. This example creates the file sample.dat and then checks if the file pointer is 
  9208. at the end of that file using the __eof function. 
  9209.  
  9210. ************************************************************************/
  9211.  
  9212. #include <sys\stat.h>
  9213. #include <io.h>
  9214. #include <stdio.h>
  9215. #include <stdlib.h>
  9216.  
  9217. int main(void)
  9218. {
  9219.    int fh,returnValue;
  9220.  
  9221.    fh = creat("sample.dat", S_IREAD|S_IWRITE);
  9222.    if (-1 == fh) {
  9223.       perror("Error creating sample.dat");
  9224.       return EXIT_FAILURE;
  9225.    }
  9226.    if (-1 == (returnValue = __eof(fh))) {
  9227.       perror("eof function error");
  9228.       return EXIT_FAILURE;
  9229.    }
  9230.    if (1 == returnValue)
  9231.       printf("File pointer is at end-of-file position.\n");
  9232.    else
  9233.       printf("File pointer is not at end-of-file position.\n");
  9234.    close(fh);
  9235.    return 0;
  9236.  
  9237.    /****************************************************************************
  9238.       The output should be:
  9239.  
  9240.       File pointer is at end-of-file position.
  9241.    ****************************************************************************/
  9242. }
  9243.  
  9244.  
  9245. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9246.  
  9247. Example of __eof 
  9248.  
  9249.      _chsize - Alter Length of File 
  9250.      creat - Create New File 
  9251.      _filelength - Determine File Length 
  9252.      _sopen - Open Shared File 
  9253.      open - Open File 
  9254.      <io.h> 
  9255.  
  9256.  
  9257. ΓòÉΓòÉΓòÉ 4.74. erf - erfc - Calculate Error Functions ΓòÉΓòÉΓòÉ
  9258.  
  9259.  
  9260. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9261.  
  9262. #include <math.h>
  9263. double erf(double x);
  9264. double erfc(double x);
  9265.  
  9266.  
  9267. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9268.  
  9269. Language Level: SAA, XPG4 
  9270.  
  9271. erf calculates the error function. 
  9272.  
  9273. erfc computes the value of 1.0 - erf(x). erfc is used in place of erf for large 
  9274. values of x. 
  9275.  
  9276. Return Value 
  9277. erf returns a double value that represents the error function. erfc returns a 
  9278. double value representing 1.0 - erf. 
  9279.  
  9280.  
  9281. ΓòÉΓòÉΓòÉ <hidden> Example of erf - erfc ΓòÉΓòÉΓòÉ
  9282.  
  9283. /************************************************************************
  9284.  
  9285. This example uses erf and erfc to compute the error function of two numbers. 
  9286.  
  9287. ************************************************************************/
  9288.  
  9289. #include <stdio.h>
  9290. #include <math.h>
  9291.  
  9292. double smallx,largex,value;
  9293.  
  9294. int main(void)
  9295. {
  9296.    smallx = 0.1;
  9297.    largex = 10.0;
  9298.    value = erf(smallx);                                   /* value = 0.112463 */
  9299.    printf("Error value for 0.1: %lf\n", value);
  9300.    value = erfc(largex);                          /* value = 2.088488e-45     */
  9301.    printf("Error value for 10.0: %le\n", value);
  9302.    return 0;
  9303.  
  9304.    /****************************************************************************
  9305.       The output should be:
  9306.  
  9307.       Error value for 0.1: 0.112463
  9308.       Error value for 10.0: 2.088488e-45
  9309.    ****************************************************************************/
  9310. }
  9311.  
  9312.  
  9313. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9314.  
  9315. Example of erf - erfc 
  9316.  
  9317.      Bessel Functions - Solve Differential Equations 
  9318.      gamma - Gamma Function 
  9319.      <math.h> 
  9320.  
  9321.  
  9322. ΓòÉΓòÉΓòÉ 4.75. execl - _execvpe - Load and Run Child Process ΓòÉΓòÉΓòÉ
  9323.  
  9324.  
  9325. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9326.  
  9327. #include <process.h>
  9328. int execl(char *pathname, char *arg0, char *arg1,...,
  9329.              char *argn, NULL);
  9330. int execle(char *pathname, char *arg0, char *arg1,...,
  9331.              char *argn, NULL, char *envp[ ]);
  9332. int execlp(char *pathname, char *arg0, char *arg1,...,
  9333.              char *argn, NULL);
  9334. int _execlpe(char *pathname, char *arg0, char *arg1,...,
  9335.              char *argn, NULL, char *envp[ ]);
  9336. int execv(char *pathname, char *argv[ ]);
  9337. int execve(char *pathname, char *argv[ ],char *envp[ ]);
  9338. int execvp(char *pathname, char *argv[ ]);
  9339. int _execvpe(char *pathname, char *argv[ ], char *envp[ ]);
  9340.  
  9341.  
  9342. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9343.  
  9344. Language Level:  XPG4 (except _execlpe and _execvpe), Extension 
  9345.  
  9346. The exec functions load and run new child processes. The parent process is 
  9347. ended after the child process has started.  Sufficient storage must be 
  9348. available for loading and running the child process. 
  9349.  
  9350. All of the exec functions are versions of the same routine;  the letters at the 
  9351. end determine the specific variation: 
  9352.  
  9353.  Letter    Variation 
  9354.   p        Uses PATH environment variable to find the file to be run. 
  9355.   l        Passes a list of command line arguments separately. 
  9356.   v        Passes to the child process an array of pointers to command-line 
  9357.            arguments. 
  9358.   e        Passes to the child process an array of pointers to environment 
  9359.            strings. 
  9360.  
  9361.  Note:  In earlier releases of C Set ++, all of the exec functions began with 
  9362.  an underscore (_getpid). Because they are defined by the X/Open standard, the 
  9363.  underscore has been removed. _execlpe and _execvpe retain the initial 
  9364.  underscore because they are not included in the X/Open standard. For 
  9365.  compatibility, VisualAge C++ will map the _exec functions to the correct exec 
  9366.  function. 
  9367.  
  9368.  The pathname argument specifies the file to run as the child process.  The 
  9369.  pathname can specify a full path from the root, a partial path from the 
  9370.  current working directory, or a file name.  If pathname does not have a file 
  9371.  name extension or does not end with a period, the exec functions will add the 
  9372.  .EXE extension and search for the file.  If pathname has an extension, the 
  9373.  exec function uses only that extension. If pathname ends with a period, the 
  9374.  exec functions search for pathname with no extension.  The execlp, _execlpe, 
  9375.  execvp, and _execvpe functions search for the pathname in the directories that 
  9376.  the PATH environment variable specifies. 
  9377.  
  9378.  You pass arguments to the new process by giving one or more pointers to 
  9379.  character strings as arguments in the exec call.  These character strings form 
  9380.  the argument list for the child process. 
  9381.  
  9382.  The compiler can pass the argument pointers as separate arguments (execl, 
  9383.  execle, execlp, and _execlpe) or as an array of pointers (execv, execve, 
  9384.  execvp, and _execvpe).  You should pass at least one argument, either arg0 or 
  9385.  argv[0], to the child process. If you do not, an argument will be returned 
  9386.  that points to the same file as the path name argument you specified. This 
  9387.  argument may not be exactly identical to the path name argument you specified. 
  9388.  A different value does not produce an error. 
  9389.  
  9390.  Use the execl, execle, execlp, and _execlpe functions for the cases where you 
  9391.  know the number of arguments in advance. The arg0 argument is usually a 
  9392.  pointer to pathname. The arg1 through argn arguments are pointers to the 
  9393.  character strings forming the new argument list. There must be a NULL pointer 
  9394.  following argn to mark the end of the argument list. 
  9395.  
  9396.  Use the execv, execve, execvp, and _execvpe functions when the number of 
  9397.  arguments to the new process is variable.  Pass pointers to the arguments of 
  9398.  these functions as an array, argv[ ]. The argv[0] argument is usually a 
  9399.  pointer to pathname. The argv[1] through argv[n] arguments are pointers to the 
  9400.  character strings forming the new argument list.  If argv[n] is the last 
  9401.  parameter, then argv[n+1] must be NULL. 
  9402.  
  9403.  Files that are open when you make an exec call remain open in the new process. 
  9404.  In the execl, execlp, execv, and execvp calls, the child process receives the 
  9405.  environment of the parent.  The execle, _execlpe, execve, and _execvpe 
  9406.  functions let you change the environment for the child process by passing a 
  9407.  list of environment settings through the envp argument.  The envp argument is 
  9408.  an array of character pointers, each element of which points to a string 
  9409.  ending with a null character that defines an environment variable.  Such a 
  9410.  string usually has the following form: 
  9411.  
  9412.      NAME=value
  9413.  
  9414.  where NAME is the name of an environment variable, and value is the string 
  9415.  value to which the exec function sets that variable. 
  9416.  
  9417.  Note:  Do not enclose the value in double quotation marks. 
  9418.  
  9419.  The final element of the envp array should be NULL. When envp itself is NULL, 
  9420.  the child process receives the environment settings of the parent process. 
  9421.  
  9422.  The exec functions do not preserve signal settings in child processes created 
  9423.  by calls to exec functions.  Calls to exec functions reset the signal settings 
  9424.  to the default in the child process. 
  9425.  
  9426.  Return Value 
  9427.  The exec functions do not normally return control to the calling process. 
  9428.  They are equivalent to the corresponding _spawn functions with P_OVERLAY as 
  9429.  the value of modeflag.  If an error occurs, the exec functions return -1 and 
  9430.  set errno to one of the following values: 
  9431.  
  9432.  Value          Meaning 
  9433.  EACCESS        The specified file has a locking or sharing violation. 
  9434.  EMFILE         There are too many open files.  The system must open the 
  9435.                 specified file to tell whether it is an executable file. 
  9436.  ENOENT         The file or pathname was not found or was specified 
  9437.                 incorrectly. 
  9438.  ENOEXEC        The specified file cannot run or has an incorrect executable 
  9439.                 file format. 
  9440.  ENOMEM         One of the following conditions exists: 
  9441.                     Not enough storage is available to run the child process. 
  9442.                     Not enough storage is available for the argument or 
  9443.                      environment strings. 
  9444.  
  9445.  
  9446. ΓòÉΓòÉΓòÉ <hidden> Example of exec Functions ΓòÉΓòÉΓòÉ
  9447.  
  9448. /************************************************************************
  9449.  
  9450. This example calls four of the eight exec routines.  When invoked without 
  9451. arguments, the program first runs the code for case PARENT.  It then calls 
  9452. execle() to load and run a copy of itself.  The instructions for the child are 
  9453. blocked to run only if argv[0] and one parameter were passed (case CHILD).  In 
  9454. its turn, the child runs its own child as a copy of the same program.  This 
  9455. sequence is continued until four generations of child processes have run.  Each 
  9456. of the processes prints a message identifying itself. 
  9457.  
  9458. ************************************************************************/
  9459.  
  9460. #include <stdio.h>
  9461. #include <stdlib.h>
  9462. #include <process.h>
  9463.  
  9464. #define  PARENT       1
  9465. #define  CHILD        2
  9466.  
  9467. char *args[3];
  9468.  
  9469. int main(int argc, char **argv, char **envp) {
  9470.    switch(argc) {
  9471.       case PARENT: {                   /* No argument: run a child */
  9472.          printf("Parent process began.\n");
  9473.          execle(argv[0],argv[0],"1",NULL,envp);
  9474.          abort();     /* Not executed because parent was overlaid. */
  9475.       }
  9476.       case CHILD: {           /* One argument: run a child's child */
  9477.          printf("Child process %s began.\n", argv[1]);
  9478.          if ('1' == *argv[1]) {   /* generation one */
  9479.             execl(argv[0], argv[0], "2", NULL);
  9480.             abort();    /* Not executed because child was overlaid */
  9481.         }
  9482.         if('2' == *argv[1]) {                    /* generation two */
  9483.             args[0] = argv[0];
  9484.             args[1] = "3";
  9485.             args[2] = NULL;
  9486.             execv(argv[0],args);
  9487.             abort();    /* Not executed because child was overlaid */
  9488.          }
  9489.          if ('3' == *argv[1]) {                /* generation three */
  9490.             args[0] = argv[0];
  9491.             args[1] = "4";
  9492.             args[2] = NULL;
  9493.             execve(argv[0], args, _environ);
  9494.             abort();    /* Not executed because child was overlaid */
  9495.         }
  9496.          if ('4' == *argv[1])                   /* generation four */
  9497.             printf("Child process %s", argv[1]);
  9498.       }
  9499.    }
  9500.    printf(" ended.\n");
  9501.    return 55;
  9502.    /* The output should be similar to:
  9503.       Parent process began.
  9504.       Child process 1 began.
  9505.       Child process 2 began.
  9506.       Child process 3 began.
  9507.       Child process 4 began.
  9508.       Child process 4 ended.                                        */
  9509. }
  9510.  
  9511.  
  9512. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9513.  
  9514. Example of exec Functions 
  9515.  
  9516.      abort - Stop a Program 
  9517.      _cwait - Wait for Child Process 
  9518.      exit - End Program 
  9519.      _exit - End Process 
  9520.      _spawnl - _spawnvpe - Start and Run Child Processes 
  9521.      system - Invoke the Command Processor 
  9522.      wait - Wait for Child Process 
  9523.      "envp Parameter to main" in the Programming Guide 
  9524.      <process.h> 
  9525.  
  9526.  
  9527. ΓòÉΓòÉΓòÉ 4.76. exit - End Program ΓòÉΓòÉΓòÉ
  9528.  
  9529.  
  9530. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9531.  
  9532. #include <stdlib.h>  /* also in <process.h> */
  9533. void exit(int status);
  9534.  
  9535.  
  9536. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9537.  
  9538. Language Level: ANSI, SAA, POSIX, XPG4, Extension 
  9539.  
  9540. exit returns control to the host environment from the program. It first calls 
  9541. all functions registered with the atexit function, in reverse order;  that is, 
  9542. the last one registered is the first one called. It flushes all buffers and 
  9543. closes all open files before ending the program. All files opened with tmpfile 
  9544. are deleted. 
  9545.  
  9546. The argument status can have a value from 0 to 255 inclusive or be one of the 
  9547. macros EXIT_SUCCESS or EXIT_FAILURE. A status value of EXIT_SUCCESS or 0 
  9548. indicates a normal exit; otherwise, another status value is returned. 
  9549.  
  9550. Return Value 
  9551. exit returns both control and the value of status to the operating system. 
  9552.  
  9553.  
  9554. ΓòÉΓòÉΓòÉ <hidden> Example of exit ΓòÉΓòÉΓòÉ
  9555.  
  9556. /************************************************************************
  9557.  
  9558. This example ends the program after flushing buffers and closing any open files 
  9559. if it cannot open the file myfile.mjq. 
  9560.  
  9561. ************************************************************************/
  9562.  
  9563. #include <stdio.h>
  9564. #include <stdlib.h>
  9565.  
  9566. FILE *stream;
  9567.  
  9568. int main(void)
  9569. {
  9570.    if (NULL == (stream = fopen("myfile.mjq", "r"))) {
  9571.       perror("Could not open data file");
  9572.       exit(EXIT_FAILURE);
  9573.    }
  9574.    return 0;
  9575.  
  9576.    /****************************************************************************
  9577.       The output should be:
  9578.  
  9579.       Could not open data file: The file cannot be found.
  9580.    ****************************************************************************/
  9581. }
  9582.  
  9583.  
  9584. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9585.  
  9586. Example of exit 
  9587.  
  9588.      abort - Stop a Program 
  9589.      atexit - Record Program Termination Function 
  9590.      _onexit - Record Termination Function 
  9591.      _exit - End Process 
  9592.      signal - Handle Interrupt Signals 
  9593.      tmpfile - Create Temporary File 
  9594.      <stdlib.h> 
  9595.  
  9596.  
  9597. ΓòÉΓòÉΓòÉ 4.77. _exit - End Process ΓòÉΓòÉΓòÉ
  9598.  
  9599.  
  9600. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9601.  
  9602. #include <stdlib.h>  /* also in <process.h> */
  9603. void _exit(int status);
  9604.  
  9605.  
  9606. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9607.  
  9608. Language Level:  Extension 
  9609.  
  9610. _exit ends the calling process without calling functions registered by _onexit 
  9611. or atexit. It also does not flush stream buffers or delete temporary files. You 
  9612. supply the status value as a parameter; the value 0 typically means a normal 
  9613. exit. 
  9614.  
  9615. Return Value 
  9616. Although _exit does not return a value, the value is available to the waiting 
  9617. parent process, if there is one, after the child process ends.  If no parent 
  9618. process waits for the exiting process, the status value is lost.  The status 
  9619. value is available through the operating system batch command IF ERRORLEVEL. 
  9620.  
  9621.  
  9622. ΓòÉΓòÉΓòÉ <hidden> Example of _exit ΓòÉΓòÉΓòÉ
  9623.  
  9624. /************************************************************************
  9625.  
  9626. This example calls _exit to end the process. Because _exit does not flush the 
  9627. buffer first, the output from the second printf statement will not appear. 
  9628.  
  9629. ************************************************************************/
  9630.  
  9631. #include <stdio.h>
  9632. #include <stdlib.h>                      /* You can also use <process.h>      */
  9633.  
  9634. char buf[51];
  9635.  
  9636. int main(void)
  9637. {
  9638.  
  9639.    /* Make sure the standard output stream is line-buffered even if the       */
  9640.    /* output is redirected to a file.                                         */
  9641.  
  9642.    if (0 != setvbuf(stdout, buf, _IOLBF, 50))
  9643.       printf("The buffering was not set correctly.\n");
  9644.    printf("This will print out but ...\n");
  9645.    printf("this will not!");
  9646.    _exit(EXIT_FAILURE);
  9647.    return 0;
  9648.  
  9649.    /****************************************************************************
  9650.       The output should be:
  9651.  
  9652.       This will print out but ...
  9653.    ****************************************************************************/
  9654. }
  9655.  
  9656.  
  9657. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9658.  
  9659. Example of _exit 
  9660.  
  9661.      abort - Stop a Program 
  9662.      atexit - Record Program Termination Function 
  9663.      execl - _execvpe - Load and Run Child Process 
  9664.      exit - End Program 
  9665.      _onexit - Record Termination Function 
  9666.      <process.h> 
  9667.      <stdlib.h> 
  9668.  
  9669.  
  9670. ΓòÉΓòÉΓòÉ 4.78. exp - Calculate Exponential Function ΓòÉΓòÉΓòÉ
  9671.  
  9672.  
  9673. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9674.  
  9675. #include <math.h>
  9676. double exp(double x);
  9677.  
  9678.  
  9679. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9680.  
  9681. Language Level: ANSI, SAA, POSIX, XPG4 
  9682.  
  9683. exp calculates the exponential function of a floating-point argument x (e to 
  9684. the exponent x, where e equals 2.17128128...). 
  9685.  
  9686. Return Value 
  9687. If an overflow occurs, exp returns HUGE_VAL. If an underflow occurs, it returns 
  9688. 0. Both overflow and underflow set errno to ERANGE. 
  9689.  
  9690.  
  9691. ΓòÉΓòÉΓòÉ <hidden> Example of exp ΓòÉΓòÉΓòÉ
  9692.  
  9693. /************************************************************************
  9694.  
  9695. This example calculates y as the exponential function of x: 
  9696.  
  9697. ************************************************************************/
  9698.  
  9699. #include <math.h>
  9700.  
  9701. int main(void)
  9702. {
  9703.    double x,y;
  9704.  
  9705.    x = 5.0;
  9706.    y = exp(x);
  9707.    printf("exp( %lf ) = %lf\n", x, y);
  9708.    return 0;
  9709.  
  9710.    /****************************************************************************
  9711.       The output should be:
  9712.  
  9713.       exp( 5.000000 ) = 148.413159
  9714.    ****************************************************************************/
  9715. }
  9716.  
  9717.  
  9718. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9719.  
  9720. Example of exp 
  9721.  
  9722.      log - Calculate Natural Logarithm 
  9723.      log10 - Calculate Base 10 Logarithm 
  9724.      <math.h> 
  9725.  
  9726.  
  9727. ΓòÉΓòÉΓòÉ 4.79. fabs - Calculate Floating-Point Absolute Value ΓòÉΓòÉΓòÉ
  9728.  
  9729.  
  9730. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9731.  
  9732. #include <math.h>
  9733. double fabs(double x);
  9734.  
  9735.  
  9736. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9737.  
  9738. Language Level: ANSI, SAA, POSIX, XPG4 
  9739.  
  9740. fabs calculates the absolute value of the floating-point argument x. 
  9741.  
  9742. Return Value 
  9743. fabs returns the absolute value. There is no error return value. 
  9744.  
  9745.  
  9746. ΓòÉΓòÉΓòÉ <hidden> Example of fabs ΓòÉΓòÉΓòÉ
  9747.  
  9748. /************************************************************************
  9749.  
  9750. This example calculates y as the absolute value of x: 
  9751.  
  9752. ************************************************************************/
  9753.  
  9754. #include <math.h>
  9755.  
  9756. int main(void)
  9757. {
  9758.    double x,y;
  9759.  
  9760.    x = -5.6798;
  9761.    y = fabs(x);
  9762.    printf("fabs( %lf ) = %lf\n", x, y);
  9763.    return 0;
  9764.  
  9765.    /****************************************************************************
  9766.       The output should be similar to :
  9767.  
  9768.       fabs( -5.679800 ) = 5.679800
  9769.    ****************************************************************************/
  9770. }
  9771.  
  9772.  
  9773. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9774.  
  9775. Example of fabs 
  9776.  
  9777.      abs - Calculate Integer Absolute Value 
  9778.      _cabs - Calculate Absolute Value of Complex Number 
  9779.      labs - Calculate Absolute Value of Long Integer 
  9780.      <math.h> 
  9781.  
  9782.  
  9783. ΓòÉΓòÉΓòÉ 4.80. _facos - Calculate Arccosine ΓòÉΓòÉΓòÉ
  9784.  
  9785.  
  9786. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9787.  
  9788. #include <builtin.h>
  9789. double _facos(double x);
  9790.  
  9791.  
  9792. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9793.  
  9794. Language Level:  Extension 
  9795.  
  9796. _facos calculates the arccosine of x. This function causes the compiler to emit 
  9797. the appropriate 80387 instructions for the calculation of the arccosine. 
  9798.  
  9799. Because it is a built-in function and has no backing code in the library: 
  9800.  
  9801.      You cannot take the address of _facos. 
  9802.      You cannot parenthesize a _facos function call, because parentheses 
  9803.       specify a call to the backing code for the function. 
  9804.  
  9805.  Return Value 
  9806.  _facos returns the arccosine of x. 
  9807.  
  9808.  
  9809. ΓòÉΓòÉΓòÉ <hidden> Example of _facos ΓòÉΓòÉΓòÉ
  9810.  
  9811. /************************************************************************
  9812.  
  9813. This example prompts for a value for x. It prints an error message if x is 
  9814. greater than 1 or less than -1. Otherwise, it assigns the arccosine of x to y. 
  9815.  
  9816. ************************************************************************/
  9817.  
  9818. #include <builtin.h>
  9819. #include <stdio.h>
  9820.  
  9821. #define MAX  1.0
  9822. #define MIN -1.0
  9823.  
  9824. int main(void)
  9825. {
  9826.    double x;
  9827.  
  9828.    printf("Enter x:\n");
  9829.    scanf("%lf", &x);
  9830.  
  9831.    /* Output error if not in range */
  9832.    if (MAX < x)
  9833.       printf("Error: %lf too large for acos.\n", x);
  9834.    else if (MIN > x)
  9835.            printf("Error: %lf too small for acos.\n", x);
  9836.         else
  9837.            printf("The arccossine of %lf is %lf.\n", x, _facos(x));
  9838.    return 0;
  9839.  
  9840.    /****************************************************************************
  9841.       Assuming you enter: -1.0
  9842.  
  9843.       The output should be:
  9844.  
  9845.       The arccossine of -1.000000 is 3.141593.
  9846.    ****************************************************************************/
  9847. }
  9848.  
  9849.  
  9850. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9851.  
  9852. Example of _facos 
  9853.  
  9854.      acos - Calculate Arccosine 
  9855.      cos - Calculate Cosine 
  9856.      cosh - Calculate Hyperbolic Cosine 
  9857.      _fcos - Calculate Cosine 
  9858.      _fcossin - Calculate Cosine and Sine 
  9859.      _fsincos - Calculate Sine and Cosine 
  9860.      <builtin.h> 
  9861.  
  9862.  
  9863. ΓòÉΓòÉΓòÉ 4.81. _fasin - Calculate Arcsine ΓòÉΓòÉΓòÉ
  9864.  
  9865.  
  9866. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9867.  
  9868. #include <builtin.h>
  9869. double _fasin(double x);
  9870.  
  9871.  
  9872. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9873.  
  9874. Language Level:  Extension 
  9875.  
  9876. _fasin calculates the arcsine of x. This function causes the compiler to emit 
  9877. the appropriate 80387 instructions for the calculation of arcsine. 
  9878.  
  9879. Because it is a built-in function and has no backing code in the library: 
  9880.  
  9881.      You cannot take the address of _fasin. 
  9882.      You cannot parenthesize a _fasin function call, because parentheses 
  9883.       specify a call to the backing code for the function. 
  9884.  
  9885.  Return Value 
  9886.  _facos returns the arcsine of x. 
  9887.  
  9888.  
  9889. ΓòÉΓòÉΓòÉ <hidden> Example of _fasin ΓòÉΓòÉΓòÉ
  9890.  
  9891. /************************************************************************
  9892.  
  9893. This example prompts for a value of x. It prints an error message if x is 
  9894. greater than 1 or less than -1. Otherwise, it assigns the arcsine of x to y. 
  9895.  
  9896. ************************************************************************/
  9897.  
  9898. #include <builtin.h>
  9899. #include <stdio.h>
  9900.  
  9901. #define MAX  1.0
  9902. #define MIN -1.0
  9903.  
  9904. int main(void)
  9905. {
  9906.    double x;
  9907.  
  9908.    printf("Enter x:\n");
  9909.    scanf("%lf", &x);
  9910.  
  9911.    /* Output error if not in range */
  9912.    if (MAX < x)
  9913.       printf("Error: %lf too large for asin.\n", x);
  9914.    else if (MIN > x)
  9915.            printf("Error: %lf too small for asin.\n", x);
  9916.         else
  9917.            printf("The arcsine of %lf is %lf.\n", x, _fasin(x));
  9918.    return 0;
  9919.  
  9920.    /****************************************************************************
  9921.       Assuming you enter: 1.0
  9922.  
  9923.       The ouput should be:
  9924.  
  9925.       The arcsine of 1.000000 is 1.570796.
  9926.    ****************************************************************************/
  9927. }
  9928.  
  9929.  
  9930. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  9931.  
  9932. Example of _fasin 
  9933.  
  9934.      asin - Calculate Arcsine 
  9935.      _fcossin - Calculate Cosine and Sine 
  9936.      _fsin - Calculate Sine 
  9937.      _fsincos - Calculate Sine and Cosine 
  9938.      sin - Calculate Sine 
  9939.      sinh - Calculate Hyperbolic Sine 
  9940.      <builtin.h> 
  9941.  
  9942.  
  9943. ΓòÉΓòÉΓòÉ 4.82. fclose - Close Stream ΓòÉΓòÉΓòÉ
  9944.  
  9945.  
  9946. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  9947.  
  9948. #include <stdio.h>
  9949. int fclose(FILE *stream);
  9950.  
  9951.  
  9952. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  9953.  
  9954. Language Level: ANSI, SAA, POSIX, XPG4 
  9955.  
  9956. fclose closes a stream pointed to by stream.  This function flushes all buffers 
  9957. associated with the stream before closing it.  When it closes the stream, the 
  9958. function releases any buffers that the system reserved. When a binary stream is 
  9959. closed, the last record in the file is padded with null characters (\0) to the 
  9960. end of the record. 
  9961.  
  9962. Return Value 
  9963. fclose returns 0 if it successfully closes the stream, or EOF if any errors 
  9964. were detected. 
  9965.  
  9966. Note:  Once you close a stream with fclose, you must open it again before you 
  9967. can use it. 
  9968.  
  9969.  
  9970. ΓòÉΓòÉΓòÉ <hidden> Example of fclose ΓòÉΓòÉΓòÉ
  9971.  
  9972. /************************************************************************
  9973.  
  9974. This example opens a file fclose.dat for reading as a stream; then it closes 
  9975. this file. 
  9976.  
  9977. ************************************************************************/
  9978.  
  9979. #include <stdio.h>
  9980.  
  9981. int main(void)
  9982. {
  9983.    FILE *stream;
  9984.  
  9985.    stream = fopen("fclose.dat", "r");
  9986.    if (0 != fclose(stream))                               /* Close the stream.*/
  9987.       perror("fclose error");
  9988.    else
  9989.       printf("File closed successfully.\n");
  9990.    return 0;
  9991.  
  9992.    /****************************************************************************
  9993.       The output should be:
  9994.  
  9995.       File closed successfully.
  9996.    ****************************************************************************/
  9997. }
  9998.  
  9999.  
  10000. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10001.  
  10002. Example of fclose 
  10003.  
  10004.      close - Close File Associated with Handle 
  10005.      _fcloseall - Close All Open Streams 
  10006.      fflush - Write Buffer to File 
  10007.      fopen - Open Files 
  10008.      freopen - Redirect Open Files 
  10009.      <stdio.h> 
  10010.  
  10011.  
  10012. ΓòÉΓòÉΓòÉ 4.83. _fcloseall - Close All Open Streams ΓòÉΓòÉΓòÉ
  10013.  
  10014.  
  10015. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10016.  
  10017. #include <stdio.h>
  10018. int _fcloseall(void);
  10019.  
  10020.  
  10021. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10022.  
  10023. Language Level:  Extension 
  10024.  
  10025. _fcloseall closes all open streams, except stdin, stdout, and stderr. It also 
  10026. closes and deletes any temporary files created by tmpfile. 
  10027.  
  10028. _fcloseall flushes all buffers associated with the streams before closing them. 
  10029. When it closes streams, it releases the buffers that the system reserved, but 
  10030. does not release user-allocated buffers. 
  10031.  
  10032. Return Value 
  10033. _fcloseall returns the total number of streams closed, or EOF if an error 
  10034. occurs. 
  10035.  
  10036.  
  10037. ΓòÉΓòÉΓòÉ <hidden> Example of _fcloseall ΓòÉΓòÉΓòÉ
  10038.  
  10039. /************************************************************************
  10040.  
  10041. This example opens a file john for reading as a data stream, and then closes 
  10042. the file. It closes all other streams except stdin, stdout, and stderr. 
  10043.  
  10044. ************************************************************************/
  10045.  
  10046. #include <stdio.h>
  10047.  
  10048. #define OUTFILE "temp.out"
  10049.  
  10050. int main(void)
  10051. {
  10052.    FILE *stream;
  10053.    int numclosed;
  10054.  
  10055.    stream = fopen(OUTFILE, "w");
  10056.    numclosed = _fcloseall();
  10057.    printf("Number of files closed = %d\n", numclosed);
  10058.    remove(OUTFILE);
  10059.    return 0;
  10060.  
  10061.    /****************************************************************************
  10062.       The output should be:
  10063.  
  10064.       Number of files closed = 1
  10065.    ****************************************************************************/
  10066. }
  10067.  
  10068.  
  10069. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10070.  
  10071. Example of _fcloseall 
  10072.  
  10073.      close - Close File Associated with Handle 
  10074.      fclose - Close Stream 
  10075.      fflush - Write Buffer to File 
  10076.      fopen - Open Files 
  10077.      freopen - Redirect Open Files 
  10078.      tmpfile - Create Temporary File 
  10079.      <stdio.h> 
  10080.  
  10081.  
  10082. ΓòÉΓòÉΓòÉ 4.84. _fcos - Calculate Cosine ΓòÉΓòÉΓòÉ
  10083.  
  10084.  
  10085. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10086.  
  10087. #include <builtin.h>
  10088. double _fcos( double x);
  10089.  
  10090.  
  10091. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10092.  
  10093. Language Level:  Extension 
  10094.  
  10095. _fcos calculates the cosine of x, where x is expressed in radians. The value of 
  10096. x must be less than 2**63. This function causes the compiler to emit the 
  10097. appropriate 80387 instruction and return only the cosine. 
  10098.  
  10099. Because it is a built-in function and has no backing code in the library: 
  10100.  
  10101.      You cannot take the address of _fcos. 
  10102.      You cannot parenthesize a _fcos function call, because parentheses 
  10103.       specify a call to the backing code for the function in the library. 
  10104.  
  10105.  Return Value 
  10106.  _fcos returns the cosine expressed in radians. 
  10107.  
  10108.  
  10109. ΓòÉΓòÉΓòÉ <hidden> Example of _fcos ΓòÉΓòÉΓòÉ
  10110.  
  10111. /************************************************************************
  10112.  
  10113. This example calculates y to be the cosine of x. 
  10114.  
  10115. ************************************************************************/
  10116.  
  10117. #include <builtin.h>
  10118. #include <stdio.h>
  10119.  
  10120. int main(void)
  10121. {
  10122.    double x;
  10123.  
  10124.    x = 7.2;
  10125.    printf("The cosine of %lf is %lf.\n", x, _fcos(x));
  10126.    return 0;
  10127.  
  10128.    /****************************************************************************
  10129.       The output should be similar to :
  10130.  
  10131.       The cosine of 7.200000 is 0.608351.
  10132.    ****************************************************************************/
  10133. }
  10134.  
  10135.  
  10136. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10137.  
  10138. Example of _fcos 
  10139.  
  10140.      cos - Calculate Cosine 
  10141.      cosh - Calculate Hyperbolic Cosine 
  10142.      _facos - Calculate Arccosine 
  10143.      _fcossin - Calculate Cosine and Sine 
  10144.      _fsincos - Calculate Sine and Cosine 
  10145.      <builtin.h> 
  10146.  
  10147.  
  10148. ΓòÉΓòÉΓòÉ 4.85. _fcossin - Calculate Cosine and Sine ΓòÉΓòÉΓòÉ
  10149.  
  10150.  
  10151. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10152.  
  10153. #include <builtin.h>
  10154. double _fcossin(double x, double *y);
  10155.  
  10156.  
  10157. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10158.  
  10159. Language Level:  Extension 
  10160.  
  10161. _fcossin calculates the cosine of x, and stores the sine of x in *y. This is 
  10162. faster than separately calculating the sine and cosine. Use _fcossin instead of 
  10163. _fsincos when you will be using the cosine first, and then the sine. This 
  10164. function causes the compiler to emit the FSINCOS 80387 instruction. 
  10165.  
  10166. Because it is a built-in function and has no backing code in the library: 
  10167.  
  10168.      You cannot take the address of _fcossin. 
  10169.      You cannot parenthesize a _fcossin function call, because parentheses 
  10170.       specify a call to the backing code for the function in the library. 
  10171.  
  10172.  Return Value 
  10173.  _fcossin returns the cosine of x. 
  10174.  
  10175.  
  10176. ΓòÉΓòÉΓòÉ <hidden> Example of _fcossin ΓòÉΓòÉΓòÉ
  10177.  
  10178. /************************************************************************
  10179.  
  10180. This example calculates the cosine of x and stores it in z, and stores the sine 
  10181. of x in *y. 
  10182.  
  10183. ************************************************************************/
  10184.  
  10185. #include <builtin.h>
  10186. #include <stdio.h>
  10187.  
  10188. int main(void)
  10189. {
  10190.    double x, y, z;
  10191.  
  10192.    printf("Enter x:\n");
  10193.    scanf("%lf", &x);
  10194.  
  10195.    z = _fcossin(x, &y);
  10196.    printf("The cosine of %lf is %lf.\n", x, z);
  10197.    printf("The sine of %lf is %lf.\n", x, y);
  10198.    return 0;
  10199.  
  10200.    /****************************************************************************
  10201.       Assuming you enter : 1.0
  10202.  
  10203.       The output should be :
  10204.  
  10205.       The cosine of 1.000000 is 0.540302.
  10206.       The sine of 1.000000 is 0.841471.
  10207.    ****************************************************************************/
  10208. }
  10209.  
  10210.  
  10211. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10212.  
  10213. Example of _fcossin 
  10214.  
  10215.      acos - Calculate Arccosine 
  10216.      asin - Calculate Arcsine 
  10217.      cos - Calculate Cosine 
  10218.      cosh - Calculate Hyperbolic Cosine 
  10219.      _facos - Calculate Arccosine 
  10220.      _fasin - Calculate Arcsine 
  10221.      _fcos - Calculate Cosine 
  10222.      sin - Calculate Sine 
  10223.      sinh - Calculate Hyperbolic Sine 
  10224.      _fsin - Calculate Sine 
  10225.      _fsincos - Calculate Sine and Cosine 
  10226.      <builtin.h> 
  10227.  
  10228.  
  10229. ΓòÉΓòÉΓòÉ 4.86. _fcvt - Convert Floating-Point to String ΓòÉΓòÉΓòÉ
  10230.  
  10231.  
  10232. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10233.  
  10234. #include <stdlib.h>
  10235. char *_fcvt(double value, int ndec, int *decptr, int *signptr);
  10236.  
  10237.  
  10238. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10239.  
  10240. Language Level:  Extension 
  10241.  
  10242. _fcvt converts the floating-point number value to a character string. _fcvt 
  10243. stores the digits of value as a string and adds a null character (\0). The ndec 
  10244. variable specifies the number of digits to be stored after the decimal point. 
  10245.  
  10246. If the number of digits after the decimal point in value exceeds ndec, _fcvt 
  10247. rounds the correct digit according to the FORTRAN F format.  If there are fewer 
  10248. than ndec digits of precision, _fcvt pads the string with zeros. 
  10249.  
  10250. A FORTRAN F number has the following format: 
  10251.  
  10252. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  10253. Γöé                                        Γöé
  10254. Γöé       ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ   ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ                    Γöé
  10255. Γöé           Γöé         Γöé                    Γöé
  10256. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇdigitΓöÇΓö┤ΓöÇΓöÇ.ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö┤ΓöÇΓöÇ><                  Γöé
  10257. Γöé   Γö£ΓöÇ+ΓöÇΓöñ          ΓööΓöÇdigitΓöÇΓöÿ                     Γöé
  10258. Γöé   ΓööΓöÇΓö┤ΓöÇΓöÿ                                   Γöé
  10259. Γöé                                        Γöé
  10260. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  10261.  
  10262. _fcvt stores only digits in the string. You can obtain the position of the 
  10263. decimal point and the sign of value after the call from decptr and signptr. 
  10264. decptr points to an integer value giving the position of the decimal point with 
  10265. respect to the beginning of the string.  A 0 or negative integer value shows 
  10266. that the decimal point lies to the left of the first digit. 
  10267.  
  10268. signptr points to an integer showing the sign of value. _fcvt sets the integer 
  10269. to 0 if value is positive and to a nonzero number if value is negative. 
  10270.  
  10271. _fcvt also converts NaN and infinity values to the strings NAN and INFINITY, 
  10272. respectively. For more information on NaN and infinity values, see Infinity and 
  10273. NaN Support. 
  10274.  
  10275. Warning: For each thread, the _ecvt, _fcvt, and _gcvt functions use a single, 
  10276. dynamically allocated buffer for the conversion. Any subsequent call that the 
  10277. same thread makes to these functions destroys the result of the previous call. 
  10278.  
  10279. Return Value 
  10280. _fcvt returns a pointer to the string of digits. Because of the limited 
  10281. precision of the double type, no more than 16 decimal digits are significant in 
  10282. any conversion. If it cannot allocate memory to perform the conversion, _fcvt 
  10283. returns NULL and sets errno to ENOMEM. 
  10284.  
  10285.  
  10286. ΓòÉΓòÉΓòÉ <hidden> Example of _fcvt ΓòÉΓòÉΓòÉ
  10287.  
  10288. /************************************************************************
  10289.  
  10290. This example reads in two floating-point numbers, computes their product, and 
  10291. prints out only the billions digit of its character representation.  At most, 
  10292. 16 decimal digits of significance can be expected. The output given assumes the 
  10293. user enters the values 2000000 and 3000. 
  10294.  
  10295. ************************************************************************/
  10296.  
  10297. #include <stdio.h>
  10298. #include <stdlib.h>
  10299. #include <math.h>
  10300.  
  10301. int main(void)
  10302. {
  10303.    float x = 2000000;
  10304.    float y = 3000;
  10305.    double z;
  10306.    int w,b,decimal,sign;
  10307.    char *buffer;
  10308.  
  10309.    z = x *y;
  10310.    printf("The product of %e and %e is %g.\n", x, y, z);
  10311.    w = log10(fabs(z))+1.;
  10312.    buffer = _fcvt(z, w, &decimal, &sign);
  10313.    b = decimal-10;
  10314.    if (b < 0)
  10315.       printf("Their product does not exceed one billion.\n");
  10316.    if (b > 15)
  10317.       printf("The billions digit of their product is insignificant.\n");
  10318.    if ((b > -1) && (b < 16))
  10319.       printf("The billions digit of their product is %c.\n", buffer[b]);
  10320.    return 0;
  10321.  
  10322.    /****************************************************************************
  10323.       The output should be:
  10324.  
  10325.       The product of 2.000000e+06 and 3.000000e+03 is 6e+09.
  10326.       The billions digit of their product is 6.
  10327.    ****************************************************************************/
  10328. }
  10329.  
  10330.  
  10331. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10332.  
  10333. Example of _fcvt 
  10334.  
  10335.      _ecvt - Convert Floating-Point to Character 
  10336.      _gcvt - Convert Floating-Point to String 
  10337.      Infinity and NaN Support 
  10338.      <stdlib.h> 
  10339.  
  10340.  
  10341. ΓòÉΓòÉΓòÉ 4.87. fdopen - Associates Input Or Output With File ΓòÉΓòÉΓòÉ
  10342.  
  10343.  
  10344. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10345.  
  10346. #include <stdio.h>
  10347. FILE *fdopen(int handle, char *type);
  10348.  
  10349.  
  10350. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10351.  
  10352. Language Level:  XPG4, Extension 
  10353.  
  10354. fdopen associates an input or output stream with the file identified by handle. 
  10355. The type variable is a character string specifying the type of access requested 
  10356. for the stream. 
  10357.  
  10358.  Mode Description 
  10359.  r 
  10360.       Create a stream to read a text file. The file pointer is set to the 
  10361.       beginning of the file. 
  10362.  w 
  10363.       Create a stream to write to a text file. The file pointer is set to the 
  10364.       beginning of the file. 
  10365.  a 
  10366.       Create a stream to write, in append mode, at the end of the text file. 
  10367.       The file pointer is set to the end of the file. 
  10368.  r+ 
  10369.       Create a stream for reading and writing a text file. The file pointer is 
  10370.       set to the beginning of the file. 
  10371.  w+ 
  10372.       Create a stream for reading and writing a text file. The file pointer is 
  10373.       set to the beginning of the file. 
  10374.  a+ 
  10375.       Create a stream for reading or writing, in append mode, at the end of the 
  10376.       text file. The file pointer is set to the end of the file. 
  10377.  rb 
  10378.       Create a stream to read a binary file. The file pointer is set to the 
  10379.       beginning of the file. 
  10380.  wb 
  10381.       Create a stream to write to a binary file. The file pointer is set to the 
  10382.       beginning of the file. 
  10383.  ab 
  10384.       Create a stream to write to a binary file in append mode. The file 
  10385.       pointer is set to the end of the file. 
  10386.  r+b or rb+ 
  10387.       Create a stream for reading and writing a binary file. The file pointer 
  10388.       is set to the beginning of the file. 
  10389.  w+b or wb+ 
  10390.       Create a stream for reading and writing a binary file. The file pointer 
  10391.       is set to the beginning of the file. 
  10392.  a+b or ab+ 
  10393.       Create a stream for reading and writing to a binary file in append mode. 
  10394.       The file pointer is set to the end of the file. 
  10395.  
  10396.  Warning: Use the w, w+, wb, wb+, and w+b modes with care; they can destroy 
  10397.  existing files. 
  10398.  
  10399.  The specified type must be compatible with the access mode you used to open 
  10400.  the file. If the file was opened with the O_APPEND FLAG, the stream mode must 
  10401.  be r, a, a+, rb, ab, a+b, or ab+. 
  10402.  
  10403.  When you open a file with a, a+, ab, a+b, or ab+ as the value of type, all 
  10404.  write operations take place at the end of the file. Although you can 
  10405.  reposition the file pointer using fseek or rewind, the file pointer always 
  10406.  moves back to the end of the file before the system carries out any write 
  10407.  operation. This action prevents you from writing over existing data. 
  10408.  
  10409.  When you specify any of the types containing +, you can read from and write to 
  10410.  the file, and the file is open for update. However, when switching from 
  10411.  reading to writing or from writing to reading, you must include an intervening 
  10412.  fseek, fsetpos, or rewind operation. You can specify the current file position 
  10413.  with fseek. 
  10414.  
  10415.  In accessing text files, carriage-return line-feed (CR-LF) combinations are 
  10416.  translated into a single line feed (LF) on input; LF characters are translated 
  10417.  to CR-LF combinations on output. Accesses to binary files suppress all of 
  10418.  these translations. (See "Stream Processing" in the Programming Guide for the 
  10419.  differences between text and binary streams.) 
  10420.  
  10421.  If fdopen returns NULL, use close to close the file. If fdopen is successful, 
  10422.  you must use fclose to close the stream and file. 
  10423.  
  10424.  Note:  In earlier releases of C Set ++, fdopen began with an underscore 
  10425.  (_fdopen). Because it is defined by the X/Open standard, the underscore has 
  10426.  been removed. For compatibility, VisualAge C++ will map _fdopen to fdopen for 
  10427.  you. 
  10428.  
  10429.  Return Value 
  10430.  fdopen returns a pointer to a file structure that can be used to access the 
  10431.  open file. A NULL pointer return value indicates an error. 
  10432.  
  10433.  
  10434. ΓòÉΓòÉΓòÉ <hidden> Example of fdopen ΓòÉΓòÉΓòÉ
  10435.  
  10436. /************************************************************************
  10437.  
  10438. This example opens the file sample.dat and associates a stream with the file 
  10439. using fdopen. It then reads from the stream into the buffer. 
  10440.  
  10441. ************************************************************************/
  10442.  
  10443. #include <io.h>
  10444. #include <stdio.h>
  10445. #include <stdlib.h>
  10446. #include <fcntl.h>
  10447. #include <string.h>
  10448.  
  10449. int main(void)
  10450. {
  10451.    long length;
  10452.    int fh;
  10453.    char buffer[20];
  10454.    FILE *fp;
  10455.  
  10456.    memset(buffer, '\0', 20);                              /* Initialize buffer*/
  10457.    printf("\nCreating sample.dat.\n");
  10458.    system("echo Sample Program > sample.dat");
  10459.    if (-1 == (fh = open("sample.dat", O_RDWR|O_APPEND))) {
  10460.       perror("Unable to open sample.dat");
  10461.       return EXIT_FAILURE;
  10462.    }
  10463.    if (NULL == (fp = fdopen(fh, "r"))) {
  10464.       perror("fdopen failed");
  10465.       close(fh);
  10466.       return EXIT_FAILURE;
  10467.    }
  10468.    if (7 != fread(buffer, 1, 7, fp)) {
  10469.       perror("fread failed");
  10470.       fclose(fp);
  10471.       return EXIT_FAILURE;
  10472.    }
  10473.    printf("Successfully read from the stream the following:\n%s.\n", buffer);
  10474.    fclose(fp);
  10475.    return 0;
  10476.  
  10477.    /****************************************************************************
  10478.       The output should be:
  10479.  
  10480.       Creating sample.dat.
  10481.       Successfully read from the stream the following:
  10482.       Sample .
  10483.    ****************************************************************************/
  10484. }
  10485.  
  10486.  
  10487. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10488.  
  10489. Example of fdopen 
  10490.  
  10491.      close - Close File Associated with Handle 
  10492.      creat - Create New File 
  10493.      fclose - Close Stream 
  10494.      fopen - Open Files 
  10495.      fseek - Reposition File Position 
  10496.      fsetpos - Set File Position 
  10497.      open - Open File 
  10498.      rewind - Adjust Current File Position 
  10499.      _sopen - Open Shared File 
  10500.      <stdio.h> 
  10501.  
  10502.  
  10503. ΓòÉΓòÉΓòÉ 4.88. feof - Test End-of-File Indicator ΓòÉΓòÉΓòÉ
  10504.  
  10505.  
  10506. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10507.  
  10508. #include <stdio.h>
  10509. int feof(FILE *stream);
  10510.  
  10511.  
  10512. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10513.  
  10514. Language Level: ANSI, SAA, POSIX, XPG4 
  10515.  
  10516. feof indicates whether the end-of-file flag is set for the given stream.  The 
  10517. end-of-file flag is set by several functions to indicate the end of the file. 
  10518. The end-of-file flag is cleared by calling rewind, fsetpos, fseek, or clearerr 
  10519. for this stream. 
  10520.  
  10521. Return Value 
  10522. feof returns a nonzero value if and only if the EOF flag is set;  otherwise, it 
  10523. returns 0. 
  10524.  
  10525.  
  10526. ΓòÉΓòÉΓòÉ <hidden> Example of feof ΓòÉΓòÉΓòÉ
  10527.  
  10528. /************************************************************************
  10529.  
  10530. This example scans the input stream until it reads an end-of-file character. 
  10531.  
  10532. ************************************************************************/
  10533.  
  10534. #include <stdio.h>
  10535.  
  10536. int main(void)
  10537. {
  10538.    char inp_char;
  10539.    FILE *stream;
  10540.  
  10541.    stream = fopen("feof.dat", "r");
  10542.  
  10543.    /* scan an input stream until an end-of-file character is read             */
  10544.  
  10545.    while (0 == feof(stream)) {
  10546.       fscanf(stream, "%c", &inp_char);
  10547.       printf("<x%x> ", inp_char);
  10548.    }
  10549.    fclose(stream);
  10550.    return 0;
  10551.  
  10552.    /****************************************************************************
  10553.       If feof.dat contains : abc defgh
  10554.  
  10555.       The output should be:
  10556.  
  10557.       <x61> <x62> <x63> <x20> <x64> <x65> <x66> <x67> <x68>
  10558.    ****************************************************************************/
  10559. }
  10560.  
  10561.  
  10562. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10563.  
  10564. Example of feof 
  10565.  
  10566.      clearerr - Reset Error Indicators. 
  10567.      ferror - Test for Read/Write Errors 
  10568.      fseek - Reposition File Position 
  10569.      fsetpos - Set File Position 
  10570.      perror - Print Error Message 
  10571.      rewind - Adjust Current File Position 
  10572.      <stdio.h> 
  10573.  
  10574.  
  10575. ΓòÉΓòÉΓòÉ 4.89. ferror - Test for Read/Write Errors ΓòÉΓòÉΓòÉ
  10576.  
  10577.  
  10578. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10579.  
  10580. #include <stdio.h>
  10581. int ferror(FILE *stream);
  10582.  
  10583.  
  10584. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10585.  
  10586. Language Level: ANSI, SAA, POSIX, XPG4 
  10587.  
  10588. ferror tests for an error in reading from or writing to the given stream.  If 
  10589. an error occurs, the error indicator for the stream remains set until you close 
  10590. stream, call rewind, or call clearerr. 
  10591.  
  10592. Return Value 
  10593. The ferror function returns a nonzero value to indicate an error on the given 
  10594. stream.  A return value of 0 means no error has occurred. 
  10595.  
  10596.  
  10597. ΓòÉΓòÉΓòÉ <hidden> Example of ferror ΓòÉΓòÉΓòÉ
  10598.  
  10599. /************************************************************************
  10600.  
  10601. This example puts data out to a stream and then checks that a write error has 
  10602. not occurred. 
  10603.  
  10604. ************************************************************************/
  10605.  
  10606. #include <stdio.h>
  10607. #include <stdlib.h>
  10608.  
  10609. int main(void)
  10610. {
  10611.    FILE *stream;
  10612.    char *string = "Important information";
  10613.  
  10614.    stream = fopen("ferror.dat", "w");
  10615.    fprintf(stream, "%s\n", string);
  10616.    if (ferror(stream)) {
  10617.       printf("write error\n");
  10618.       clearerr(stream);
  10619.       return EXIT_FAILURE;
  10620.    }
  10621.    else
  10622.       printf("Data written to a file successfully.\n");
  10623.    if (fclose(stream))
  10624.       perror("fclose error");
  10625.    return 0;
  10626.  
  10627.    /****************************************************************************
  10628.       The output should be:
  10629.  
  10630.       Data written to a file successfully.
  10631.    ****************************************************************************/
  10632. }
  10633.  
  10634.  
  10635. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10636.  
  10637. Example of ferror 
  10638.  
  10639.      clearerr - Reset Error Indicators. 
  10640.      feof - Test End-of-File Indicator 
  10641.      fopen - Open Files 
  10642.      perror - Print Error Message 
  10643.      strerror - Set Pointer to Runtime Error Message 
  10644.      _strerror - Set Pointer to System Error String 
  10645.      <stdio.h> 
  10646.  
  10647.  
  10648. ΓòÉΓòÉΓòÉ 4.90. fflush - Write Buffer to File ΓòÉΓòÉΓòÉ
  10649.  
  10650.  
  10651. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10652.  
  10653. #include <stdio.h>
  10654. int fflush(FILE *stream);
  10655.  
  10656.  
  10657. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10658.  
  10659. Language Level: ANSI, SAA, POSIX, XPG4 
  10660.  
  10661. fflush causes the system to empty the buffer associated with the specified 
  10662. output stream, if possible. If the stream is open for input, fflush undoes the 
  10663. effect of any ungetc function. The stream remains open after the call. 
  10664.  
  10665. If stream is NULL, the system flushes all open streams. 
  10666.  
  10667. Note:  The system automatically flushes buffers when you close the stream, or 
  10668.        when a program ends normally without closing the stream. 
  10669.  
  10670.  Return Value 
  10671.  fflush returns the value 0 if it successfully flushes the buffer. It returns 
  10672.  EOF if an error occurs. 
  10673.  
  10674.  
  10675. ΓòÉΓòÉΓòÉ <hidden> Example of fflush ΓòÉΓòÉΓòÉ
  10676.  
  10677. /************************************************************************
  10678.  
  10679. This example flushes a stream buffer. 
  10680.  
  10681. ************************************************************************/
  10682.  
  10683. #include <stdio.h>
  10684.  
  10685. int main(void)
  10686. {
  10687.    FILE *stream;
  10688.  
  10689.    stream = fopen("myfile.dat", "w");
  10690.    fprintf(stream, "Hello world");
  10691.    fflush(stream);
  10692.    fclose(stream);
  10693.    return 0;
  10694. }
  10695.  
  10696.  
  10697. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10698.  
  10699. Example of fflush 
  10700.  
  10701.      fclose - Close Stream 
  10702.      _flushall - Write Buffers to Files 
  10703.      setbuf - Control Buffering 
  10704.      ungetc - Push Character onto Input Stream 
  10705.      <stdio.h> 
  10706.  
  10707.  
  10708. ΓòÉΓòÉΓòÉ 4.91. fgetc - Read a Character ΓòÉΓòÉΓòÉ
  10709.  
  10710.  
  10711. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10712.  
  10713. #include <stdio.h>
  10714. int fgetc(FILE *stream);
  10715.  
  10716.  
  10717. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10718.  
  10719. Language Level: ANSI, SAA, POSIX, XPG4 
  10720.  
  10721. fgetc reads a single unsigned character from the input stream at the current 
  10722. position and increases the associated file pointer, if any, so that it points 
  10723. to the next character. 
  10724.  
  10725. Note:  fgetc is identical to getc but is always implemented as a function call; 
  10726. it is never replaced by a macro. 
  10727.  
  10728. Return Value 
  10729. fgetc returns the character read as an integer. An EOF return value indicates 
  10730. an error or an end-of-file condition.  Use feof or ferror to determine whether 
  10731. the EOF value indicates an error or the end of the file. 
  10732.  
  10733.  
  10734. ΓòÉΓòÉΓòÉ <hidden> Example of fgetc ΓòÉΓòÉΓòÉ
  10735.  
  10736. /************************************************************************
  10737.  
  10738. This example gathers a line of input from a stream. 
  10739.  
  10740. ************************************************************************/
  10741.  
  10742. #include <stdio.h>
  10743.  
  10744. #define  MAX_LEN       80
  10745.  
  10746. int main(void)
  10747. {
  10748.    FILE *stream;
  10749.    char buffer[MAX_LEN+1];
  10750.    int i,ch;
  10751.  
  10752.    stream = fopen("myfile.dat", "r");
  10753.    for (i = 0; (i < (sizeof(buffer)-1) && ((ch = fgetc(stream)) != EOF) &&
  10754.                (ch != '\n')); i++)
  10755.       buffer[i] = ch;
  10756.    buffer[i] = '\0';
  10757.    if (fclose(stream))
  10758.       perror("fclose error");
  10759.    printf("The input line was : %s\n", buffer);
  10760.    return 0;
  10761.  
  10762.    /****************************************************************************
  10763.       If myfile.dat contains: one two three
  10764.  
  10765.       The output should be:
  10766.  
  10767.       The input line was : one two three
  10768.    ****************************************************************************/
  10769. }
  10770.  
  10771.  
  10772. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10773.  
  10774. Example of fgetc 
  10775.  
  10776.      _fgetchar - Read Single Character from stdin 
  10777.      feof - Test End-of-File Indicator 
  10778.      ferror - Test for Read/Write Errors 
  10779.      fputc - Write Character 
  10780.      getc - getchar - Read a Character 
  10781.      _getch - _getche - Read Character from Keyboard 
  10782.      <stdio.h> 
  10783.  
  10784.  
  10785. ΓòÉΓòÉΓòÉ 4.92. _fgetchar - Read Single Character from stdin ΓòÉΓòÉΓòÉ
  10786.  
  10787.  
  10788. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10789.  
  10790. #include <stdio.h>
  10791. int _fgetchar(void);
  10792.  
  10793.  
  10794. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10795.  
  10796. Language Level:  Extension 
  10797.  
  10798. _fgetchar reads a single character from the stdin stream. It is equivalent to 
  10799. the following fgetc call: 
  10800.  
  10801.    fgetc(c, stdin);
  10802.  
  10803. For portability, use the ANSI/ISO fgetc function instead of _fgetchar. 
  10804.  
  10805. Return Value 
  10806. _fgetchar returns the character read.  A return value of EOF indicates an error 
  10807. or end-of-file position. Use feof or ferror to tell whether the return value 
  10808. indicates an error or an end-of-file position. 
  10809.  
  10810.  
  10811. ΓòÉΓòÉΓòÉ <hidden> Example of _fgetchar ΓòÉΓòÉΓòÉ
  10812.  
  10813. /************************************************************************
  10814.  
  10815. This example gathers a line of input from stdin using _fgetchar: 
  10816.  
  10817. ************************************************************************/
  10818.  
  10819. #include <stdio.h>
  10820.  
  10821. int main(void)
  10822. {
  10823.    char buffer[81];
  10824.    int i,ch;
  10825.  
  10826.    printf("Please input a line of characters...\n");
  10827.    for (i = 0; (i < 80) && ((ch = _fgetchar()) != EOF) && (ch != '\n'); i++)
  10828.       buffer[i] = ch;
  10829.    buffer[i] = '\0';
  10830.    printf("The input line was : %s\n", buffer);
  10831.    return 0;
  10832.  
  10833.    /****************************************************************************
  10834.       The output should be:
  10835.  
  10836.       Please input a line of characters...
  10837.       This is a simple program.
  10838.       The input line was : This is a simple program.
  10839.    ****************************************************************************/
  10840. }
  10841.  
  10842.  
  10843. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10844.  
  10845. Example of _fgetchar 
  10846.  
  10847.      feof - Test End-of-File Indicator 
  10848.      ferror - Test for Read/Write Errors 
  10849.      fgetc - Read a Character 
  10850.      _fputchar - Write Character 
  10851.      getc - getchar - Read a Character 
  10852.      _getch - _getche - Read Character from Keyboard 
  10853.      <stdio.h> 
  10854.  
  10855.  
  10856. ΓòÉΓòÉΓòÉ 4.93. fgetpos - Get File Position ΓòÉΓòÉΓòÉ
  10857.  
  10858.  
  10859. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10860.  
  10861. #include <stdio.h>
  10862. int fgetpos(FILE *stream, fpos_t *pos);
  10863.  
  10864.  
  10865. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10866.  
  10867. Language Level: ANSI, SAA, XPG4 
  10868.  
  10869. fgetpos stores the current position of the file pointer associated with stream 
  10870. into the object pointed to by pos.  The value pointed to by pos can be used 
  10871. later in a call to fsetpos to reposition the stream. 
  10872.  
  10873. Note:  For buffered text streams, fgetpos returns an incorrect file position if 
  10874. the file contains new-line characters instead of carriage-return line-feed 
  10875. combinations.  Your file would only contain new-line characters if you 
  10876. previously used it as a binary stream.  To avoid this problem, either continue 
  10877. to process the file as a binary stream, or use unbuffered I/O operations. 
  10878.  
  10879. Return Value 
  10880. fgetpos returns 0 if successful. On error, fgetpos returns nonzero and sets 
  10881. errno to a nonzero value. 
  10882.  
  10883.  
  10884. ΓòÉΓòÉΓòÉ <hidden> Example of fgetpos ΓòÉΓòÉΓòÉ
  10885.  
  10886. /************************************************************************
  10887.  
  10888. This example opens the file myfile.dat for reading and stores the current file 
  10889. pointer position into the variable pos. 
  10890.  
  10891. ************************************************************************/
  10892.  
  10893. #include <stdio.h>
  10894.  
  10895. FILE *stream;
  10896.  
  10897. int main(void)
  10898. {
  10899.    int retcode;
  10900.    fpos_t pos;
  10901.  
  10902.    stream = fopen("myfile.dat", "rb");
  10903.  
  10904.     /* The value returned by fgetpos can be used by fsetpos                   */
  10905.     /* to set the file pointer if 'retcode' is 0                              */
  10906.  
  10907.    if ( 0 == (retcode = fgetpos(stream, &pos)) )
  10908.       printf("Current position of file pointer found.\n");
  10909.    fclose(stream);
  10910.    return 0;
  10911.  
  10912.    /****************************************************************************
  10913.       If myfile.dat exists, the output should be:
  10914.  
  10915.       Current position of file pointer found.
  10916.    ****************************************************************************/
  10917. }
  10918.  
  10919.  
  10920. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10921.  
  10922. Example of fgetpos 
  10923.  
  10924.      fseek - Reposition File Position 
  10925.      fsetpos - Set File Position 
  10926.      ftell - Get Current Position 
  10927.      <stdio.h> 
  10928.  
  10929.  
  10930. ΓòÉΓòÉΓòÉ 4.94. fgets - Read a String ΓòÉΓòÉΓòÉ
  10931.  
  10932.  
  10933. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  10934.  
  10935. #include <stdio.h>
  10936. char *fgets (char *string, int n, FILE *stream);
  10937.  
  10938.  
  10939. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  10940.  
  10941. Language Level: ANSI, SAA, POSIX, XPG4 
  10942.  
  10943. fgets reads characters from the current stream position up to and including the 
  10944. first new-line character (\n), up to the end of the stream, or until the number 
  10945. of characters read is equal to n-1, whichever comes first.  fgets stores the 
  10946. result in string and adds a null character (\0) to the end of the string.  The 
  10947. string includes the new-line character, if read.  If n is equal to 1, the 
  10948. string is empty. 
  10949.  
  10950. Return Value 
  10951. fgets returns a pointer to the string buffer if successful.  A NULL return 
  10952. value indicates an error or an end-of-file condition.  Use feof or ferror to 
  10953. determine whether the NULL value indicates an error or the end of the file. In 
  10954. either case, the value of the string is unchanged. 
  10955.  
  10956.  
  10957. ΓòÉΓòÉΓòÉ <hidden> Example of fgets ΓòÉΓòÉΓòÉ
  10958.  
  10959. /************************************************************************
  10960.  
  10961. This example gets a line of input from a data stream.  The example reads no 
  10962. more than MAX_LEN - 1 characters, or up to a new-line character, from the 
  10963. stream. 
  10964.  
  10965. ************************************************************************/
  10966.  
  10967. #include <stdio.h>
  10968.  
  10969. #define  MAX_LEN       100
  10970.  
  10971. int main(void)
  10972. {
  10973.    FILE *stream;
  10974.    char line[MAX_LEN],*result;
  10975.  
  10976.    stream = fopen("myfile.dat", "rb");
  10977.    if ((result = fgets(line, MAX_LEN, stream)) != NULL)
  10978.       printf("The string is %s\n", result);
  10979.    if (fclose(stream))
  10980.       perror("fclose error");
  10981.    return 0;
  10982.  
  10983.    /****************************************************************************
  10984.       If myfile.dat contains: This is my data file.
  10985.  
  10986.       The output should be:
  10987.  
  10988.       The string is This is my data file.
  10989.    ****************************************************************************/
  10990. }
  10991.  
  10992.  
  10993. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  10994.  
  10995. Example of fgets 
  10996.  
  10997.      feof - Test End-of-File Indicator 
  10998.      ferror - Test for Read/Write Errors 
  10999.      fputs - Write String 
  11000.      gets - Read a Line 
  11001.      puts - Write a String 
  11002.      <stdio.h> 
  11003.  
  11004.  
  11005. ΓòÉΓòÉΓòÉ 4.95. fgetwc - Read Wide Character from Stream ΓòÉΓòÉΓòÉ
  11006.  
  11007.  
  11008. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11009.  
  11010. #include <stdio.h>
  11011. #include <wchar.h>
  11012. wint_t fgetwc(FILE *stream);
  11013.  
  11014.  
  11015. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11016.  
  11017. Language Level:  ANSI 93 
  11018.  
  11019. fgetwc reads the next multibyte character from the input stream pointed to by 
  11020. stream, converts it to a wide character, and advances the associated file 
  11021. position indicator for the stream (if defined). 
  11022.  
  11023. The behavior of fgetwc is affected by the LC_CTYPE category of the current 
  11024. locale. If you change the category between subsequent read operations on the 
  11025. same stream, undefined results can occur. 
  11026.  
  11027. Using non-wide-character functions with fgetwc on the same stream results in 
  11028. undefined behavior. 
  11029.  
  11030. After calling fgetwc, flush the buffer or reposition the stream pointer before 
  11031. calling a write function for the stream, unless EOF has been reached. After a 
  11032. write operation on the stream, flush the buffer or reposition the stream 
  11033. pointer before calling fgetwc. 
  11034.  
  11035. Return Value 
  11036. fgetwc returns the next wide character that corresponds to the multibyte 
  11037. character from the input stream pointed to by stream. If the stream is at EOF, 
  11038. the EOF indicator for the stream is set and fgetwc returns WEOF. 
  11039.  
  11040. If a read error occurs, the error indicator for the stream is set and fgetwc 
  11041. returns WEOF. If an encoding error occurs (an error converting the multibyte 
  11042. character into a wide character), fgetwc sets errno to EILSEQ and returns WEOF. 
  11043.  
  11044. Use ferror and feof to distinguish between a read error and an EOF. EOF is only 
  11045. reached when an attempt is made to read past the last byte of data. Reading up 
  11046. to and including the last byte of data does not turn on the EOF indicator. 
  11047.  
  11048.  
  11049. ΓòÉΓòÉΓòÉ <hidden> Example of fgetwc ΓòÉΓòÉΓòÉ
  11050.  
  11051. /************************************************************************
  11052.  
  11053. This example opens a file, reads in each wide character using fgetwc, and 
  11054. prints out the characters. 
  11055.  
  11056. ************************************************************************/
  11057.  
  11058. #include <stdio.h>
  11059. #include <wchar.h>
  11060. #include <errno.h>
  11061.  
  11062. int main(void)
  11063. {
  11064.    FILE   *stream;
  11065.    wint_t wc;
  11066.  
  11067.    if (NULL == (stream = fopen("fgetwc.dat", "r"))) {
  11068.       printf("Unable to open: \"fgetwc.dat\"\n");
  11069.       exit(1);
  11070.    }
  11071.  
  11072.    errno = 0;
  11073.    while (WEOF != (wc = fgetwc(stream)))
  11074.       printf("wc = %lc\n", wc);
  11075.  
  11076.    if (EILSEQ == errno) {
  11077.       printf("An invalid wide character was encountered.\n");
  11078.       exit(1);
  11079.    }
  11080.    fclose(stream);
  11081.    return 0;
  11082.  
  11083.    /****************************************************************************
  11084.       Assuming the file fgetwc.dat contains:
  11085.  
  11086.       Hello world!
  11087.  
  11088.       The output should be similar to:
  11089.  
  11090.       wc = H
  11091.       wc = e
  11092.       wc = l
  11093.       wc = l
  11094.       wc = o
  11095.       :
  11096.    ****************************************************************************/
  11097. }
  11098.  
  11099.  
  11100. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11101.  
  11102. Example of fgetwc 
  11103.  
  11104.      fgetc - Read a Character 
  11105.      _fgetchar - Read Single Character from stdin 
  11106.      fgetws - Read Wide-Character String from Stream 
  11107.      fputwc - Write Wide Character 
  11108.      _getch - _getche - Read Character from Keyboard 
  11109.      <stdio.h> 
  11110.      <wchar.h> 
  11111.  
  11112.  
  11113. ΓòÉΓòÉΓòÉ 4.96. fgetws - Read Wide-Character String from Stream ΓòÉΓòÉΓòÉ
  11114.  
  11115.  
  11116. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11117.  
  11118. #include <stdio.h>
  11119. #include <wchar.h>
  11120. wchar_t *fgetws(wchar_t *wcs, int n, FILE *stream);
  11121.  
  11122.  
  11123. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11124.  
  11125. Language Level:  ANSI 93, XPG4 
  11126.  
  11127. fgetws reads wide characters from the stream into the array pointed to by wcs. 
  11128. At most, n - 1 wide characters are read. fgetws stops reading characters after 
  11129. WEOF, or after it reads a new-line wide character (which is retained). It adds 
  11130. a null wide character immediately after the last wide character read into the 
  11131. array. 
  11132.  
  11133. fgetws advances the file position unless there is an error. If an error occurs, 
  11134. the file position is undefined. 
  11135.  
  11136. The behavior of fgetws is affected by the LC_CTYPE category of the current 
  11137. locale. If you change the category between subsequent read operations on the 
  11138. same stream, undefined results can occur. 
  11139.  
  11140. Using non-wide-character functions with fgetws on the same stream results in 
  11141. undefined behavior. 
  11142.  
  11143. After calling fgetws, flush the buffer or reposition the stream pointer before 
  11144. calling a write function for the stream, unless WEOF has been reached. After a 
  11145. write operation on the stream, flush the buffer or reposition the stream 
  11146. pointer before calling fgetws. 
  11147.  
  11148. Return Value 
  11149. If successful, fgetws returns a pointer to the wide-character string wcs. If 
  11150. WEOF is encountered before any wide characters have been read into wcs, the 
  11151. contents of wcs remain unchanged and fgetws returns a null pointer. If WEOF is 
  11152. reached after data has already been read into the string buffer, fgetws returns 
  11153. a pointer to the string buffer to indicate success. A subsequent call would 
  11154. return NULL because WEOF would be reached without any data being read. 
  11155.  
  11156. If a read error occurs, the contents of wcs are indeterminate and fgetws 
  11157. returns NULL. If an encoding error occurs (in converting a wide character to a 
  11158. multibyte character), fgetws sets errno to EILSEQ and returns NULL. 
  11159.  
  11160. If n equals 1, the wcs buffer has only room for the terminating null character 
  11161. and nothing is read from the stream. (Such an operation is still considered a 
  11162. read operation, so it cannot immediately follow a write operation unless the 
  11163. buffer is flushed or the stream pointer repositioned first.) 
  11164.  
  11165. If n is greater than 1, fgetws fails only if an I/O error occurs or if WEOF is 
  11166. reached before data is read from the stream. Use ferror and feof to distinguish 
  11167. between a read error and a WEOF. WEOF is only reached when an attempt is made 
  11168. to read past the last byte of data. Reading up to and including the last byte 
  11169. of data does not turn on the WEOF indicator. 
  11170.  
  11171.  
  11172. ΓòÉΓòÉΓòÉ <hidden> Example of fgetws ΓòÉΓòÉΓòÉ
  11173.  
  11174. /************************************************************************
  11175.  
  11176. This example opens a file, reads in the file contents using fgetws, then prints 
  11177. the file contents. 
  11178.  
  11179. ************************************************************************/
  11180.  
  11181. #include <errno.h>
  11182. #include <stdio.h>
  11183. #include <wchar.h>
  11184.  
  11185. int main(void)
  11186. {
  11187.    FILE    *stream;
  11188.    wchar_t  wcs[100];
  11189.  
  11190.    if (NULL == (stream = fopen("fgetws.dat", "r"))) {
  11191.       printf("Unable to open: \"fgetws.dat\"\n");
  11192.       exit(1);
  11193.    }
  11194.  
  11195.    errno = 0;
  11196.    if (NULL == fgetws(wcs, 100, stream)) {
  11197.       if (EILSEQ == errno) {
  11198.          printf("An invalid wide character was encountered.\n");
  11199.          exit(1);
  11200.       }
  11201.       else if (feof(stream))
  11202.               printf("End of file reached.\n");
  11203.            else
  11204.               perror("Read error.\n");
  11205.    }
  11206.    printf("wcs = \"%ls\"\n", wcs);
  11207.    fclose(stream);
  11208.    return 0;
  11209.  
  11210.    /****************************************************************************
  11211.       Assuming the file fgetws.dat contains:
  11212.  
  11213.       This test string should not return -1
  11214.  
  11215.       The output should be similar to:
  11216.  
  11217.       wcs = "This test string should not return -1"
  11218.    ****************************************************************************/
  11219. }
  11220.  
  11221.  
  11222. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11223.  
  11224. Example of fgetws 
  11225.  
  11226.      fgets - Read a String 
  11227.      fgetwc - Read Wide Character from Stream 
  11228.      fputws - Write Wide-Character String. 
  11229.      <stdio.h> 
  11230.      <wchar.h> 
  11231.  
  11232.  
  11233. ΓòÉΓòÉΓòÉ 4.97. _filelength - Determine File Length ΓòÉΓòÉΓòÉ
  11234.  
  11235.  
  11236. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11237.  
  11238. #include <io.h>
  11239. long _filelength(int handle);
  11240.  
  11241.  
  11242. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11243.  
  11244. Language Level:  Extension 
  11245.  
  11246. _filelength returns the length, in bytes, of the file associated with handle. 
  11247. The length of the file will be correct even if you have the handle opened and 
  11248. have appended data to the file. 
  11249.  
  11250. Return Value 
  11251. A return value of -1L indicates an error, and errno is set to one of the 
  11252. following values: 
  11253.  
  11254.  Value        Meaning 
  11255.  EBADF        The file handle is incorrect or the mode specified does not match 
  11256.               the mode you opened the file with. 
  11257.  EOS2ERR      The call to the operating system was not successful. 
  11258.  
  11259.  
  11260. ΓòÉΓòÉΓòÉ <hidden> Example of _filelength ΓòÉΓòÉΓòÉ
  11261.  
  11262. /************************************************************************
  11263.  
  11264. This example opens a file and tries to determine the current length of the file 
  11265. using _filelength. 
  11266.  
  11267. ************************************************************************/
  11268.  
  11269. #include <io.h>
  11270. #include <stdio.h>
  11271. #include <stdlib.h>
  11272. #include <fcntl.h>
  11273.  
  11274. int main(void)
  11275. {
  11276.    long length;
  11277.    int fh;
  11278.  
  11279.    printf("\nCreating sample.dat.\n");
  11280.    system("echo Sample Program > sample.dat");
  11281.    if (-1 == (fh = open("sample.dat", O_RDWR|O_APPEND))) {
  11282.       printf("Unable to open sample.dat.\n");
  11283.       return EXIT_FAILURE;
  11284.    }
  11285.    if (-1 == (length = _filelength(fh))) {
  11286.       printf("Unable to determine length of sample.dat.\n");
  11287.       return EXIT_FAILURE;
  11288.    }
  11289.    printf("Current length of sample.dat is %d.\n", length);
  11290.    close(fh);
  11291.    return 0;
  11292.  
  11293.    /****************************************************************************
  11294.       The output should be:
  11295.  
  11296.       Creating sample.dat.
  11297.       Current length of sample.dat is 17.
  11298.    ****************************************************************************/
  11299. }
  11300.  
  11301.  
  11302. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11303.  
  11304. Example of _filelength 
  11305.  
  11306.      _chsize - Alter Length of File 
  11307.      __eof - Determine End of File 
  11308.      <io.h> 
  11309.  
  11310.  
  11311. ΓòÉΓòÉΓòÉ 4.98. fileno - Determine File Handle ΓòÉΓòÉΓòÉ
  11312.  
  11313.  
  11314. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11315.  
  11316. #include <stdio.h>
  11317. int fileno(FILE *stream);
  11318.  
  11319.  
  11320. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11321.  
  11322. Language Level:  XPG4, Extension 
  11323.  
  11324. fileno determines the file handle currently associated with stream. 
  11325.  
  11326. Note:  In earlier releases of C Set ++, fileno began with an underscore 
  11327. (_fileno). Because it is defined by the X/Open standard, the underscore has 
  11328. been removed. For compatibility, VisualAge C++ will map _fileno to fileno for 
  11329. you. 
  11330.  
  11331. Return Value 
  11332. fileno returns the file handle. If the function fails, the return value is -1 
  11333. and the errno variable may be set to one of the following values: 
  11334.  
  11335.  Value          Meaning 
  11336.  ENULLFCB       The input stream is NULL. 
  11337.  EBADTYPE       The input stream file is not a stream file. 
  11338.  
  11339.  The result is undefined if stream does not specify an open file. 
  11340.  
  11341.  
  11342. ΓòÉΓòÉΓòÉ <hidden> Example of fileno ΓòÉΓòÉΓòÉ
  11343.  
  11344. /************************************************************************
  11345.  
  11346. This example determines the file handle of the stderr data stream. 
  11347.  
  11348. ************************************************************************/
  11349.  
  11350. #include <stdio.h>
  11351.  
  11352. int main(void)
  11353. {
  11354.    int result;
  11355.  
  11356.    result = 0xFFFF & fileno(stderr);
  11357.    printf("The file handle associated with stderr is %d.\n", result);
  11358.    return 0;
  11359.  
  11360.    /****************************************************************************
  11361.       The output should be:
  11362.  
  11363.       The file handle associated with stderr is 2.
  11364.    ****************************************************************************/
  11365. }
  11366.  
  11367.  
  11368. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11369.  
  11370. Example of fileno 
  11371.  
  11372.      dup - Associate Second Handle with Open File 
  11373.      dup2 - Associate Second Handle with Open File 
  11374.      fopen - Open Files 
  11375.      freopen - Redirect Open Files 
  11376.      isatty - Test Handle for Character Device 
  11377.      open - Open File 
  11378.      <stdio.h> 
  11379.  
  11380.  
  11381. ΓòÉΓòÉΓòÉ 4.99. floor - Integer <= Argument ΓòÉΓòÉΓòÉ
  11382.  
  11383.  
  11384. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11385.  
  11386. #include <math.h>
  11387. double floor(double x);
  11388.  
  11389.  
  11390. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11391.  
  11392. Language Level: ANSI, SAA, POSIX, XPG4 
  11393.  
  11394. floor calculates the largest integer that is less than or equal to x. 
  11395.  
  11396. Return Value 
  11397. floor returns the floating-point result as a double value. 
  11398.  
  11399. The result of floor cannot have a range error. 
  11400.  
  11401.  
  11402. ΓòÉΓòÉΓòÉ <hidden> Example of floor ΓòÉΓòÉΓòÉ
  11403.  
  11404. /************************************************************************
  11405.  
  11406. This example assigns y value of the largest integer less than or equal to 2.8 
  11407. and z the value of the largest integer less than or equal to -2.8. 
  11408.  
  11409. ************************************************************************/
  11410.  
  11411. #include <math.h>
  11412.  
  11413. int main(void)
  11414. {
  11415.    double y,z;
  11416.  
  11417.    y = floor(2.8);
  11418.    z = floor(-2.8);
  11419.    printf("floor(  2.8 ) = %lf\n", y);
  11420.    printf("floor( -2.8 ) = %lf\n", z);
  11421.    return 0;
  11422.  
  11423.    /****************************************************************************
  11424.       The output should be:
  11425.  
  11426.       floor(  2.8 ) = 2.000000
  11427.       floor( -2.8 ) = -3.000000
  11428.    ****************************************************************************/
  11429. }
  11430.  
  11431.  
  11432. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11433.  
  11434. Example of floor 
  11435.  
  11436.      ceil - Find Integer >= Argument 
  11437.      fmod - Calculate Floating-Point Remainder 
  11438.      <math.h> 
  11439.  
  11440.  
  11441. ΓòÉΓòÉΓòÉ 4.100. _flushall - Write Buffers to Files ΓòÉΓòÉΓòÉ
  11442.  
  11443.  
  11444. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11445.  
  11446. #include <stdio.h>
  11447. int _flushall(void);
  11448.  
  11449.  
  11450. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11451.  
  11452. Language Level:  Extension 
  11453.  
  11454. _flushall causes the system to write to file the contents of all buffers 
  11455. associated with open output streams (including stdin, stdout, and stderr). It 
  11456. clears all buffers associated with open input streams of their current 
  11457. contents. The next read operation, if there is one, reads new data from the 
  11458. input files into the buffers. All streams remain open after the call. 
  11459.  
  11460. For portability, use the ANSI/ISO function fflush instead of _flushall. 
  11461.  
  11462. Return Value 
  11463. _flushall returns the number of open streams of input and output. If an error 
  11464. occurs, _flushall returns EOF. 
  11465.  
  11466.  
  11467. ΓòÉΓòÉΓòÉ <hidden> Example of _flushall ΓòÉΓòÉΓòÉ
  11468.  
  11469. /************************************************************************
  11470.  
  11471. In this example, _flushall completes any pending input or output on all streams 
  11472. by flushing all buffers. 
  11473.  
  11474. ************************************************************************/
  11475.  
  11476. #include <stdio.h>
  11477.  
  11478. int main(void)
  11479. {
  11480.    int i,numflushed;
  11481.    char buffer1[5] =  { 1,2,3,4 };
  11482.    char buffer2[5] =  { 5,6,7,8 };
  11483.    char *file1 = "file1.dat";
  11484.    char *file2 = "file2.dat";
  11485.    FILE *stream1,*stream2;
  11486.  
  11487.    stream1 = fopen(file1, "a+");
  11488.    stream2 = fopen(file2, "a+");
  11489.    for (i = 0; i <= sizeof(buffer1); i++) {
  11490.       fputc(buffer1[i], stream1);
  11491.       fputc(buffer2[i], stream2);
  11492.    }
  11493.    numflushed = _flushall();                   /* all streams flushed          */
  11494.    printf("Number of files flushed = %d\n", numflushed);
  11495.    fclose(stream1);
  11496.    fclose(stream2);
  11497.    return 0;
  11498.  
  11499.    /****************************************************************************
  11500.       The output should be:
  11501.  
  11502.       Number of files flushed = 5
  11503.    ****************************************************************************/
  11504. }
  11505.  
  11506.  
  11507. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11508.  
  11509. Example of _flushall 
  11510.  
  11511.      close - Close File Associated with Handle 
  11512.      fclose - Close Stream 
  11513.      fflush - Write Buffer to File 
  11514.      <stdio.h> 
  11515.  
  11516.  
  11517. ΓòÉΓòÉΓòÉ 4.101. fmod - Calculate Floating-Point Remainder ΓòÉΓòÉΓòÉ
  11518.  
  11519.  
  11520. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11521.  
  11522. #include <math.h>
  11523. double fmod(double x, double y);
  11524.  
  11525.  
  11526. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11527.  
  11528. Language Level: ANSI, SAA, POSIX, XPG4 
  11529.  
  11530. fmod calculates the floating-point remainder of x/y. The absolute value of the 
  11531. result is always less than the absolute value of y. The result will have the 
  11532. same sign as x. 
  11533.  
  11534. Return Value 
  11535.  
  11536. fmod returns the floating-point remainder of x/y. If y is zero or if x/y causes 
  11537. an overflow, fmod returns 0. 
  11538.  
  11539.  
  11540. ΓòÉΓòÉΓòÉ <hidden> Example of fmod ΓòÉΓòÉΓòÉ
  11541.  
  11542. /************************************************************************
  11543.  
  11544. This example computes z as the remainder of x/y; here, x/y is -3 with a 
  11545. remainder of -1. 
  11546.  
  11547. ************************************************************************/
  11548.  
  11549. #include <math.h>
  11550.  
  11551. int main(void)
  11552. {
  11553.    double x,y,z;
  11554.  
  11555.    x = -10.0;
  11556.    y = 3.0;
  11557.    z = fmod(x, y);                                        /* z = -1.0         */
  11558.    printf("fmod( %lf, %lf) = %lf\n", x, y, z);
  11559.    return 0;
  11560.  
  11561.    /****************************************************************************
  11562.       The output should be:
  11563.  
  11564.       fmod( -10.000000, 3.000000) = -1.000000
  11565.    ****************************************************************************/
  11566. }
  11567.  
  11568.  
  11569. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11570.  
  11571. Example of fmod 
  11572.  
  11573.      ceil - Find Integer >= Argument 
  11574.      fabs - Calculate Floating-Point Absolute Value 
  11575.      floor - Integer <= Argument 
  11576.      <math.h> 
  11577.  
  11578.  
  11579. ΓòÉΓòÉΓòÉ 4.102. fopen - Open Files ΓòÉΓòÉΓòÉ
  11580.  
  11581.  
  11582. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11583.  
  11584. #include <stdio.h>
  11585. FILE *fopen(const char *filename, const char *mode);
  11586.  
  11587.  
  11588. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11589.  
  11590. Language Level: ANSI, SAA, POSIX, XPG4 
  11591.  
  11592. fopen opens the file specified by filename. mode is a character string 
  11593. specifying the type of access requested for the file. The mode variable 
  11594. contains one positional parameter followed by optional keyword parameters. 
  11595.  
  11596. The possible values for the positional parameters are: 
  11597.  
  11598.  Mode Description 
  11599.  r 
  11600.    Open a text file for reading.  The file must exist. 
  11601.  w 
  11602.    Create a text file for writing. If the given file exists, its contents are 
  11603.    destroyed. 
  11604.  a 
  11605.    Open a text file in append mode for writing at the end of the file. fopen 
  11606.    creates the file if it does not exist. 
  11607.  r+ 
  11608.    Open a text file for both reading and writing.  The file must exist. 
  11609.  w+ 
  11610.    Create a text file for both reading and writing. If the given file exists, 
  11611.    its contents are destroyed. 
  11612.  a+ 
  11613.    Open a text file in append mode for reading or updating at the end of the 
  11614.    file.  fopen creates the file if it does not exist. 
  11615.  rb 
  11616.    Open a binary file for reading.  The file must exist. 
  11617.  wb 
  11618.    Create an empty binary file for writing. If the file exists, its contents 
  11619.    are destroyed. 
  11620.  ab 
  11621.    Open a binary file in append mode for writing at the end of the file. fopen 
  11622.    creates the file if it does not exist. 
  11623.  r+b or rb+ 
  11624.    Open a binary file for both reading and writing. The file must exist. 
  11625.  w+b or wb+ 
  11626.    Create an empty binary file for both reading and writing. If the file 
  11627.    exists, its contents will be destroyed. 
  11628.  a+b or ab+ 
  11629.    Open a binary file in append mode for writing at the end of the file.  fopen 
  11630.    creates the file if it does not exist. 
  11631.  
  11632.  Warning: Use the w, w+, wb, w+b, and wb+ parameters with care;  data in 
  11633.  existing files of the same name will be lost. 
  11634.  
  11635.  Text files contain printable characters and control characters organized into 
  11636.  lines. Each line ends with a new-line character, except for the last line, 
  11637.  which does not require one. The system may insert or convert control 
  11638.  characters in an output text stream. 
  11639.  
  11640.  Note:  Data output to a text stream may not compare as equal to the same data 
  11641.  on input. 
  11642.  
  11643.  Binary files contain a series of characters.  For binary files, the system 
  11644.  does not translate control characters on input or output. 
  11645.  
  11646.  When you open a file with a, a+, ab, a+b or ab+ mode, all write operations 
  11647.  take place at the end of the file.  Although you can reposition the file 
  11648.  pointer using fseek or rewind, the write functions move the file pointer back 
  11649.  to the end of the file before they carry out any operation. This action 
  11650.  prevents you from overwriting existing data. 
  11651.  
  11652.  When you specify the update mode (using + in the second or third position), 
  11653.  you can both read from and write to the file.  However, when switching between 
  11654.  reading and writing, you must include an intervening positioning function such 
  11655.  as fseek, fsetpos, rewind, or fflush.  Output may immediately follow input if 
  11656.  the end-of-file was detected. 
  11657.  
  11658.  The keyword parameters are: 
  11659.  
  11660.  blksize=value 
  11661.    Specifies the maximum length, in bytes, of a physical block of records. For 
  11662.    fixed-length records, the maximum size is 32760 bytes.  For variable-length 
  11663.    records, the maximum is 32756. The default buffer size is 4096 bytes. 
  11664.  lrecl=value 
  11665.    Specifies the length, in bytes, for fixed-length records and the maximum 
  11666.    length for variable-length records. For fixed-length records, the maximum 
  11667.    length is 32760 bytes.  For variable-length records, the maximum is 32756. 
  11668.    If the value of LRECL is larger than the value of BLKSIZE, the LRECL value 
  11669.    is ignored. 
  11670.  recfm=value 
  11671.    value can be: 
  11672.    F         fixed-length, unblocked records 
  11673.    V         variable-length, unblocked records The default for the 
  11674.    VisualAge C++ compiler is fixed-length record format. 
  11675.  type=value 
  11676.    value can be: 
  11677.  
  11678.    memory  This parameter identifies this file as a memory file that is 
  11679.    accessible only from C programs. This is the default. If you want to use a 
  11680.    memory file, you must compile with the /Sv option. 
  11681.  
  11682.  The VisualAge C++ compiler does not support record I/O. 
  11683.  
  11684.  fopen generally fails if parameters are mismatched. 
  11685.  
  11686.  The file attributes can be altered only if the open mode specified with the 
  11687.  fopen function is one of the write modes (w, w+, wb, or wb+). The system 
  11688.  deletes the existing file and creates a new file with the attributes specified 
  11689.  in fopen. 
  11690.  
  11691.  Return Value 
  11692.  fopen returns a pointer to a file structure that can be used to access the 
  11693.  open file. A NULL pointer return value indicates an error. 
  11694.  
  11695.  
  11696. ΓòÉΓòÉΓòÉ <hidden> Example of fopen ΓòÉΓòÉΓòÉ
  11697.  
  11698. /************************************************************************
  11699.  
  11700. This example attempts to open a file for reading. 
  11701.  
  11702. ************************************************************************/
  11703.  
  11704. #include <stdio.h>
  11705.  
  11706. int main(void)
  11707. {
  11708.    FILE *stream;
  11709.  
  11710.    if (NULL == (stream = fopen("myfile.dat", "r")))
  11711.       printf("Could not open data file\n");
  11712.    else
  11713.       fclose(stream);
  11714.  
  11715.     /* The following call opens a fixed record length file                    */
  11716.     /* for reading and writing in record mode.                                */
  11717.  
  11718.    if (NULL == (stream = fopen("myfile.dat",
  11719.                         "rb+, lrecl=80, blksize=240, recfm=f, type=record")))
  11720.       printf("Could not open data file\n");
  11721.    else
  11722.       fclose(stream);
  11723.    return 0;
  11724.  
  11725.    /****************************************************************************
  11726.       The output should be:
  11727.  
  11728.       Could not open data file
  11729.    ****************************************************************************/
  11730. }
  11731.  
  11732.  
  11733. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11734.  
  11735. Example of fopen 
  11736.  
  11737.      creat - Create New File 
  11738.      fclose - Close Stream 
  11739.      fflush - Write Buffer to File 
  11740.      fread - Read Items 
  11741.      freopen - Redirect Open Files 
  11742.      open - Open File 
  11743.      _sopen - Open Shared File 
  11744.      fseek - Reposition File Position 
  11745.      fsetpos - Set File Position 
  11746.      fwrite - Write Items 
  11747.      rewind - Adjust Current File Position 
  11748.      <stdio.h> 
  11749.  
  11750.  
  11751. ΓòÉΓòÉΓòÉ 4.103. _fpatan - Calculate Arctangent ΓòÉΓòÉΓòÉ
  11752.  
  11753.  
  11754. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11755.  
  11756. #include <builtin.h>
  11757. double _fpatan(double x);
  11758.  
  11759.  
  11760. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11761.  
  11762. Language Level:  Extension 
  11763.  
  11764. _fpatan calculates the arctangent of x, which is a value in radians between 
  11765. -pi/2 and pi/2. This function causes the compiler to emit the appropriate 80387 
  11766. instruction for the calculation of arctangent. 
  11767.  
  11768. Because it is a built-in function and has no backing code in the library: 
  11769.  
  11770.      You cannot take the address of _fpatan. 
  11771.      You cannot parenthesize a _fpatan function call, because parentheses 
  11772.       specify a call to the backing code for the function. 
  11773.  
  11774.  Return Value 
  11775.  This function returns the arctangent of x. 
  11776.  
  11777.  
  11778. ΓòÉΓòÉΓòÉ <hidden> Example of _fpatan ΓòÉΓòÉΓòÉ
  11779.  
  11780. /************************************************************************
  11781.  
  11782. This example calculates the arctangent of x. 
  11783.  
  11784. ************************************************************************/
  11785.  
  11786. #include <builtin.h>
  11787. #include <stdio.h>
  11788.  
  11789. int main(void)
  11790. {
  11791.    double x;
  11792.  
  11793.    x = 0.45;
  11794.    printf("The arctangent of %lf is %lf.\n", x, _fpatan(x));
  11795.    return 0;
  11796.  
  11797.    /****************************************************************************
  11798.       The output should be :
  11799.  
  11800.       The arctangent of 0.450000 is 0.422854.
  11801.    ****************************************************************************/
  11802. }
  11803.  
  11804.  
  11805. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11806.  
  11807. Example of _fpatan 
  11808.  
  11809.      atan - atan2 - Calculate Arctangent 
  11810.      _fptan - Calculate Tangent 
  11811.      tan - Calculate Tangent 
  11812.      tanh - Calculate Hyperbolic Tangent 
  11813.      <builtin.h> 
  11814.  
  11815.  
  11816. ΓòÉΓòÉΓòÉ 4.104. _fpreset - Reset Floating-Point Unit ΓòÉΓòÉΓòÉ
  11817.  
  11818.  
  11819. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11820.  
  11821. #include <float.h>
  11822. void _fpreset(void);
  11823.  
  11824.  
  11825. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11826.  
  11827. Language Level:  Extension 
  11828.  
  11829. _fpreset resets the floating-point unit to the default state that the math 
  11830. library requires to function correctly. The value of this default state may 
  11831. change between releases of VisualAge C++. You can determine the default state 
  11832. by calling _fpreset and then calling _control87 with 0 as the parameter. 
  11833.  
  11834. This function is often used within signal handlers. If a program traps 
  11835. floating-point error signals (SIGFPE) with signal, the program can safely 
  11836. recover from floating-point errors by calling longjmp. For more information on 
  11837. signal handlers, see "Signal and OS/2 Exception Handling" the Programming 
  11838. Guide. 
  11839.  
  11840. _fpreset resets the floating-point unit of the current thread only.  It does 
  11841. not affect any other threads that may be processing. 
  11842.  
  11843. Return Value 
  11844. There is no return value. 
  11845.  
  11846.  
  11847. ΓòÉΓòÉΓòÉ <hidden> Example of _fpreset ΓòÉΓòÉΓòÉ
  11848.  
  11849. /************************************************************************
  11850.  
  11851. This example establishes the function fphandler as a floating-point error 
  11852. handler. The main program produces a floating-point error, which causes control 
  11853. to be passed to fphandler. The fphandler function calls _fpreset to reset the 
  11854. floating-point unit, and then returns to main. 
  11855.  
  11856. ************************************************************************/
  11857.  
  11858. #include <stdio.h>
  11859. #include <stdlib.h>
  11860. #include <signal.h>
  11861. #include <setjmp.h>
  11862. #include <float.h>
  11863.  
  11864. jmp_buf mark;
  11865.  
  11866. void fphandler(int sig)
  11867. {
  11868.    printf("Floating point signal = %d\n", sig);
  11869.    _fpreset();                /* Reinitialize floating-point package          */
  11870.    longjmp(mark, -1);
  11871. }
  11872.  
  11873. int main(void)
  11874. {
  11875.    double a = 1.0,b = 0.0,c;
  11876.  
  11877.    if (SIG_ERR == signal(SIGFPE, fphandler))
  11878.       return EXIT_FAILURE;
  11879.    if (0 == setjmp(mark)) {
  11880.       c = a/b;                    /* generate floating-point error            */
  11881.       printf("Should never get here\n");
  11882.    }
  11883.    printf("Recovered from floating-point error\n");
  11884.    return 0;
  11885.  
  11886.    /****************************************************************************
  11887.       The output should be:
  11888.  
  11889.       Floating point signal = 3
  11890.       Recovered from floating-point error
  11891.    ****************************************************************************/
  11892. }
  11893.  
  11894.  
  11895. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11896.  
  11897. Example of _fpreset 
  11898.  
  11899.      _clear87 - Clear Floating-Point Status Word 
  11900.      _control87 - Set Floating-Point Control Word 
  11901.      longjmp - Restore Stack Environment 
  11902.      signal - Handle Interrupt Signals 
  11903.      _status87 - Get Floating-Point Status Word 
  11904.      <float.h> 
  11905.  
  11906.  
  11907. ΓòÉΓòÉΓòÉ 4.105. fprintf - Write Formatted Data to a Stream ΓòÉΓòÉΓòÉ
  11908.  
  11909.  
  11910. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  11911.  
  11912. #include <stdio.h>
  11913. int fprintf(FILE *stream, const char *format-string, argument-list);
  11914.  
  11915.  
  11916. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  11917.  
  11918. Language Level: ANSI, SAA, POSIX, XPG4, Extension 
  11919.  
  11920. fprintf formats and writes a series of characters and values to the output 
  11921. stream. fprintf converts each entry in argument-list, if any, and writes to the 
  11922. stream according to the corresponding format specification in the 
  11923. format-string. 
  11924.  
  11925. The format-string has the same form and function as the format-string argument 
  11926. for printf. See printf - Print Formatted Characters for a description of the 
  11927. format-string and the argument list. 
  11928.  
  11929. In extended mode, fprintf also converts floating-point values of NaN and 
  11930. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  11931. and sign of the string is determined by the format specifiers.  See Infinity 
  11932. and NaN Support for more information on infinity and NaN values. 
  11933.  
  11934. If you specify a null string for the %s or %ls format specifier, fprintf prints 
  11935. (null). (In previous releases of C Set ++, printf produced no output for a null 
  11936. string.) 
  11937.  
  11938. Return Value 
  11939. fprintf returns the number of bytes printed or a negative value if an output 
  11940. error occurs. 
  11941.  
  11942.  
  11943. ΓòÉΓòÉΓòÉ <hidden> Example of fprintf ΓòÉΓòÉΓòÉ
  11944.  
  11945. /************************************************************************
  11946.  
  11947. This example sends a line of asterisks for each integer in the array count to 
  11948. the file myfile.  The number of asterisks printed on each line corresponds to 
  11949. an integer in the array. 
  11950.  
  11951. ************************************************************************/
  11952.  
  11953. #include <stdio.h>
  11954.  
  11955. int count[10] =  { 1, 5, 8, 3, 0, 3, 5, 6, 8, 10 } ;
  11956.  
  11957. int main(void)
  11958. {
  11959.    int i,j;
  11960.    FILE *stream;
  11961.  
  11962.    stream = fopen("myfile.dat", "w");
  11963.  
  11964.                    /* Open the stream for writing                             */
  11965.    for (i = 0; i < sizeof(count)/sizeof(count[0]); i++) {
  11966.       for (j = 0; j < count[i]; j++)
  11967.          fprintf(stream, "*");
  11968.  
  11969.                    /* Print asterisk                                          */
  11970.       fprintf(stream, "\n");
  11971.  
  11972.                    /* Move to the next line                                   */
  11973.    }
  11974.    fclose(stream);
  11975.    return 0;
  11976.  
  11977.    /****************************************************************************
  11978.       The output data file myfile.dat should contain:
  11979.  
  11980.       *
  11981.       *****
  11982.       ********
  11983.       ***
  11984.  
  11985.       ***
  11986.       *****
  11987.       ******
  11988.       ********
  11989.       **********
  11990.    ****************************************************************************/
  11991. }
  11992.  
  11993.  
  11994. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  11995.  
  11996. Example of fprintf 
  11997.  
  11998.      _cprintf - Print Characters to Screen 
  11999.      fscanf - Read Formatted Data 
  12000.      printf - Print Formatted Characters 
  12001.      sprintf - Print Formatted Data to Buffer 
  12002.      vfprintf - Print Argument Data to Stream 
  12003.      vprintf - Print Argument Data 
  12004.      vsprintf - Print Argument Data to Buffer 
  12005.      vswprintf - Format and Write Wide Characters to Buffer 
  12006.      Infinity and NaN Support 
  12007.      <stdio.h> 
  12008.  
  12009.  
  12010. ΓòÉΓòÉΓòÉ 4.106. _fptan - Calculate Tangent ΓòÉΓòÉΓòÉ
  12011.  
  12012.  
  12013. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12014.  
  12015. #include <builtin.h>
  12016. double _fptan(double x);
  12017.  
  12018.  
  12019. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12020.  
  12021. Language Level:  Extension 
  12022.  
  12023. _fptan calculates the tangent of x, where x is expressed in radians. The value 
  12024. of x must be less than 2**63. This function causes the compiler to emit the 
  12025. appropriate 80387 instruction for the calculation of tangent. 
  12026.  
  12027. Because it is a built-in function and has no backing code in the library: 
  12028.  
  12029.      You cannot take the address of _fptan. 
  12030.      You cannot parenthesize a _fptan function call, because parentheses 
  12031.       specify a call to the backing code for the function in the library. 
  12032.  
  12033.  Return Value 
  12034.  _fptan returns the tangent of x expressed in radians. 
  12035.  
  12036.  
  12037. ΓòÉΓòÉΓòÉ <hidden> Example of _fptan ΓòÉΓòÉΓòÉ
  12038.  
  12039. /************************************************************************
  12040.  
  12041. This example calculates the tangent of pi/4. 
  12042.  
  12043. ************************************************************************/
  12044.  
  12045. #include <builtin.h>
  12046. #include <stdio.h>
  12047.  
  12048. int main(void)
  12049. {
  12050.    double pi;
  12051.  
  12052.    pi = 3.1415926;
  12053.    printf("The tangent of %lf is %lf.\n", pi/4.0, _fptan(pi/4.0));
  12054.    return 0;
  12055.  
  12056.    /****************************************************************************
  12057.       The output should be :
  12058.  
  12059.       The tangent of 0.785398 is 1.000000.
  12060.    ****************************************************************************/
  12061. }
  12062.  
  12063.  
  12064. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12065.  
  12066. Example of _fptan 
  12067.  
  12068.      atan - atan2 - Calculate Arctangent 
  12069.      _fpatan - Calculate Arctangent 
  12070.      tan - Calculate Tangent 
  12071.      tanh - Calculate Hyperbolic Tangent 
  12072.      <builtin.h> 
  12073.  
  12074.  
  12075. ΓòÉΓòÉΓòÉ 4.107. fputc - Write Character ΓòÉΓòÉΓòÉ
  12076.  
  12077.  
  12078. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12079.  
  12080. #include <stdio.h>
  12081. int fputc(int c, FILE *stream);
  12082.  
  12083.  
  12084. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12085.  
  12086. Language Level: ANSI, SAA, POSIX, XPG4 
  12087.  
  12088. fputc converts c to an unsigned char and then writes c to the output stream at 
  12089. the current position and advances the file position appropriately. If the 
  12090. stream is opened with one of the append modes, the character is appended to the 
  12091. end of the stream. 
  12092.  
  12093. fputc is identical to putc is always implemented as a function call; it is 
  12094. never replaced by a macro. 
  12095.  
  12096. Return Value 
  12097. fputc returns the character written.  A return value of EOF indicates an error. 
  12098.  
  12099.  
  12100. ΓòÉΓòÉΓòÉ <hidden> Example of fputc ΓòÉΓòÉΓòÉ
  12101.  
  12102. /************************************************************************
  12103.  
  12104. This example writes the contents of buffer to a file called myfile.dat. 
  12105.  
  12106. Note:  Because the output occurs as a side effect within the second expression 
  12107. of the for statement, the statement body is null. 
  12108.  
  12109. ************************************************************************/
  12110.  
  12111. #include <stdio.h>
  12112. #include <stdlib.h>
  12113.  
  12114. #define  NUM_ALPHA     26
  12115.  
  12116. int main(void)
  12117. {
  12118.    FILE *stream;
  12119.    int i;
  12120.    int ch;
  12121.  
  12122.    /* Don't forget the NULL char at the end of the string!                    */
  12123.    char buffer[NUM_ALPHA+1] = "abcdefghijklmnopqrstuvwxyz";
  12124.  
  12125.    if ((stream = fopen("myfile.dat", "w")) != NULL) {
  12126.  
  12127.      /* Put buffer into file                                                  */
  12128.       for (i = 0; (i < sizeof(buffer)) && ((ch = fputc(buffer[i], stream)) !=
  12129.          EOF); ++i)
  12130.          ;
  12131.       fclose(stream);
  12132.       return 0;
  12133.    }
  12134.    else
  12135.       perror("Error opening myfile.dat");
  12136.    return EXIT_FAILURE;
  12137.  
  12138.    /****************************************************************************
  12139.       The output data file myfile.dat should contain:
  12140.  
  12141.       abcdefghijklmnopqrstuvwxyz
  12142.    ****************************************************************************/
  12143. }
  12144.  
  12145.  
  12146. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12147.  
  12148. Example of fputc 
  12149.  
  12150.      fgetc - Read a Character 
  12151.      _fputchar - Write Character 
  12152.      putc - putchar - Write a Character 
  12153.      _putch - Write Character to Screen 
  12154.      <stdio.h> 
  12155.  
  12156.  
  12157. ΓòÉΓòÉΓòÉ 4.108. _fputchar - Write Character ΓòÉΓòÉΓòÉ
  12158.  
  12159.  
  12160. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12161.  
  12162. #include <stdio.h>
  12163. int _fputchar(int c);
  12164.  
  12165.  
  12166. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12167.  
  12168. Language Level:  Extension 
  12169.  
  12170. _fputchar writes the single character c to the stdout stream at the current 
  12171. position. It is equivalent to the following fputc call: 
  12172.  
  12173.    fputc(c, stdout);
  12174.  
  12175. For portability, use the ANSI/ISO fputc function instead of _fputchar. 
  12176.  
  12177. Return Value 
  12178. _fputchar returns the character written.  A return value of EOF indicates that 
  12179. a write error has occurred. Use ferror and feof to tell whether this is an 
  12180. error condition or the end of the file. 
  12181.  
  12182.  
  12183. ΓòÉΓòÉΓòÉ <hidden> Example of _fputchar ΓòÉΓòÉΓòÉ
  12184.  
  12185. /************************************************************************
  12186.  
  12187. This example writes the contents of buffer to stdout: 
  12188.  
  12189. ************************************************************************/
  12190.  
  12191. #include <stdio.h>
  12192.  
  12193. int main(void)
  12194. {
  12195.    char buffer[80];
  12196.    int i,ch = 1;
  12197.  
  12198.    for (i = 0; i < 80; i++)
  12199.       buffer[i] = 'c';
  12200.    for (i = 0; (i < 80) && (ch != EOF); i++)
  12201.       ch = _fputchar(buffer[i]);
  12202.    printf("\n");
  12203.    return 0;
  12204.  
  12205.    /****************************************************************************
  12206.       The output should be similar to:
  12207.  
  12208.    ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
  12209.    ****************************************************************************/
  12210. }
  12211.  
  12212.  
  12213. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12214.  
  12215. Example of _fputchar 
  12216.  
  12217.      _fgetchar - Read Single Character from stdin 
  12218.      fputc - Write Character 
  12219.      putc - putchar - Write a Character 
  12220.      _putch - Write Character to Screen 
  12221.      <stdio.h> 
  12222.  
  12223.  
  12224. ΓòÉΓòÉΓòÉ 4.109. fputs - Write String ΓòÉΓòÉΓòÉ
  12225.  
  12226.  
  12227. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12228.  
  12229. #include <stdio.h>
  12230. int fputs(const char *string, FILE *stream);
  12231.  
  12232.  
  12233. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12234.  
  12235. Language Level: ANSI, SAA, POSIX, XPG4 
  12236.  
  12237. fputs copies string to the output stream at the current position.  It does not 
  12238. copy the null character (\0) at the end of the string. 
  12239.  
  12240. Return Value 
  12241. fputs returns EOF if an error occurs; otherwise, it returns a non-negative 
  12242. value. 
  12243.  
  12244.  
  12245. ΓòÉΓòÉΓòÉ <hidden> Example of fputs ΓòÉΓòÉΓòÉ
  12246.  
  12247. /************************************************************************
  12248.  
  12249. This example writes a string to a stream. 
  12250.  
  12251. ************************************************************************/
  12252.  
  12253. #include <stdio.h>
  12254.  
  12255. #define  NUM_ALPHA     26
  12256.  
  12257. int main(void)
  12258. {
  12259.    FILE *stream;
  12260.    int num;
  12261.  
  12262.    /* Do not forget that the '\0' char occupies one character                 */
  12263.  
  12264.    static char buffer[NUM_ALPHA+1] = "abcdefghijklmnopqrstuvwxyz";
  12265.  
  12266.    if ((stream = fopen("myfile.dat", "w")) != NULL) {
  12267.  
  12268.       /* Put buffer into file                                                 */
  12269.  
  12270.       if ((num = fputs(buffer, stream)) != EOF) {
  12271.  
  12272.         /* Note that fputs() does not copy the \0 character                   */
  12273.  
  12274.          printf("Total number of characters written to file = %i\n", num);
  12275.          fclose(stream);
  12276.       }
  12277.       else                                                /* fputs failed     */
  12278.          perror("fputs failed");
  12279.    }
  12280.    else
  12281.       perror("Error opening myfile.dat");
  12282.    return 0;
  12283.  
  12284.    /****************************************************************************
  12285.       The output should be:
  12286.  
  12287.       Total number of characters written to file = 26
  12288.    ****************************************************************************/
  12289. }
  12290.  
  12291.  
  12292. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12293.  
  12294. Example of fputs 
  12295.  
  12296.      _cputs - Write String to Screen 
  12297.      fgets - Read a String 
  12298.      gets - Read a Line 
  12299.      puts - Write a String 
  12300.      <stdio.h> 
  12301.  
  12302.  
  12303. ΓòÉΓòÉΓòÉ 4.110. fputwc - Write Wide Character ΓòÉΓòÉΓòÉ
  12304.  
  12305.  
  12306. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12307.  
  12308. #include <stdio.h>
  12309. #include <wchar.h>
  12310. wint_t fputwc(wint_t wc, FILE *stream);
  12311.  
  12312.  
  12313. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12314.  
  12315. Language Level:  ANSI 93, XPG4 
  12316.  
  12317. fputwc converts the wide character wc to a multibyte character and writes it to 
  12318. the output stream pointed to by stream at the current position. It also 
  12319. advances the file position indicator appropriately. If the file cannot support 
  12320. positioning requests, or if the stream was opened with append mode, the 
  12321. character is appended to the stream. 
  12322.  
  12323. The behavior of fputwc is affected by the LC_CTYPE category of the current 
  12324. locale. If you change the category between subsequent operations on the same 
  12325. stream, undefined results can occur. Using non-wide-character functions with 
  12326. fputwc on the same stream results in undefined behavior. 
  12327.  
  12328. After calling fputwc, flush the buffer or reposition the stream pointer before 
  12329. calling a read function for the stream. After reading from the stream, flush 
  12330. the buffer or reposition the stream pointer before calling fputwc, unless EOF 
  12331. has been reached. 
  12332.  
  12333. Return Value 
  12334. fputwc returns the wide character written. If a write error occurs, the error 
  12335. indicator for the stream is set and fputwc returns WEOF. If an encoding error 
  12336. occurs during conversion from wide character to a multibyte character, fputwc 
  12337. sets errno to EILSEQ and returns WEOF. 
  12338.  
  12339.  
  12340. ΓòÉΓòÉΓòÉ <hidden> Example of fputwc ΓòÉΓòÉΓòÉ
  12341.  
  12342. /************************************************************************
  12343.  
  12344. This example opens a file and uses fputwc to write wide characters to the file. 
  12345.  
  12346. ************************************************************************/
  12347.  
  12348. #include <stdio.h>
  12349. #include <wchar.h>
  12350. #include <errno.h>
  12351.  
  12352. int main(void)
  12353. {
  12354.    FILE    *stream;
  12355.    wchar_t *wcs = L"A character string.";
  12356.    int     i;
  12357.  
  12358.    if (NULL == (stream = fopen("fputwc.out", "w"))) {
  12359.       printf("Unable to open: \"fputwc.out\".\n");
  12360.       exit(1);
  12361.    }
  12362.  
  12363.    for (i = 0; wcs[i] != L'\0'; i++) {
  12364.       errno = 0;
  12365.       if (WEOF == fputwc(wcs[i], stream)) {
  12366.          printf("Unable to fputwc() the wide character.\n"
  12367.                 "wcs[%d] = 0x%lx\n", i, wcs[i]);
  12368.          if (EILSEQ == errno)
  12369.             printf("An invalid wide character was encountered.\n");
  12370.          exit(1);
  12371.       }
  12372.    }
  12373.    fclose(stream);
  12374.    return 0;
  12375.  
  12376.    /****************************************************************************
  12377.       The output file fputwc.out should contain :
  12378.  
  12379.       A character string.
  12380.    ****************************************************************************/
  12381. }
  12382.  
  12383.  
  12384. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12385.  
  12386. Example of fputwc 
  12387.  
  12388.      fgetwc - Read Wide Character from Stream 
  12389.      fputc - Write Character 
  12390.      _fputchar - Write Character 
  12391.      fputws - Write Wide-Character String 
  12392.      _putch - Write Character to Screen 
  12393.      <stdio.h> 
  12394.      <wchar.h> 
  12395.  
  12396.  
  12397. ΓòÉΓòÉΓòÉ 4.111. fputws - Write Wide-Character String ΓòÉΓòÉΓòÉ
  12398.  
  12399.  
  12400. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12401.  
  12402. #include <stdio.h>
  12403. #include <wchar.h>
  12404. int fputws(const wchar_t *wcs, FILE *stream);
  12405.  
  12406.  
  12407. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12408.  
  12409. Language Level:  ANSI, SAA, XPG4 
  12410.  
  12411. fputws converts the wide-character string wcs to a multibyte-character string 
  12412. and writes it to stream as a multibyte character string. It does not write the 
  12413. terminating null byte. 
  12414.  
  12415. The behavior of fputws is affected by the LC_CTYPE category of the current 
  12416. locale. If you change the category between subsequent operations on the same 
  12417. stream, undefined results can occur. Using non-wide-character functions with 
  12418. fputws on the same stream results in undefined behavior. 
  12419.  
  12420. After calling fputws, flush the buffer or reposition the stream pointer before 
  12421. calling a read function for the stream. After a read operation, flush the 
  12422. buffer or reposition the stream pointer before calling fputws, unless EOF has 
  12423. been reached. 
  12424.  
  12425. Return Value 
  12426. fputws returns a non-negative value if successful. If a write error occurs, the 
  12427. error indicator for the stream is set and fputws returns -1. If an encoding 
  12428. error occurs in converting the wide characters to multibyte characters, fputws 
  12429. sets errno to EILSEQ and returns -1. 
  12430.  
  12431.  
  12432. ΓòÉΓòÉΓòÉ <hidden> Example of fputws ΓòÉΓòÉΓòÉ
  12433.  
  12434. /************************************************************************
  12435.  
  12436. This example opens a file and writes a wide-character string to the file using 
  12437. fgetws. 
  12438.  
  12439. ************************************************************************/
  12440.  
  12441. #include <stdio.h>
  12442. #include <wchar.h>
  12443. #include <errno.h>
  12444.  
  12445. int main(void)
  12446. {
  12447.    FILE    *stream;
  12448.    wchar_t *wcs = L"This test string should not return -1";
  12449.  
  12450.    if (NULL == (stream = fopen("fputws.out", "w"))) {
  12451.       printf("Unable to open: \"fputws.out\".\n");
  12452.       exit(1);
  12453.    }
  12454.  
  12455.    errno = 0;
  12456.    if (EOF == fputws(wcs, stream)) {
  12457.       printf("Unable to complete fputws() function.\n");
  12458.       if (EILSEQ == errno)
  12459.          printf("An invalid wide character was encountered.\n");
  12460.       exit(1);
  12461.    }
  12462.    fclose(stream);
  12463.    return 0;
  12464.  
  12465.    /****************************************************************************
  12466.       The output file fputws.out should contain :
  12467.  
  12468.       This test string should not return -1
  12469.    ****************************************************************************/
  12470. }
  12471.  
  12472.  
  12473. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12474.  
  12475. Example of fputws 
  12476.  
  12477.      fgetws - Read Wide-Character String from Stream 
  12478.      fputs - Write String 
  12479.      fputwc - Write Wide Character 
  12480.      <stdio.h> 
  12481.      <wchar.h> 
  12482.  
  12483.  
  12484. ΓòÉΓòÉΓòÉ 4.112. fread - Read Items ΓòÉΓòÉΓòÉ
  12485.  
  12486.  
  12487. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12488.  
  12489. #include <stdio.h>
  12490. size_t fread(void *buffer, size_t size, size_t count,
  12491.                 FILE *stream);
  12492.  
  12493.  
  12494. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12495.  
  12496. Language Level: ANSI, SAA, POSIX, XPG4 
  12497.  
  12498. fread reads up to count items of size length from the input stream and stores 
  12499. them in the given buffer.  The position in the file increases by the number of 
  12500. bytes read. 
  12501.  
  12502. Return Value 
  12503. fread returns the number of full items successfully read, which can be less 
  12504. than count if an error occurs or if the end-of-file is met before reaching 
  12505. count.  If size or count is 0, fread returns zero and the contents of the array 
  12506. and the state of the stream remain unchanged. 
  12507.  
  12508. Use ferror and feof to distinguish between a read error and an end-of-file. 
  12509.  
  12510.  
  12511. ΓòÉΓòÉΓòÉ <hidden> Example of fread ΓòÉΓòÉΓòÉ
  12512.  
  12513. /************************************************************************
  12514.  
  12515. This example attempts to read NUM_ALPHA characters from the file myfile.dat. If 
  12516. there are any errors with either fread or fopen, a message is printed. 
  12517.  
  12518. ************************************************************************/
  12519.  
  12520. #include <stdio.h>
  12521.  
  12522. #define  NUM_ALPHA     26
  12523.  
  12524. int main(void)
  12525. {
  12526.    FILE *stream;
  12527.    int num;                     /* number of characters read from stream      */
  12528.  
  12529.    /* Do not forget that the '\0' char occupies one character too!            */
  12530.    char buffer[NUM_ALPHA+1];
  12531.  
  12532.    if ((stream = fopen("myfile.dat", "r")) != NULL) {
  12533.       num = fread(buffer, sizeof(char), NUM_ALPHA, stream);
  12534.       if (num) {                                          /* fread success    */
  12535.          printf("Number of characters has been read = %i\n", num);
  12536.          buffer[num] = '\0';
  12537.          printf("buffer = %s\n", buffer);
  12538.          fclose(stream);
  12539.       }
  12540.       else {                                              /* fread failed     */
  12541.          if (ferror(stream))                              /* possibility 1    */
  12542.             perror("Error reading myfile.dat");
  12543.          else
  12544.             if (feof(stream))                             /* possibility 2    */
  12545.  
  12546.                perror("EOF found");
  12547.       }
  12548.    }
  12549.    else
  12550.       perror("Error opening myfile.dat");
  12551.    return 0;
  12552.  
  12553.    /****************************************************************************
  12554.       The output should be:
  12555.  
  12556.       Number of characters has been read = 26
  12557.       buffer = abcdefghijklmnopqrstuvwxyz
  12558.    ****************************************************************************/
  12559. }
  12560.  
  12561.  
  12562. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12563.  
  12564. Example of fread 
  12565.  
  12566.      feof - Test End-of-File Indicator 
  12567.      ferror - Test for Read/Write Errors 
  12568.      fopen - Open Files 
  12569.      fwrite - Write Items 
  12570.      read - Read Into Buffer 
  12571.      <stdio.h> 
  12572.  
  12573.  
  12574. ΓòÉΓòÉΓòÉ 4.113. free - Release Storage Blocks ΓòÉΓòÉΓòÉ
  12575.  
  12576.  
  12577. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12578.  
  12579. #include <stdlib.h>  /* also in <malloc.h> */
  12580. void free(void *ptr);
  12581.  
  12582.  
  12583. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12584.  
  12585. Language Level: ANSI, SAA, POSIX, XPG4, Extension 
  12586.  
  12587. free frees a block of storage. ptr points to a block previously reserved with a 
  12588. call to one of the memory allocation functions (such as calloc, _umalloc, or 
  12589. _trealloc). The number of bytes freed is the number of bytes specified when you 
  12590. reserved (or reallocated, in the case of realloc) the block of storage.  If ptr 
  12591. is NULL, free simply returns. 
  12592.  
  12593. Note:  Attempting to free a block of storage not allocated with a C memory 
  12594. management function or a block that was previously freed can affect the 
  12595. subsequent reserving of storage and lead to undefined results. 
  12596.  
  12597. Return Value 
  12598. There is no return value. 
  12599.  
  12600.  
  12601. ΓòÉΓòÉΓòÉ <hidden> Example of free ΓòÉΓòÉΓòÉ
  12602.  
  12603. /************************************************************************
  12604.  
  12605. This example uses calloc to allocate storage for x array elements and then 
  12606. calls free to free them. 
  12607.  
  12608. ************************************************************************/
  12609.  
  12610. #include <stdio.h>
  12611. #include <stdlib.h>
  12612.  
  12613. int main(void)
  12614. {
  12615.    long *array;                              /* start of the array            */
  12616.    long *index;                                           /* index variable   */
  12617.    int i;                                                 /* index variable   */
  12618.    int num = 100;                       /* number of entries of the array     */
  12619.  
  12620.    printf("Allocating memory for %d long integers.\n", num);
  12621.  
  12622.    /* allocate num entries                                                    */
  12623.    if ((index = array = calloc(num, sizeof(long))) != NULL) {
  12624.  
  12625.      /*.......................................................................*/
  12626.      /*         do something with the array                                   */
  12627.      /*.......................................................................*/
  12628.  
  12629.       free(array);                                        /* deallocates array*/
  12630.    }
  12631.    else {                                                 /* Out of storage   */
  12632.       perror("Error: out of storage");
  12633.       abort();
  12634.    }
  12635.    return 0;
  12636.  
  12637.    /****************************************************************************
  12638.       The output should be:
  12639.  
  12640.       Allocating memory for 100 long integers.
  12641.    ****************************************************************************/
  12642. }
  12643.  
  12644.  
  12645. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12646.  
  12647. Example of free 
  12648.  
  12649.      Managing Memory in the Programming Guide 
  12650.      _alloca - Temporarily Reserve Storage Block 
  12651.      calloc - Reserve and Initialize Storage 
  12652.      _debug_free - Release Memory 
  12653.      _debug_tfree - Release Tiled Memory 
  12654.      malloc - Reserve Storage Block 
  12655.      realloc - Change Reserved Storage Block Size 
  12656.      _tfree - Free Tiled Storage Block 
  12657.      <malloc.h> 
  12658.      <stdlib.h> 
  12659.  
  12660.  
  12661. ΓòÉΓòÉΓòÉ 4.114. _freemod - Free User DLL ΓòÉΓòÉΓòÉ
  12662.  
  12663.  
  12664. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12665.  
  12666. #include <stdlib.h>
  12667. int _freemod(unsigned long module_handle);
  12668.  
  12669.  
  12670. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12671.  
  12672. Language Level:  Extension 
  12673.  
  12674. _freemod frees all references to a dynamic link library (DLL) for the calling 
  12675. process. It is the counterpart of the _loadmod function, which loads a DLL for 
  12676. the process. The module_handle is the module handle of the DLL, which was 
  12677. returned by _loadmod. 
  12678.  
  12679. Note:  _loadmod and _freemod perform exactly the same function as the OS/2 APIs 
  12680.        DosLoadModule and DosFreeModule. They are provided for compatibility 
  12681.        with earlier VisualAge C++ releases only, and will not be supported in 
  12682.        future versions. Use DosLoadModule and DosFreeModule instead. For more 
  12683.        details on these APIs, see the Control Program Guide and Reference. 
  12684.  
  12685.  Return Value 
  12686.  _freemod returns 0 if successful. If not, _freemod returns -1 and sets errno 
  12687.  to EOS2ERR. 
  12688.  
  12689.  
  12690. ΓòÉΓòÉΓòÉ <hidden> Example of _freemod ΓòÉΓòÉΓòÉ
  12691.  
  12692. /************************************************************************
  12693.  
  12694. This example loads the DLL mark with _loadmod, and uses the OS/2 function 
  12695. DosQueryProcAddr to get the address of the function dor from within the DLL. It 
  12696. then calls that function, which multiplies two integers passed to it. When the 
  12697. function and DLL are no longer needed, the program frees the DLL module. The 
  12698. macro INCL_DOS and the types PFN and APIRET are required for the OS/2 call, and 
  12699. are defined by including the <os2.h> header file. 
  12700.  
  12701. Note:  To run this program, you must first create mark.dll. Copy the code for 
  12702.        the PLUS function into a file called mark.c, and the code for the .DEF 
  12703.        file into mark.def.  Eliminate the comments from these two files. 
  12704.        Compile with the command: 
  12705.  
  12706.                  icc /Ge- mark.c mark.def
  12707.        You can then run the example. 
  12708.  
  12709.   ************************************************************************/
  12710.  
  12711.   #define  INCL_DOS
  12712.   #include <os2.h>
  12713.   #include <stdio.h>
  12714.   #include <stdlib.h>
  12715.  
  12716.    /* This is the code for MARK.DEF
  12717.    LIBRARY MARK
  12718.    PROTMODE
  12719.    EXPORTS PLUS                                                                 */
  12720.    /* This is the code for PLUS function in the DLL
  12721.       #pragma linkage( PLUS, system )
  12722.       int PLUS( int a , int b)
  12723.       {
  12724.          return a + b;
  12725.       }                                                                         */
  12726.  
  12727.   int main(void)
  12728.   {
  12729.      int x = 4,y = 7;
  12730.      unsigned long handle;
  12731.      char *modname = "MARK";                                /* DLL name         */
  12732.      char *fname = "PLUS";                                  /* function name    */
  12733.      PFN faddr;                                  /* pointer to function         */
  12734.      APIRET rc;                            /* return code from DosQueryProcAddr */
  12735.  
  12736.       /*  dynamically load the 'mark' DLL                                       */
  12737.  
  12738.      if (_loadmod(modname, &handle)) {
  12739.         printf("Error loading module %s\n", modname);
  12740.         return EXIT_FAILURE;
  12741.      }
  12742.  
  12743.       /*   get function address from DLL                                        */
  12744.  
  12745.      rc = DosQueryProcAddr(handle, 0, fname, &faddr);
  12746.      if (0 == rc) {
  12747.         printf("Calling the function from the %s DLL to add %d and %d\n", modname,
  12748.            x, y);
  12749.         printf("The result of the function call is %d\n", faddr(x, y));
  12750.      }
  12751.      else {
  12752.         printf("Error locating address of function %s\n", fname);
  12753.         _freemod(handle);
  12754.         return EXIT_FAILURE;
  12755.      }
  12756.      if (_freemod(handle)) {
  12757.         printf("Error in freeing the %s DLL module\n", modname);
  12758.         return EXIT_FAILURE;
  12759.      }
  12760.      printf("Reference to the %s DLL module has been freed\n", modname);
  12761.      return 0;
  12762.  
  12763.      /****************************************************************************
  12764.         The output should be:
  12765.  
  12766.         Calling the function from the MARK DLL to add 4 and 7
  12767.         The result of the function call is 11
  12768.         Reference to the MARK DLL module has been freed
  12769.      ****************************************************************************/
  12770.   }
  12771.  
  12772.  
  12773. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12774.  
  12775. Example of _freemod 
  12776.  
  12777.      "Building Dynamic Link Libraries" in the Programming Guide 
  12778.      _loadmod - Load DLL 
  12779.      <stdlib.h> 
  12780.  
  12781.  
  12782. ΓòÉΓòÉΓòÉ 4.115. freopen - Redirect Open Files ΓòÉΓòÉΓòÉ
  12783.  
  12784.  
  12785. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12786.  
  12787. #include <stdio.h>
  12788. FILE *freopen(const char *filename, const char *mode, FILE *stream);
  12789.  
  12790.  
  12791. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12792.  
  12793. Language Level: ANSI, SAA, POSIX, XPG4 
  12794.  
  12795. freopen closes the file currently associated with stream and reassigns stream 
  12796. to the file specified by filename. The freopen function opens the new file 
  12797. associated with stream with the given mode, which is a character string 
  12798. specifying the type of access requested for the file. You can also use the 
  12799. freopen function to redirect the standard stream files stdin, stdout, and 
  12800. stderr to files that you specify. 
  12801.  
  12802. If filename is an empty string, freopen closes and reopens the stream to the 
  12803. new open mode, rather than reassigning it to a new file or device. You can use 
  12804. freopen with no file name specified to change the mode of a standard stream 
  12805. from text to binary without redirecting the stream, for example: 
  12806.  
  12807.    fp = freopen("", "rb", stdin);
  12808. You can use the same method to change the mode from binary back to text. 
  12809.  
  12810. Portability Note  This method is included in the SAA C definition, but not in 
  12811. the ANSI/ISO C standard. 
  12812.  
  12813. See fopen. for a description of the mode parameter. 
  12814.  
  12815. Return Value 
  12816. freopen returns a pointer to the newly opened stream. If an error occurs, 
  12817. freopen closes the original file and returns a NULL pointer value. 
  12818.  
  12819.  
  12820. ΓòÉΓòÉΓòÉ <hidden> Example of freopen ΓòÉΓòÉΓòÉ
  12821.  
  12822. /************************************************************************
  12823.  
  12824. This example closes the stream1 data stream and reassigns its stream pointer. 
  12825. Note that stream1 and stream2 will have the same value, but they will not 
  12826. necessarily have the same value as stream. 
  12827.  
  12828. ************************************************************************/
  12829.  
  12830. #include <stdio.h>
  12831. #include <stdlib.h>
  12832.  
  12833. int main(void)
  12834. {
  12835.    FILE *stream,*stream1,*stream2;
  12836.  
  12837.    stream = fopen("myfile.dat", "r");
  12838.    stream1 = stream;
  12839.    if (NULL == (stream2 = freopen("", "w+", stream1)))
  12840.       return EXIT_FAILURE;
  12841.    fclose(stream2);
  12842.    return 0;
  12843. }
  12844.  
  12845.  
  12846. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12847.  
  12848. Example of freopen 
  12849.  
  12850.      close - Close File Associated with Handle 
  12851.      fclose - Close Stream 
  12852.      _fcloseall - Close All Open Streams 
  12853.      fopen - Open Files 
  12854.      open - Open File 
  12855.      _sopen - Open Shared File 
  12856.      <stdio.h> 
  12857.  
  12858.  
  12859. ΓòÉΓòÉΓòÉ 4.116. frexp - Separate Floating-Point Value ΓòÉΓòÉΓòÉ
  12860.  
  12861.  
  12862. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12863.  
  12864. #include <math.h>
  12865. double frexp(double x, int *expptr);
  12866.  
  12867.  
  12868. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12869.  
  12870. Language Level: ANSI, SAA, POSIX, XPG4 
  12871.  
  12872. frexp breaks down the floating-point value x into a term m for the mantissa and 
  12873. another term n for the exponent, such that x = m * (2**n), and the absolute 
  12874. value of m is greater than or equal to 0.5 and less than 1.0 or equal to 0. 
  12875. frexp stores the integer exponent n at the location to which expptr points. 
  12876.  
  12877. Return Value 
  12878. frexp returns the mantissa term m.  If x is 0, frexp returns 0 for both the 
  12879. mantissa and exponent.  The mantissa has the same sign as the argument x.  The 
  12880. result of the frexp function cannot have a range error. 
  12881.  
  12882.  
  12883. ΓòÉΓòÉΓòÉ <hidden> Example of frexp ΓòÉΓòÉΓòÉ
  12884.  
  12885. /************************************************************************
  12886.  
  12887. This example decomposes the floating-point value of x, 16.4, into its mantissa 
  12888. 0.5125, and its exponent 5.  It stores the mantissa in y and the exponent in n. 
  12889.  
  12890. ************************************************************************/
  12891.  
  12892. #include <math.h>
  12893.  
  12894. int main(void)
  12895. {
  12896.    double x,m;
  12897.    int n;
  12898.  
  12899.    x = 16.4;
  12900.    m = frexp(x, &n);
  12901.    printf("The mantissa is %lf and the exponent is %d\n", m, n);
  12902.    return 0;
  12903.  
  12904.    /****************************************************************************
  12905.       The output should be:
  12906.  
  12907.       The mantissa is 0.512500 and the exponent is 5
  12908.    ****************************************************************************/
  12909. }
  12910.  
  12911.  
  12912. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  12913.  
  12914. Example of frexp 
  12915.  
  12916.      ldexp - Multiply by a Power of Two 
  12917.      modf - Separate Floating-Point Value 
  12918.      <math.h> 
  12919.  
  12920.  
  12921. ΓòÉΓòÉΓòÉ 4.117. fscanf - Read Formatted Data ΓòÉΓòÉΓòÉ
  12922.  
  12923.  
  12924. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  12925.  
  12926. #include <stdio.h>
  12927. int fscanf (FILE *stream, const char *format-string, argument-list);
  12928.  
  12929.  
  12930. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  12931.  
  12932. Language Level: ANSI, SAA, POSIX, XPG4, Extension 
  12933.  
  12934. fscanf reads data from the current position of the specified stream into the 
  12935. locations given by the entries in argument-list, if any.  Each entry in 
  12936. argument-list must be a pointer to a variable with a type that corresponds to a 
  12937. type specifier in format-string. 
  12938.  
  12939. The format-string controls the interpretation of the input fields and has the 
  12940. same form and function as the format-string argument for the scanf function. 
  12941. See scanf for a description of format-string. 
  12942.  
  12943. In extended mode, the fscanf function also reads in the strings "INFINITY", 
  12944. "INF", and "NAN" (in upper or lowercase) and converts them to the corresponding 
  12945. floating-point value.  The sign of the value is determined by the format 
  12946. specification. See Infinity and NaN Support for more information on infinity 
  12947. and NaN values. 
  12948.  
  12949. Return Value 
  12950. fscanf returns the number of fields that it successfully converted and 
  12951. assigned.  The return value does not include fields that fscanf read but did 
  12952. not assign. 
  12953.  
  12954. The return value is EOF if an input failure occurs before any conversion, or 
  12955. the number of input items assigned if successful. 
  12956.  
  12957.  
  12958. ΓòÉΓòÉΓòÉ <hidden> Example of fscanf ΓòÉΓòÉΓòÉ
  12959.  
  12960. /************************************************************************
  12961.  
  12962. This example opens the file myfile.dat for reading and then scans this file for 
  12963. a string, a long integer value, a character, and a floating-point value. 
  12964.  
  12965. ************************************************************************/
  12966.  
  12967. #include <stdio.h>
  12968.  
  12969. #define  MAX_LEN       80
  12970.  
  12971. int main(void)
  12972. {
  12973.    FILE *stream;
  12974.    long l;
  12975.    float fp;
  12976.    char s[MAX_LEN+1];
  12977.    char c;
  12978.  
  12979.    stream = fopen("myfile.dat", "r");
  12980.  
  12981.     /* Put in various data.                                                   */
  12982.  
  12983.    fscanf(stream, "%s", &s[0]);
  12984.    fscanf(stream, "%ld", &l);
  12985.    fscanf(stream, "%c", &c);
  12986.    fscanf(stream, "%f", &fp);
  12987.    printf("string = %s\n", s);
  12988.    printf("long double = %ld\n", l);
  12989.    printf("char = %c\n", c);
  12990.    printf("float = %f\n", fp);
  12991.    return 0;
  12992.  
  12993.    /****************************************************************************
  12994.       If myfile.dat contains:
  12995.       abcdefghijklmnopqrstuvwxyz 343.2.
  12996.  
  12997.       The output should be:
  12998.  
  12999.       string = abcdefghijklmnopqrstuvwxyz
  13000.       long double = 343
  13001.       char = .
  13002.       float = 2.000000
  13003.    ****************************************************************************/
  13004. }
  13005.  
  13006.  
  13007. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13008.  
  13009. Example of fscanf 
  13010.  
  13011.      Infinity and NaN Support 
  13012.      _cscanf - Read Data from Keyboard 
  13013.      fprintf - Write Formatted Data to a Stream 
  13014.      scanf - Read Data 
  13015.      sscanf - Read Data 
  13016.      <stdio.h> 
  13017.  
  13018.  
  13019. ΓòÉΓòÉΓòÉ 4.118. fseek - Reposition File Position ΓòÉΓòÉΓòÉ
  13020.  
  13021.  
  13022. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13023.  
  13024. #include <stdio.h>
  13025. int fseek(FILE *stream, long int offset, int origin);
  13026.  
  13027.  
  13028. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13029.  
  13030. Language Level: ANSI, SAA, POSIX, XPG4 
  13031.  
  13032. fseek changes the current file position associated with stream to a new 
  13033. location within the file. The next operation on the stream takes place at the 
  13034. new location.  On a stream open for update, the next operation can be either a 
  13035. reading or a writing operation. 
  13036.  
  13037. The origin must be one of the following constants defined in <stdio.h>: 
  13038.  
  13039.  Origin            Definition 
  13040.  SEEK_SET          Beginning of file 
  13041.  SEEK_CUR          Current position of file pointer 
  13042.  SEEK_END          End of file 
  13043.  
  13044.  For a binary stream, you can also change the position beyond the end of the 
  13045.  file.  An attempt to position before the beginning of the file causes an 
  13046.  error. If successful, fseek clears the end-of-file indicator, even when origin 
  13047.  is SEEK_END, and undoes the effect of any preceding ungetc function on the 
  13048.  same stream. 
  13049.  
  13050.  Note:  For streams opened in text mode, fseek has limited use because some 
  13051.  system translations (such as those between carriage-return-line-feed and new 
  13052.  line) can produce unexpected results.  The only fseek operations that can be 
  13053.  relied upon to work on streams opened in text mode are seeking with an offset 
  13054.  of zero relative to any of the origin values or seeking from the beginning of 
  13055.  the file with an offset value returned from a call to ftell. See the chapter 
  13056.  "Performing I/O Operations" in the Programming Guide for more information. 
  13057.  
  13058.  Return Value 
  13059.  fseek returns 0 if it successfully moves the pointer.  A nonzero return value 
  13060.  indicates an error.  On devices that cannot seek, such as terminals and 
  13061.  printers, the return value is nonzero. 
  13062.  
  13063.  
  13064. ΓòÉΓòÉΓòÉ <hidden> Example of fseek ΓòÉΓòÉΓòÉ
  13065.  
  13066. /************************************************************************
  13067.  
  13068. This example opens a file myfile.dat for reading. After performing input 
  13069. operations (not shown), fseek moves the file pointer to the beginning of the 
  13070. file. 
  13071.  
  13072. ************************************************************************/
  13073.  
  13074. #include <stdio.h>
  13075. #include <stdlib.h>
  13076.  
  13077. int main(void)
  13078. {
  13079.    FILE *stream;
  13080.    int result;
  13081.  
  13082.    stream = fopen("myfile.dat", "r");
  13083.  
  13084.    result = fseek(stream, 0L, SEEK_SET);   /* moves the pointer to the
  13085.                                               beginning of the file           */
  13086.  
  13087.    if (result)                           /* fail to move the pointer to the   */
  13088.       return EXIT_FAILURE;               /* beginning of the file             */
  13089.    fclose(stream);
  13090.    return 0;
  13091. }
  13092.  
  13093.  
  13094. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13095.  
  13096. Example of fseek 
  13097.  
  13098.      fgetpos - Get File Position 
  13099.      fsetpos - Set File Position 
  13100.      ftell - Get Current Position 
  13101.      rewind - Adjust Current File Position 
  13102.      ungetc - Push Character onto Input Stream 
  13103.      <stdio.h> 
  13104.  
  13105.  
  13106. ΓòÉΓòÉΓòÉ 4.119. fsetpos - Set File Position ΓòÉΓòÉΓòÉ
  13107.  
  13108.  
  13109. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13110.  
  13111. #include <stdio.h>
  13112. int fsetpos(FILE *stream, const fpos_t *pos);
  13113.  
  13114.  
  13115. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13116.  
  13117. Language Level: ANSI, SAA, XPG4 
  13118.  
  13119. fsetpos moves any file position associated with stream to a new location within 
  13120. the file according to the value pointed to by pos.  The value of pos was 
  13121. obtained by a previous call to the fgetpos library function. 
  13122.  
  13123. If successful, fsetpos clears the end-of-file indicator, and undoes the effect 
  13124. of any previous ungetc function on the same stream. 
  13125.  
  13126. After the fsetpos call, the next operation on a stream in update mode may be 
  13127. input or output. 
  13128.  
  13129. Return Value 
  13130. If fsetpos successfully changes the current position of the file, it returns 0. 
  13131. A nonzero return value indicates an error. 
  13132.  
  13133.  
  13134. ΓòÉΓòÉΓòÉ <hidden> Example of fsetpos ΓòÉΓòÉΓòÉ
  13135.  
  13136. /************************************************************************
  13137.  
  13138. This example opens a file myfile.dat for reading. After performing input 
  13139. operations (not shown), fsetpos moves the file pointer to the beginning of the 
  13140. file and rereads the first byte. 
  13141.  
  13142. ************************************************************************/
  13143.  
  13144. #include <stdio.h>
  13145.  
  13146. FILE *stream;
  13147.  
  13148. int main(void)
  13149. {
  13150.    int retcode;
  13151.    fpos_t pos,pos1,pos2,pos3;
  13152.    char ptr[20];           /* existing file 'myfile.dat' has 20 byte records  */
  13153.  
  13154.     /* Open file, get position of file pointer, and read first record         */
  13155.    stream = fopen("myfile.dat", "rb");
  13156.    fgetpos(stream, &pos);
  13157.    pos1 = pos;
  13158.    if (!fread(ptr, sizeof(ptr), 1, stream))
  13159.       perror("fread error");
  13160.  
  13161.     /* Perform a number of read operations - the value of 'pos' changes       */
  13162.     /* Re-set pointer to start of file and re-read first record               */
  13163.  
  13164.    fsetpos(stream, &pos1);
  13165.    if (!fread(ptr, sizeof(ptr), 1, stream))
  13166.       perror("fread error");
  13167.    fclose(stream);
  13168.    return 0;
  13169. }
  13170.  
  13171.  
  13172. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13173.  
  13174. Example of fsetpos 
  13175.  
  13176.      fgetpos - Get File Position 
  13177.      fseek - Reposition File Position 
  13178.      ftell - Get Current Position 
  13179.      rewind - Adjust Current File Position 
  13180.      ungetc - Push Character onto Input Stream 
  13181.      <stdio.h> 
  13182.  
  13183.  
  13184. ΓòÉΓòÉΓòÉ 4.120. _fsin - Calculate Sine ΓòÉΓòÉΓòÉ
  13185.  
  13186.  
  13187. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13188.  
  13189. #include <builtin.h>
  13190. double _fsin( double x);
  13191.  
  13192.  
  13193. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13194.  
  13195. Language Level:  Extension 
  13196.  
  13197. _fsin calculates the sine of x, where x is expressed in radians. The value of x 
  13198. must be less than 2**63. This function causes the compiler to emit the 
  13199. appropriate 80387 instruction for the calculation of sine. 
  13200.  
  13201. Because it is a built-in function and has no backing code in the library: 
  13202.  
  13203.      You cannot take the address of _fsin. 
  13204.      You cannot parenthesize a _fsin function call, because parentheses 
  13205.       specify a call to the backing code for the function in the library. 
  13206.  
  13207.  Return Value 
  13208.  This function returns the sine of a variable x expressed in radians. 
  13209.  
  13210.  
  13211. ΓòÉΓòÉΓòÉ <hidden> Example of _fsin ΓòÉΓòÉΓòÉ
  13212.  
  13213. /************************************************************************
  13214.  
  13215. This example calculates y as the sine of pi/2. 
  13216.  
  13217. ************************************************************************/
  13218.  
  13219. #include <builtin.h>
  13220. #include <stdio.h>
  13221.  
  13222. int main(void)
  13223. {
  13224.    double pi;
  13225.  
  13226.    pi = 3.1415926535;
  13227.    printf("The sine of %lf is %lf.\n", pi/2.0, _fsin(pi/2.0));
  13228.    return 0;
  13229.  
  13230.    /****************************************************************************
  13231.       The output should be :
  13232.  
  13233.       The sine of 1.570796 is 1.000000.
  13234.    ****************************************************************************/
  13235. }
  13236.  
  13237.  
  13238. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13239.  
  13240. Example of _fsin 
  13241.  
  13242.      _fasin - Calculate Arcsine 
  13243.      _fcossin - Calculate Cosine and Sine 
  13244.      _fsincos - Calculate Sine and Cosine 
  13245.      sin - Calculate Sine 
  13246.      sinh - Calculate Hyperbolic Sine 
  13247.      <builtin.h> 
  13248.  
  13249.  
  13250. ΓòÉΓòÉΓòÉ 4.121. _fsincos - Calculate Sine and Cosine ΓòÉΓòÉΓòÉ
  13251.  
  13252.  
  13253. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13254.  
  13255. #include <builtin.h>
  13256. double _fsincos(double x, double *y);
  13257.  
  13258.  
  13259. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13260.  
  13261. Language Level:  Extension 
  13262.  
  13263. _fsincos calculates the sine of x, and stores the cosine in *y. This operation 
  13264. is faster than separately calculating the sine and cosine. Use _fsincos instead 
  13265. of _fcossin when you will be using the sine first, and then the cosine. 
  13266.  
  13267. Because it is a built-in function and has no backing code in the library: 
  13268.  
  13269.      You cannot take the address of _fsincos. 
  13270.      You cannot parenthesize a _fsincos function call because parentheses 
  13271.       specify a call to the backing code for the function. 
  13272.  
  13273.  Return Value 
  13274.  This function returns the sine of x. 
  13275.  
  13276.  
  13277. ΓòÉΓòÉΓòÉ <hidden> Example of _fsincos ΓòÉΓòÉΓòÉ
  13278.  
  13279. /************************************************************************
  13280.  
  13281. This example calculates the sine of x and stores it in z, and stores the cosine 
  13282. of x in y. 
  13283.  
  13284. ************************************************************************/
  13285.  
  13286. #include <builtin.h>
  13287. #include <stdio.h>
  13288.  
  13289. int main(void)
  13290. {
  13291.    double x, y, z;
  13292.  
  13293.    printf("Enter x:\n");
  13294.    scanf("%lf", &x);
  13295.  
  13296.    z = _fsincos(x, &y);
  13297.    printf("The sine of %lf is %lf.\n", x, z);
  13298.    printf("The cosine of %lf is %lf.\n", x, y);
  13299.    return 0;
  13300.  
  13301.    /****************************************************************************
  13302.       Assuming you enter : 1.0
  13303.  
  13304.       The output should be :
  13305.  
  13306.       The sine of 1.000000 is 0.841471.
  13307.       The cosine of 1.000000 is 0.540302.
  13308.    ****************************************************************************/
  13309. }
  13310.  
  13311.  
  13312. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13313.  
  13314. Example of _fsincos 
  13315.  
  13316.      acos - Calculate Arccosine 
  13317.      asin - Calculate Arcsine 
  13318.      cos - Calculate Cosine 
  13319.      cosh - Calculate Hyperbolic Cosine 
  13320.      _facos - Calculate Arccosine 
  13321.      _fasin - Calculate Arcsine 
  13322.      _fcos - Calculate Cosine 
  13323.      _fcossin - Calculate Cosine and Sine 
  13324.      _fsin - Calculate Sine 
  13325.      sin - Calculate Sine 
  13326.      sinh - Calculate Hyperbolic Sine 
  13327.      <builtin.h> 
  13328.  
  13329.  
  13330. ΓòÉΓòÉΓòÉ 4.122. _fsqrt -  Calculate Square Root ΓòÉΓòÉΓòÉ
  13331.  
  13332.  
  13333. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13334.  
  13335. #include <builtin.h>
  13336. double _fsqrt(double x);
  13337.  
  13338.  
  13339. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13340.  
  13341. Language Level:  Extension 
  13342.  
  13343. _fsqrt computes the square root of x using the FSQRT 80387 instruction. Note 
  13344. that this function does not set errno as the sqrt function does. If you pass a 
  13345. negative value to this function, an exception is generated. 
  13346.  
  13347. Note:  _fsqrt is a built-in function, which means it is implemented as an 
  13348. inline instruction and has no backing code in the library. For this reason: 
  13349.  
  13350.      You cannot take the address of _fsqrt. 
  13351.      You cannot parenthesize a call to _fsqrt. (Parentheses specify a call to 
  13352.       the function's backing code, and _fsqrt has none.) 
  13353.  
  13354.  Return Value 
  13355.  _fsqrt returns the value of the square root of x. 
  13356.  
  13357.  
  13358. ΓòÉΓòÉΓòÉ <hidden> Example of _fsqrt ΓòÉΓòÉΓòÉ
  13359.  
  13360. /************************************************************************
  13361.  
  13362. This example calculates the square root of 4. 
  13363.  
  13364. ************************************************************************/
  13365.  
  13366. #include <builtin.h>
  13367. #include <stdio.h>
  13368.  
  13369. int main(void)
  13370. {
  13371.    double x;
  13372.  
  13373.    x = 4.0;
  13374.    printf("The square root of %lf is %lf.\n", x, _fsqrt(x));
  13375.    return 0;
  13376.  
  13377.    /****************************************************************************
  13378.       The output should be :
  13379.  
  13380.       The square root of 4.000000 is 2.000000.
  13381.    ****************************************************************************/
  13382. }
  13383.  
  13384.  
  13385. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13386.  
  13387. Example of _fsqrt 
  13388.  
  13389.      sqrt - Calculate Square Root 
  13390.      <math.h> 
  13391.  
  13392.  
  13393. ΓòÉΓòÉΓòÉ 4.123. fstat - Information about Open File ΓòÉΓòÉΓòÉ
  13394.  
  13395.  
  13396. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13397.  
  13398. #include <sys\stat.h>
  13399. #include <sys\types.h>
  13400. int fstat(int handle, struct stat *buffer);
  13401.  
  13402.  
  13403. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13404.  
  13405. Language Level:  XPG4, Extension 
  13406.  
  13407. fstat obtains information about the open file associated with the given handle 
  13408. and stores it in the structure to which buffer points.  The <sys\stat.h> 
  13409. include file defines the stat structure.  The stat structure contains the 
  13410. following fields: 
  13411.  
  13412.  Field       Value 
  13413.  
  13414.  st_mode     Bit mask for file mode information. fstat sets the S_IFCHR bit if 
  13415.              handle refers to a device. The S_IFDIR bit is set if pathname 
  13416.              specifies a directory. It sets the S_IFREG bit if handle refers to 
  13417.              an ordinary file.  It sets user read/write bits according to the 
  13418.              permission mode of the file. The other bits have undefined values. 
  13419.  
  13420.  st_dev      Drive number of the disk containing the file. 
  13421.  
  13422.  st_rdev     Drive number of the disk containing the file (same as st_dev). 
  13423.  
  13424.  st_nlink    Always 1. 
  13425.  
  13426.  st_size     Size of the file in bytes. 
  13427.  
  13428.  st_atime    Time of last access of file. 
  13429.  
  13430.  st_mtime    Time of last modification of file. 
  13431.  
  13432.  st_ctime    Time of file creation. 
  13433.  
  13434.  There are three additional fields in the stat structure for portability to 
  13435.  other operating systems; they have no meaning under the OS/2 operating system. 
  13436.  
  13437.  Note: 
  13438.  
  13439.    1. If the given handle refers to a device, the size and time fields in the 
  13440.       stat structure are not meaningful. 
  13441.  
  13442.    2. In earlier releases of C Set ++, fstat began with an underscore (_fstat). 
  13443.       Because it is defined by the X/Open standard, the underscore has been 
  13444.       removed. For compatibility, VisualAge C++ will map _fstat to fstat for 
  13445.       you. 
  13446.  
  13447.  Return Value 
  13448.  If it obtains the file status information, fstat returns 0. A return value of 
  13449.  -1 indicates an error, and fstat sets errno to EBADF, showing an incorrect 
  13450.  file handle. 
  13451.  
  13452.  
  13453. ΓòÉΓòÉΓòÉ <hidden> Example of fstat ΓòÉΓòÉΓòÉ
  13454.  
  13455. /************************************************************************
  13456.  
  13457. This example uses fstat to report the size of a file named data. 
  13458.  
  13459. ***********************************************************************(/
  13460.  
  13461. #include <time.h>
  13462. #include <sys\types.h>
  13463. #include <sys\stat.h>
  13464. #include <stdio.h>
  13465.  
  13466. int main(void)
  13467. {
  13468.    struct stat buf;
  13469.    FILE *fp;
  13470.    int fh,result;
  13471.    char *buffer = "A line to output";
  13472.  
  13473.    fp = fopen("data", "w+");
  13474.    fprintf(fp, "%s", buffer);
  13475.    fflush(fp);
  13476.    fclose(fp);
  13477.    fp = fopen("data", "r");
  13478.    if (0 == fstat(fileno(fp), &buf)) {
  13479.       printf("file size is %ld\n", buf.st_size);
  13480.       printf("time modified is %s\n", ctime(&buf.st_atime));
  13481.    }
  13482.    else
  13483.       printf("Bad file handle\n");
  13484.    fclose(fp);
  13485.    return 0;
  13486.  
  13487.    /****************************************************************************
  13488.       The output should be similar to:
  13489.  
  13490.       file size is 16
  13491.       time modified is Thu May 16 16:08:14 1995
  13492.    ****************************************************************************/
  13493. }
  13494.  
  13495.  
  13496. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13497.  
  13498. Example of fstat 
  13499.  
  13500.      stat - Get Information about File or Directory 
  13501.      <sys\stat.h> 
  13502.      <sys\types.h> 
  13503.  
  13504.  
  13505. ΓòÉΓòÉΓòÉ 4.124. ftell - Get Current Position ΓòÉΓòÉΓòÉ
  13506.  
  13507.  
  13508. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13509.  
  13510. #include <stdio.h>
  13511. long int ftell(FILE *stream);
  13512.  
  13513.  
  13514. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13515.  
  13516. Language Level: ANSI, SAA, POSIX, XPG4 
  13517.  
  13518. ftell finds the current position of the file associated with stream. For a 
  13519. fixed-length binary file, the value returned by ftell is an offset relative to 
  13520. the beginning of the stream. 
  13521.  
  13522. Note:  For buffered text streams, ftell returns an incorrect file position if 
  13523. the file contains new-line characters instead of carriage-return line-feed 
  13524. combinations.  Your file would only contain new-line characters if you 
  13525. previously used it as a binary stream.  To avoid this problem, either continue 
  13526. to process the file as a binary stream, or use unbuffered I/O operations. 
  13527.  
  13528. Return Value 
  13529.  
  13530. ftell returns the current file position. On error, ftell returns -1L and sets 
  13531. errno to a nonzero value. 
  13532.  
  13533.  
  13534. ΓòÉΓòÉΓòÉ <hidden> Example of ftell ΓòÉΓòÉΓòÉ
  13535.  
  13536. /************************************************************************
  13537.  
  13538. This example opens the file myfile.dat for reading. It reads enough characters 
  13539. to fill half of the buffer and prints out the position in the stream and the 
  13540. buffer. 
  13541.  
  13542. ************************************************************************/
  13543.  
  13544. #include <stdio.h>
  13545.  
  13546. #define  NUM_ALPHA     26
  13547. #define  NUM_CHAR      6
  13548.  
  13549. int main(void)
  13550. {
  13551.    FILE *stream;
  13552.    int i;
  13553.    char ch;
  13554.    char buffer[NUM_ALPHA];
  13555.    long position;
  13556.  
  13557.    if ((stream = fopen("myfile.dat", "r")) != NULL) {
  13558.  
  13559.      /* read into buffer                                                      */
  13560.  
  13561.       for (i = 0; (i < NUM_ALPHA/2) && ((buffer[i] = fgetc(stream)) != EOF);
  13562.            ++i)
  13563.          if (i == NUM_CHAR-1) { /* We want to be able to position the
  13564.                                    file pointer to the character in
  13565.                                    position NUM_CHAR                          */
  13566.  
  13567.             position = ftell(stream);
  13568.             printf("Current position of the file is stored.\n");
  13569.          }
  13570.       buffer[i] = '\0';
  13571.       fseek(stream, position, SEEK_SET);
  13572.       ch = fgetc(stream);       /* get the character at position NUM_CHAR     */
  13573.       fclose(stream);
  13574.    }
  13575.    else
  13576.       perror("Error opening myfile.dat");
  13577.    return 0;
  13578. }
  13579.  
  13580.  
  13581. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13582.  
  13583. Example of ftell 
  13584.  
  13585.      fseek - Reposition File Position 
  13586.      fgetpos - Get File Position 
  13587.      fopen - Open Files 
  13588.      fsetpos - Set File Position 
  13589.      <stdio.h> 
  13590.  
  13591.  
  13592. ΓòÉΓòÉΓòÉ 4.125. _ftime - Store Current Time ΓòÉΓòÉΓòÉ
  13593.  
  13594.  
  13595. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13596.  
  13597. #include <sys\timeb.h>
  13598. #include <sys\types.h>
  13599. void _ftime(struct timeb *timeptr);
  13600.  
  13601.  
  13602. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13603.  
  13604. Language Level:  Extension 
  13605.  
  13606. _ftime gets the current time and stores it in the structure to which timeptr 
  13607. points.  The <sys\timeb.h> include file contains        the definition of the 
  13608. timeb structure.  It contains four fields: 
  13609.  
  13610.  time      The time in seconds since 00:00:00 Coordinated Universal Time, 
  13611.            January 1, 1970. 
  13612.  millitm   The fraction of a second, in milliseconds. 
  13613.  timezone  The difference in minutes between Coordinated Universal Time and 
  13614.            local time, going from east to west. _ftime sets the value of 
  13615.            timezone from the value of the global variable _timezone. 
  13616.  dstflag   Nonzero if daylight saving time is currently in effect for the local 
  13617.            time zone. For an explanation of how daylight saving time is 
  13618.            determined, see tzset - Assign Values to Locale Information. 
  13619.  
  13620.  Return Value 
  13621.  There is no return value. 
  13622.  
  13623.  
  13624. ΓòÉΓòÉΓòÉ <hidden> Example of _ftime ΓòÉΓòÉΓòÉ
  13625.  
  13626. /************************************************************************
  13627.  
  13628. This example polls the system clock, converts the current time to a character 
  13629. string, prints the string, and saves the time data in the structure timebuffer. 
  13630.  
  13631. ************************************************************************/
  13632.  
  13633. #include <sys\types.h>
  13634. #include <sys\timeb.h>
  13635. #include <stdio.h>
  13636. #include <time.h>
  13637.  
  13638. int main(void)
  13639. {
  13640.    struct timeb timebuffer;
  13641.  
  13642.    _ftime(&timebuffer);
  13643.    printf("the time is %s\n", ctime(&(timebuffer.time)));
  13644.    return 0;
  13645.  
  13646.    /****************************************************************************
  13647.       The output should be similar to:
  13648.  
  13649.       the time is Thu May 16 16:08:17 1995
  13650.    ****************************************************************************/
  13651. }
  13652.  
  13653.  
  13654. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13655.  
  13656. Example of _ftime 
  13657.  
  13658.      asctime - Convert Time to Character String 
  13659.      ctime - Convert Time to Character String 
  13660.      gmtime - Convert Time 
  13661.      localtime - Convert Time 
  13662.      mktime - Convert Local Time 
  13663.      time - Determine Current Time 
  13664.      tzset - Assign Values to Locale Information 
  13665.      <sys\timeb.h> 
  13666.      <sys\types.h> 
  13667.  
  13668.  
  13669. ΓòÉΓòÉΓòÉ 4.126. _fullpath - Get Full Path Name of Partial Path ΓòÉΓòÉΓòÉ
  13670.  
  13671.  
  13672. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13673.  
  13674. #include <stdlib.h>
  13675. char *_fullpath(char *pathbuf, char *partialpath, size_t n);
  13676.  
  13677.  
  13678. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13679.  
  13680. Language Level:  Extension 
  13681.  
  13682. _fullpath gets the full path name of the given partial path name partialpath, 
  13683. and stores it in pathbuf. The integer argument n specifies the maximum length 
  13684. for the path name.  An error occurs if the length of the path name, including 
  13685. the terminating null character, exceeds n characters. 
  13686.  
  13687. If pathbuf is NULL, _fullpath uses malloc to allocate a buffer of size 
  13688. _MAX_PATH bytes to store the path name. 
  13689.  
  13690. Return Value 
  13691. _fullpath returns a pointer to pathbuf.  If an error occurs, _fullpath returns 
  13692. NULL and sets errno to one of the following values: 
  13693.  
  13694.  Value          Meaning 
  13695.  ENOMEM         Unable to allocate storage for the buffer. 
  13696.  ERANGE         The path name is longer than n characters. 
  13697.  EOS2ERR        A system error occurred.  Check _doserrno for the specific OS/2 
  13698.                 error code. 
  13699.  
  13700.  
  13701. ΓòÉΓòÉΓòÉ <hidden> Example of _fullpath ΓòÉΓòÉΓòÉ
  13702.  
  13703. /************************************************************************
  13704. This example uses _fullpath to get and store the full path name of the current 
  13705. directory. 
  13706.  
  13707. ************************************************************************/
  13708.  
  13709. #include <stdio.h>
  13710. #include <stdlib.h>
  13711. #include <errno.h>
  13712.  
  13713. int main(void)
  13714. {
  13715.    char *retBuffer;
  13716.  
  13717.    retBuffer = _fullpath(NULL, ".", 0);
  13718.    if (NULL == retBuffer) {
  13719.       printf("An error has occurred, errno is set to %d.\n", errno);
  13720.    }
  13721.    else
  13722.       printf("Full path name of current directory is %s.\n", retBuffer);
  13723.    return 0;
  13724.  
  13725.    /****************************************************************************
  13726.       The output should be similar to:
  13727.  
  13728.         Full path name of current directory is D:\BIN.
  13729.    ****************************************************************************/
  13730. }
  13731.  
  13732.  
  13733. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13734.  
  13735. Example of _fullpath 
  13736.  
  13737.      _getcwd - Get Path Name of Current Directory 
  13738.      _getdcwd - Get Full Path Name of Current Directory 
  13739.      _makepath - Create Path 
  13740.      malloc - Reserve Storage Block 
  13741.      _splitpath - Decompose Path Name 
  13742.      <stdlib.h> 
  13743.  
  13744.  
  13745. ΓòÉΓòÉΓòÉ 4.127. fwrite - Write Items ΓòÉΓòÉΓòÉ
  13746.  
  13747.  
  13748. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13749.  
  13750. #include <stdio.h>
  13751. size_t fwrite(const void *buffer, size_t size, size_t count,
  13752.                  FILE *stream);
  13753.  
  13754.  
  13755. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13756.  
  13757. Language Level: ANSI, SAA SAA, POSIX, XPG4 
  13758.  
  13759. fwrite writes up to count items, each of size bytes in length, from buffer to 
  13760. the output stream. 
  13761.  
  13762. Return Value 
  13763. fwrite returns the number of full items successfully written, which can be 
  13764. fewer than count if an error occurs. 
  13765.  
  13766.  
  13767. ΓòÉΓòÉΓòÉ <hidden> Example of fwrite ΓòÉΓòÉΓòÉ
  13768.  
  13769. /************************************************************************
  13770.  
  13771. This example writes NUM long integers to a stream in binary format. 
  13772.  
  13773. ************************************************************************/
  13774.  
  13775. #include <stdio.h>
  13776.  
  13777. #define  NUM           100
  13778.  
  13779. int main(void)
  13780. {
  13781.    FILE *stream;
  13782.    long list[NUM];
  13783.    int numwritten;
  13784.  
  13785.    stream = fopen("myfile.dat", "w+b");
  13786.  
  13787.               /* assign values to list[]                                      */
  13788.  
  13789.    numwritten = fwrite(list, sizeof(long), NUM, stream);
  13790.    printf("Number of items successfully written : %d\n", numwritten);
  13791.    return 0;
  13792.  
  13793.    /****************************************************************************
  13794.       The output should be:
  13795.  
  13796.       Number of items successfully written : 100
  13797.    ****************************************************************************/
  13798. }
  13799.  
  13800.  
  13801. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13802.  
  13803. Example of fwrite 
  13804.  
  13805.      fopen - Open Files 
  13806.      fread - Read Items 
  13807.      read - Read Into Buffer 
  13808.      write - Writes from Buffer to File 
  13809.      <stdio.h> 
  13810.  
  13811.  
  13812. ΓòÉΓòÉΓòÉ 4.128. _fyl2x - Calculate y * log2(x) ΓòÉΓòÉΓòÉ
  13813.  
  13814.  
  13815. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13816.  
  13817. #include <builtin.h>
  13818. double _fyl2x(double x, double y);
  13819.  
  13820.  
  13821. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13822.  
  13823. Language Level:  Extension 
  13824.  
  13825. _fyl2x computes the base-2 logarithm of x and multiplies it by y (y * log2(x)). 
  13826. The variable x cannot be negative. This instruction is designed with built-in 
  13827. multiplication to optimize the calculation of logarithms with arbitrary 
  13828. positive base: log b (x) = (log2(b)**-1) * log2(x) 
  13829.  
  13830. Because it is a built-in function and has no backing code in the library: 
  13831.  
  13832.      You cannot take the address of _fyl2x. 
  13833.      You cannot parenthesize a _fyl2x function call, because parentheses 
  13834.       specify a call to the backing code for the function in the library. 
  13835.  
  13836.  Return Value 
  13837.  _fyl2x returns the result of the formula y * log2(x). 
  13838.  
  13839.  
  13840. ΓòÉΓòÉΓòÉ <hidden> Example of _fyl2x ΓòÉΓòÉΓòÉ
  13841.  
  13842. /************************************************************************
  13843.  
  13844. This example calculates (y * log2(x)), after prompting the user for values of x 
  13845. and y. 
  13846.  
  13847. ************************************************************************/
  13848.  
  13849. #include <builtin.h>
  13850. #include <stdio.h>
  13851.  
  13852. int main(void)
  13853. {
  13854.    double x, y;
  13855.  
  13856.    printf("Enter a value for x:\n");
  13857.    scanf("%lf", &x);
  13858.    printf("Enter a value for y:\n");
  13859.    scanf("%lf", &y);
  13860.    printf("%lf * log2(%lf) is %lf.\n", y, x, _fyl2x(x, y));
  13861.    return 0;
  13862.  
  13863.    /****************************************************************************
  13864.       Assuming you enter 4.0 for x and 3.0 for y.
  13865.  
  13866.       The output should be :
  13867.  
  13868.       3.000000 * log2(4.000000) is 6.000000.
  13869.    ****************************************************************************/
  13870. }
  13871.  
  13872.  
  13873. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13874.  
  13875. Example of _fyl2x 
  13876.  
  13877.      _fyl2xp1 -  Calculate y * log2(x + 1) 
  13878.      _f2xm1 -  Calculate (2**x) - 1 
  13879.      <builtin.h> 
  13880.  
  13881.  
  13882. ΓòÉΓòÉΓòÉ 4.129. _fyl2xp1 -  Calculate y * log2(x + 1) ΓòÉΓòÉΓòÉ
  13883.  
  13884.  
  13885. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13886.  
  13887. #include <builtin.h>
  13888. double _fyl2xp1(double x, double y);
  13889.  
  13890.  
  13891. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13892.  
  13893. Language Level:  Extension 
  13894.  
  13895. _fyl2xp1 computes the base-2 logarithm of x+1 and multiplies it by y (y * 
  13896. log2(x+1)). The variable x must be in the range -(1-(sqrt(2)/2)) to (sqrt(2) - 
  13897. 1). _fyl2xp1 provides improved accuracy over _fyl2x when logarithms of numbers 
  13898. very close to 1 are computed. When x is small, you can retain more significant 
  13899. digits by providing x to the _fyl2xp1 function than by providing x+1 as an 
  13900. argument to the _fyl2x function. 
  13901.  
  13902. Because it is a built-in function and has no backing code in the library: 
  13903.  
  13904.      You cannot take the address of _fyl2xp1. 
  13905.      You cannot parenthesize a _fyl2xp1 function call, because parentheses 
  13906.       specify a call to the backing code for the function in the library. 
  13907.  
  13908.  Return Value 
  13909.  _fyl2xp1 returns the result of the formula y * log2(x+1). 
  13910.  
  13911.  
  13912. ΓòÉΓòÉΓòÉ <hidden> Example of _fyl2xp1 ΓòÉΓòÉΓòÉ
  13913.  
  13914. /************************************************************************
  13915.  
  13916. This example calculates (y * log2(x + 1)), after prompting the user for values 
  13917. of x and y. 
  13918.  
  13919. ************************************************************************/
  13920.  
  13921. #include <builtin.h>
  13922. #include <stdio.h>
  13923.  
  13924. int main(void)
  13925. {
  13926.    double x, y;
  13927.  
  13928.    printf("Enter a value for x:\n");
  13929.    scanf("%lf", &x);
  13930.    printf("Enter a value for y:\n");
  13931.    scanf("%lf", &y);
  13932.    printf("%lf * log2(%lf + 1) is %lf.\n", y, x, _fyl2xp1(x, y));
  13933.    return 0;
  13934.  
  13935.    /****************************************************************************
  13936.       Assuming you enter 0.001 for x and 2.0 for y.
  13937.  
  13938.       The output should be :
  13939.  
  13940.       2.000000 * log2(0.001000 + 1) is 0.002884.
  13941.    ****************************************************************************/
  13942. }
  13943.  
  13944.  
  13945. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  13946.  
  13947. Example of _fyl2xp1 
  13948.  
  13949.      _fyl2x - Calculate y * log2(x) 
  13950.      _f2xm1 -  Calculate (2**x) - 1 
  13951.      <builtin.h> 
  13952.  
  13953.  
  13954. ΓòÉΓòÉΓòÉ 4.130. _f2xm1 -  Calculate (2**x) - 1 ΓòÉΓòÉΓòÉ
  13955.  
  13956.  
  13957. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  13958.  
  13959. #include <builtin.h>
  13960. double _f2xm1(double x);
  13961.  
  13962.  
  13963. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  13964.  
  13965. Language Level:  Extension 
  13966.  
  13967. _f2xm1 calculates 2 raised to the power of x, minus 1 ((2**x)-1). The variable 
  13968. x must be in the range -1 to 1. This instruction is designed to produce very 
  13969. accurate results when x is close to 0. Large errors may occur for operands with 
  13970. magnitudes close to 1. You can exponentiate values other than 2 by using the 
  13971. formula x**y = 2**(y * log2(x)). 
  13972.  
  13973. Because it is a built-in function and has no backing code in the library: 
  13974.  
  13975.      You cannot take the address of _f2xm1. 
  13976.      You cannot parenthesize a _f2xm1 function call, because parentheses 
  13977.       specify a call to the backing code for the function in the library. 
  13978.  
  13979.  Return Value 
  13980.  This function returns the value of the formula (2**x)-1. 
  13981.  
  13982.  
  13983. ΓòÉΓòÉΓòÉ <hidden> Example of _f2xm1 ΓòÉΓòÉΓòÉ
  13984.  
  13985. /************************************************************************
  13986.  
  13987. This example calculates (2**x)-1 after prompting the user for a value for x. 
  13988.  
  13989. ************************************************************************/
  13990.  
  13991. #include <builtin.h>
  13992. #include <stdio.h>
  13993.  
  13994. int main(void)
  13995. {
  13996.    double x;
  13997.  
  13998.    printf("Enter a value for x:\n");
  13999.    scanf("%lf", &x);
  14000.    printf("(2**(%lf)) - 1 is %lf.\n", x, _f2xm1(x));
  14001.    return 0;
  14002.  
  14003.    /****************************************************************************
  14004.       Assuming you enter : 0.001
  14005.  
  14006.       The output should be :
  14007.  
  14008.       (2**(0.001000)) - 1 is 0.000693.
  14009.    ****************************************************************************/
  14010. }
  14011.  
  14012.  
  14013. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14014.  
  14015. Example of _f2xm1 
  14016.  
  14017.      _fyl2x - Calculate y * log2(x) 
  14018.      _fyl2xp1 -  Calculate y * log2(x + 1) 
  14019.      <builtin.h> 
  14020.  
  14021.  
  14022. ΓòÉΓòÉΓòÉ 4.131. gamma - Gamma Function ΓòÉΓòÉΓòÉ
  14023.  
  14024.  
  14025. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14026.  
  14027. #include <math.h> /* SAA extension to ANSI */
  14028. double gamma(double x);
  14029.  
  14030.  
  14031. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14032.  
  14033. Language Level: SAA 
  14034.  
  14035. gamma computes ln( |G(x)| ). 
  14036.  
  14037. Portability Note  According to the SAA standard, x must be a positive real 
  14038. value.  Under the VisualAge C++ compiler, x can also be a negative integer. 
  14039.  
  14040. Return Value 
  14041. gamma returns the value of ln(|G(x)|). If x is a negative value, errno is set 
  14042. to EDOM. If the result causes an overflow, gamma returns HUGE_VAL and sets 
  14043. errno to ERANGE. 
  14044.  
  14045.  
  14046. ΓòÉΓòÉΓòÉ <hidden> Example of gamma ΓòÉΓòÉΓòÉ
  14047.  
  14048. /************************************************************************
  14049.  
  14050. This example uses gamma to calculate ln(|G(x)|), where x = 42. 
  14051.  
  14052. ************************************************************************/
  14053.  
  14054. #include <math.h>
  14055. #include <stdio.h>
  14056.  
  14057. int main(void)
  14058. {
  14059.    double x = 42,g_at_x;
  14060.  
  14061.    g_at_x = exp(gamma(x));                       /* g_at_x = 3.345253e+49     */
  14062.    printf("The value of G(%4.2f) is %7.2e\n", x, g_at_x);
  14063.    return 0;
  14064.  
  14065.    /****************************************************************************
  14066.       The output should be:
  14067.  
  14068.       The value of G(42.00) is 3.35e+49
  14069.    ****************************************************************************/
  14070. }
  14071.  
  14072.  
  14073. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14074.  
  14075. Example of gamma 
  14076.  
  14077.      Bessel Functions - Solve Differential Equations 
  14078.      erf - erfc - Calculate Error Functions 
  14079.      <math.h> 
  14080.  
  14081.  
  14082. ΓòÉΓòÉΓòÉ 4.132. _gcvt - Convert Floating-Point to String ΓòÉΓòÉΓòÉ
  14083.  
  14084.  
  14085. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14086.  
  14087. #include <stdlib.h>
  14088. char *_gcvt(double value, int ndec, char *buffer);
  14089.  
  14090.  
  14091. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14092.  
  14093. Language Level:  Extension 
  14094.  
  14095. _gcvt converts a floating-point value to a character string pointed to by 
  14096. buffer. The buffer should be large enough to hold the converted value and a 
  14097. null character (\0) that _gcvt automatically adds to the end of the string. 
  14098. There is no provision for overflow. 
  14099.  
  14100. _gcvt tries to produce ndec significant digits in FORTRAN F format. Failing 
  14101. that, it produces ndec significant digits in FORTRAN E format. Trailing zeros 
  14102. might be suppressed in the conversion if they are significant. 
  14103.  
  14104. A FORTRAN F number has the following format: 
  14105.  
  14106. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  14107. Γöé                                        Γöé
  14108. Γöé       ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ   ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ                    Γöé
  14109. Γöé           Γöé         Γöé                    Γöé
  14110. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇdigitΓöÇΓö┤ΓöÇΓöÇ.ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö┤ΓöÇΓöÇ><                  Γöé
  14111. Γöé   Γö£ΓöÇ+ΓöÇΓöñ          ΓööΓöÇdigitΓöÇΓöÿ                     Γöé
  14112. Γöé   ΓööΓöÇΓö┤ΓöÇΓöÿ                                   Γöé
  14113. Γöé                                        Γöé
  14114. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  14115.  
  14116. A FORTRAN E number has the following format: 
  14117.  
  14118. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  14119. Γöé                                        Γöé
  14120. Γöé            ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ          ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ        Γöé
  14121. Γöé                Γöé                Γöé        Γöé
  14122. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitΓöÇΓöÇ.ΓöÇΓöÇΓöÇΓöÇdigitΓöÇΓö┤ΓöÇΓöÇEΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö┤ΓöÇΓöÇ><      Γöé
  14123. Γöé   Γö£ΓöÇ+ΓöÇΓöñ              Γö£ΓöÇ+ΓöÇΓöñ      ΓööΓöÇdigitΓöÇΓöÿ         Γöé
  14124. Γöé   ΓööΓöÇΓö┤ΓöÇΓöÿ              ΓööΓöÇΓö┤ΓöÇΓöÿ                   Γöé
  14125. Γöé                                        Γöé
  14126. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  14127.  
  14128. _gcvt also converts NaN and infinity values to the strings NAN and INFINITY, 
  14129. respectively. For more information on NaN and infinity values, see Infinity and 
  14130. NaN Support. 
  14131.  
  14132. Warning: For each thread, _ecvt, _fcvt and _gcvt use a single, dynamically 
  14133. allocated buffer for the conversion. Any subsequent call that the same thread 
  14134. makes to these functions destroys the result of the previous call. 
  14135.  
  14136. Return Value 
  14137. _gcvt returns a pointer to the string of digits. If it cannot allocate memory 
  14138. to perform the conversion, _gcvt returns an empty string and sets errno to 
  14139. ENOMEM. 
  14140.  
  14141.  
  14142. ΓòÉΓòÉΓòÉ <hidden> Example of _gcvt ΓòÉΓòÉΓòÉ
  14143.  
  14144. /************************************************************************
  14145.  
  14146. This example converts the value -3.1415e3 to a character string and places it 
  14147. in the character array buffer1. It then converts the macro value _INF to a 
  14148. character string and places it in buffer2. 
  14149.  
  14150. ************************************************************************/
  14151.  
  14152. #include <stdio.h>
  14153. #include <stdlib.h>
  14154. #include <float.h>                  /* for the definition of _INF             */
  14155.  
  14156. int main(void)
  14157. {
  14158.    char buffer1[10],buffer2[10];
  14159.  
  14160.    _gcvt(-3.1415e3, 7, buffer1);
  14161.    printf("The first result is %s \n", buffer1);
  14162.    _gcvt(_INF, 5, buffer2);
  14163.    printf("The second result is %s \n", buffer2);
  14164.    return 0;
  14165.  
  14166.    /****************************************************************************
  14167.       The output should be:
  14168.  
  14169.       The first result is -3141.5
  14170.       The second result is INFINITY
  14171.    ****************************************************************************/
  14172. }
  14173.  
  14174.  
  14175. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14176.  
  14177. Example of _gcvt 
  14178.  
  14179.      _ecvt - Convert Floating-Point to Character 
  14180.      _fcvt - Convert Floating-Point to String 
  14181.      Infinity and NaN Support 
  14182.      <stdlib.h> 
  14183.  
  14184.  
  14185. ΓòÉΓòÉΓòÉ 4.133. getc - getchar - Read a Character ΓòÉΓòÉΓòÉ
  14186.  
  14187.  
  14188. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14189.  
  14190. #include <stdio.h>
  14191. int getc(FILE *stream);
  14192. int getchar(void);
  14193.  
  14194.  
  14195. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14196.  
  14197. Language Level: ANSI, SAA, POSIX, XPG4 
  14198.  
  14199. getc reads a single character from the current stream position and advances the 
  14200. stream position to the next character. getchar is identical to getc(stdin). 
  14201.  
  14202. getc is equivalent to fgetc except that, if it is implemented as a macro, getc 
  14203. can evaluate stream more than once. Therfore, the stream argument to getc 
  14204. should not be an expression with side effects. 
  14205.  
  14206. Return Value 
  14207. getc and getchar return the character read.  A return value of EOF indicates an 
  14208. error or end-of-file condition. Use ferror or feof to determine whether an 
  14209. error or an end-of-file condition occurred. 
  14210.  
  14211.  
  14212. ΓòÉΓòÉΓòÉ <hidden> Example of getc - getchar ΓòÉΓòÉΓòÉ
  14213.  
  14214. /************************************************************************
  14215.  
  14216. This example gets a line of input from the stdin stream.  You can also use 
  14217. getc(stdin) instead of getchar() in the for statement to get a line of input 
  14218. from stdin. 
  14219.  
  14220. ************************************************************************/
  14221.  
  14222. #include <stdio.h>
  14223.  
  14224. #define  LINE          80
  14225.  
  14226. int main(void)
  14227. {
  14228.    char buffer[LINE+1];
  14229.    int i;
  14230.    int ch;
  14231.  
  14232.    printf("Please enter string\n");
  14233.  
  14234.    /* Keep reading until either:
  14235.       1. the length of LINE is exceeded  or
  14236.       2. the input character is EOF  or
  14237.       3. the input character is a newline character
  14238.                                                                               */
  14239.  
  14240.    for (i = 0; (i < LINE) && ((ch = getchar()) != EOF) && (ch != '\n'); ++i)
  14241.       buffer[i] = ch;
  14242.    buffer[i] = '\0';         /* a string should always end with '\0' !        */
  14243.    printf("The string is %s\n", buffer);
  14244.    return 0;
  14245.  
  14246.    /****************************************************************************
  14247.       The output should be similar to:
  14248.  
  14249.       Please enter string
  14250.       hello world
  14251.       The string is hello world
  14252.    ****************************************************************************/
  14253. }
  14254.  
  14255.  
  14256. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14257.  
  14258. Example of getc - getchar 
  14259.  
  14260.      fgetc - Read a Character 
  14261.      _fgetchar - Read Single Character from stdin 
  14262.      _getch - _getche - Read Character from Keyboard 
  14263.      putc - putchar - Write a Character 
  14264.      ungetc - Push Character onto Input Stream 
  14265.      gets - Read a Line 
  14266.      <stdio.h> 
  14267.  
  14268.  
  14269. ΓòÉΓòÉΓòÉ 4.134. _getch - _getche - Read Character from Keyboard ΓòÉΓòÉΓòÉ
  14270.  
  14271.  
  14272. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14273.  
  14274. #include <conio.h>
  14275. int _getch(void);
  14276. int _getche(void);
  14277.  
  14278.  
  14279. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14280.  
  14281. Language Level:  Extension 
  14282.  
  14283. _getch reads a single character from the keyboard, without echoing.  _getche 
  14284. reads a single character from the keyboard and displays the character read. 
  14285. Neither function can be used to read Ctrl-Break. 
  14286.  
  14287. You can use _kbhit to test if a keystroke is waiting in the buffer. If you call 
  14288. _getch or _getche without first calling _kbhit, the program waits for a key to 
  14289. be pressed. 
  14290.  
  14291. Return Value 
  14292. _getch and _getche return the character read. To read a function key or 
  14293. cursor-moving key, you must call _getch and _getche twice; the first call 
  14294. returns 0 or E0H, and the second call returns the particular extended key code. 
  14295.  
  14296.  
  14297. ΓòÉΓòÉΓòÉ <hidden> Example of _getch - _getche ΓòÉΓòÉΓòÉ
  14298.  
  14299. /************************************************************************
  14300.  
  14301. This example gets characters from the keyboard until it finds the character 
  14302. 'x'. 
  14303.  
  14304. ************************************************************************/
  14305.  
  14306. #include <conio.h>
  14307. #include <stdio.h>
  14308.  
  14309. int main(void)
  14310. {
  14311.    int ch;
  14312.  
  14313.    printf("Type in some letters.\n");
  14314.    printf("If you type in an 'x', the program ends.\n");
  14315.    for (; ; ) {
  14316.       ch = _getch();
  14317.       if ('x' == ch) {
  14318.          _ungetch(ch);
  14319.          break;
  14320.       }
  14321.       _putch(ch);
  14322.    }
  14323.    ch = _getch();
  14324.    printf("\nThe last character was '%c'.", ch);
  14325.    return 0;
  14326.  
  14327.    /****************************************************************************
  14328.       Here is the output from a sample run:
  14329.  
  14330.       Type in some letters.
  14331.       If you type in an 'x', the program ends.
  14332.       One Two Three Four Five Si
  14333.       The last character was 'x'.
  14334.    ****************************************************************************/
  14335. }
  14336.  
  14337.  
  14338. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14339.  
  14340. Example of _getch - _getche 
  14341.  
  14342.      _cgets - Read String of Characters from Keyboard 
  14343.      fgetc - Read a Character 
  14344.      getc - getchar - Read a Character 
  14345.      _kbhit - Test for Keystroke 
  14346.      _putch - Write Character to Screen 
  14347.      _ungetch - Push Character Back to Keyboard 
  14348.      <conio.h> 
  14349.  
  14350.  
  14351. ΓòÉΓòÉΓòÉ 4.135. _getcwd - Get Path Name of Current Directory ΓòÉΓòÉΓòÉ
  14352.  
  14353.  
  14354. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14355.  
  14356. #include <direct.h>
  14357. char *_getcwd(char *pathbuf, int n);
  14358.  
  14359.  
  14360. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14361.  
  14362. Language Level:  Extension 
  14363.  
  14364. _getcwd gets the full path name of the current working directory and stores it 
  14365. in the buffer pointed to by pathbuf.  The integer argument n specifies the 
  14366. maximum length for the path name.  An error occurs if the length of the path 
  14367. name, including the terminating null character, exceeds n characters. 
  14368.  
  14369. If the pathbuf argument is NULL, _getcwd uses malloc to reserve a buffer of at 
  14370. least n bytes to store the path name.  If the current working directory string 
  14371. is more than n bytes, a large enough buffer will be allocated to contain the 
  14372. string.  You can later free this buffer using the _getcwd return value as the 
  14373. argument to free. 
  14374.  
  14375. Return Value 
  14376. _getcwd returns pathbuf. If an error occurs, _getcwd returns NULL and sets 
  14377. errno to one of the following values: 
  14378.  
  14379.  Value       Meaning 
  14380.  ENOMEM      Not enough storage space available to reserve n bytes (when 
  14381.              pathbuf is NULL). 
  14382.  ERANGE      The path name is longer than n characters. 
  14383.  EOS2ERR     An OS/2 call failed. Use _doserrno to obtain more information 
  14384.              about the return code. 
  14385.  
  14386.  
  14387. ΓòÉΓòÉΓòÉ <hidden> Example of _getcwd ΓòÉΓòÉΓòÉ
  14388.  
  14389. /************************************************************************
  14390.  
  14391. This example stores the name of the current working directory (up to _MAX_PATH 
  14392. characters) in a buffer.  The value of _MAX_PATH is defined in <stdlib.h>. 
  14393.  
  14394. ************************************************************************/
  14395.  
  14396. #include <direct.h>
  14397. #include <stdio.h>
  14398. #include <stdlib.h>
  14399.  
  14400. int main(void)
  14401. {
  14402.    char buffer[_MAX_PATH];
  14403.  
  14404.    if (NULL == getcwd(buffer, _MAX_PATH))
  14405.       perror("getcwd error");
  14406.    printf("The current directory is %s.\n", buffer);
  14407.    return 0;
  14408.  
  14409.    /****************************************************************************
  14410.       The output should be similar to:
  14411.  
  14412.       The current directory is E:\C_OS2\MIG_XMPS
  14413.    ****************************************************************************/
  14414. }
  14415.  
  14416.  
  14417. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14418.  
  14419. Example of _getcwd 
  14420.  
  14421.      chdir - Change Current Working Directory 
  14422.      _fullpath - Get Full Path Name of Partial Path 
  14423.      _getdcwd - Get Full Path Name of Current Directory 
  14424.      _getdrive - Get Current Working Drive 
  14425.      malloc - Reserve Storage Block 
  14426.      <direct.h> 
  14427.  
  14428.  
  14429. ΓòÉΓòÉΓòÉ 4.136. _getdcwd - Get Full Path Name of Current Directory ΓòÉΓòÉΓòÉ
  14430.  
  14431.  
  14432. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14433.  
  14434. #include <direct.h>
  14435. char *_getdcwd(int drive, char *pathbuf, int n);
  14436.  
  14437.  
  14438. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14439.  
  14440. Language Level:  Extension 
  14441.  
  14442. _getdcwd gets the full path name for the current directory of the specified 
  14443. drive, and stores it in the location pointed to by pathbuf. The drive argument 
  14444. is an integer value representing the drive (A: is 1, B: is 2, and so on). 
  14445.  
  14446. The integer argument n specifies the maximum length for the path name. An error 
  14447. occurs if the length of the path name, including the terminating null 
  14448. character, exceeds n characters. 
  14449.  
  14450. If the pathbuf argument is NULL, _getdcwd uses malloc to reserve a buffer of at 
  14451. least n bytes to store the path name.  If the current working directory string 
  14452. is more than n bytes, a large enough buffer will be allocated to contain the 
  14453. string. You can later free this buffer using the _getdcwd return value as the 
  14454. argument to free. 
  14455.  
  14456. Alternatives to this function are the DosQueryCurrentDir and 
  14457. DosQueryCurrentDisk API calls. 
  14458.  
  14459. Return Value 
  14460. _getdcwd returns pathbuf. If an error occurs, _getdcwd returns NULL and sets 
  14461. errno to one of the following values: 
  14462.  
  14463.  Value          Meaning 
  14464.  ENOMEM         Not enough storage space available to reserve n bytes (when 
  14465.                 pathbuf is NULL). 
  14466.  ERANGE         The path name is longer than n characters. 
  14467.  EOS2ERR        An OS/2 call failed. Use _doserrno to obtain more information 
  14468.                 about the return code. 
  14469.  
  14470.  
  14471. ΓòÉΓòÉΓòÉ <hidden> Example of _getdcwd ΓòÉΓòÉΓòÉ
  14472.  
  14473. /************************************************************************
  14474.  
  14475. This example uses _getdcwd to obtain the current working directory of drive C. 
  14476.  
  14477. ************************************************************************/
  14478.  
  14479. #include <stdio.h>
  14480. #include <direct.h>
  14481. #include <errno.h>
  14482.  
  14483. int main(void)
  14484. {
  14485.    char *retBuffer;
  14486.  
  14487.    retBuffer = _getdcwd(3, NULL, 0);
  14488.    if (NULL == retBuffer)
  14489.       printf("An error has occurred, errno is set to %d.\n", errno);
  14490.    else
  14491.       printf("%s is the current working directory in drive C.\n", retBuffer);
  14492.    return 0;
  14493.  
  14494.    /****************************************************************************
  14495.       The output should be similar to:
  14496.  
  14497.       C:\ is the current working directory in drive C.
  14498.    ****************************************************************************/
  14499. }
  14500.  
  14501.  
  14502. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14503.  
  14504. Example of _getdcwd 
  14505.  
  14506.      chdir - Change Current Working Directory 
  14507.      _chdrive - Change Current Working Drive 
  14508.      _fullpath - Get Full Path Name of Partial Path 
  14509.      _getcwd - Get Path Name of Current Directory 
  14510.      _getdrive - Get Current Working Drive 
  14511.      malloc - Reserve Storage Block 
  14512.      <direct.h> 
  14513.  
  14514.  
  14515. ΓòÉΓòÉΓòÉ 4.137. _getdrive - Get Current Working Drive ΓòÉΓòÉΓòÉ
  14516.  
  14517.  
  14518. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14519.  
  14520. #include <direct.h>
  14521. int _getdrive(void);
  14522.  
  14523.  
  14524. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14525.  
  14526. Language Level:  Extension 
  14527.  
  14528. _getdrive gets the drive number for the current working drive. 
  14529.  
  14530. An alternative to this function is the DosQueryCurrentDisk API call. 
  14531.  
  14532. Return Value 
  14533. _getdrive returns an integer corresponding to alphabetical position of the 
  14534. letter representing the current working drive. For example, A: is 1, B: is 2, 
  14535. J: is 10, and so on. 
  14536.  
  14537.  
  14538. ΓòÉΓòÉΓòÉ <hidden> Example of _getdrive ΓòÉΓòÉΓòÉ
  14539.  
  14540. /************************************************************************
  14541.  
  14542. This example gets and prints the current working drive number. 
  14543.  
  14544. ************************************************************************/
  14545.  
  14546. #include <stdio.h>
  14547. #include <direct.h>
  14548.  
  14549. int main(void)
  14550. {
  14551.    printf("Current working drive is %d.\n", _getdrive());
  14552.    return 0;
  14553.  
  14554.    /****************************************************************************
  14555.       The output should be similar to:
  14556.  
  14557.       Current working drive is 5.
  14558.    ****************************************************************************/
  14559. }
  14560.  
  14561.  
  14562. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14563.  
  14564. Example of _getdrive 
  14565.  
  14566.      chdir - Change Current Working Directory 
  14567.      _chdrive - Change Current Working Drive 
  14568.      _getcwd - Get Path Name of Current Directory 
  14569.      _getdcwd - Get Full Path Name of Current Directory 
  14570.      <direct.h> 
  14571.  
  14572.  
  14573. ΓòÉΓòÉΓòÉ 4.138. getenv - Search for Environment Variables ΓòÉΓòÉΓòÉ
  14574.  
  14575.  
  14576. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14577.  
  14578. #include <stdlib.h>
  14579. char *getenv(const char *varname);
  14580.  
  14581.  
  14582. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14583.  
  14584. Language Level: ANSI, SAA, POSIX, XPG4 
  14585.  
  14586. getenv searches the list of environment variables for an entry corresponding to 
  14587. varname. 
  14588.  
  14589. Return Value 
  14590. getenv returns a pointer to the environment table entry containing the current 
  14591. string value of varname.  The return value is NULL if the given variable is not 
  14592. currently defined or if the system does not support environment variables. 
  14593.  
  14594. You should copy the string that is returned because it may be written over by a 
  14595. subsequent call to getenv. 
  14596.  
  14597.  
  14598. ΓòÉΓòÉΓòÉ <hidden> Example of getenv ΓòÉΓòÉΓòÉ
  14599.  
  14600. /************************************************************************
  14601.  
  14602. In this example, pathvar points to the value of the PATH environment variable. 
  14603.  
  14604. ************************************************************************/
  14605.  
  14606. #include <stdlib.h>
  14607.  
  14608. int main(void)
  14609. {
  14610.    char *pathvar;
  14611.  
  14612.    pathvar = getenv("PATH");
  14613.    if (NULL == pathvar)
  14614.       printf("Environment variable PATH is not defined.\n");
  14615.    else
  14616.       printf("Path set by environment variable PATH is successfully stored.\n");
  14617.    return 0;
  14618.  
  14619.    /****************************************************************************
  14620.       The output should be:
  14621.  
  14622.       Path set by environment variable PATH is successfully stored.
  14623.    ****************************************************************************/
  14624. }
  14625.  
  14626.  
  14627. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14628.  
  14629. Example of getenv 
  14630.  
  14631.      putenv - Modify Environment Variables 
  14632.      <stdlib.h> 
  14633.  
  14634.  
  14635. ΓòÉΓòÉΓòÉ 4.139. getmccoll - Get Next Collating Element from String ΓòÉΓòÉΓòÉ
  14636.  
  14637.  
  14638. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14639.  
  14640. #include <collate.h>
  14641. collel_t getmccoll(char **src)
  14642.  
  14643.  
  14644. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14645.  
  14646. Language Level:  Extension 
  14647.  
  14648. getmccoll finds the first sequence of characters in the array pointed to by src 
  14649. that constitute a valid multicharacter collating element. It then produces the 
  14650. collel_t value that corresponds to that collating element. It also changes src 
  14651. to point to the next byte following that collating element. 
  14652.  
  14653. Return Value 
  14654. getmccoll returns the collel_t value that represents the collating element 
  14655. found. If the object pointed to by src is a null pointer or points to a null 
  14656. character, getmccoll returns 0. 
  14657.  
  14658.  
  14659. ΓòÉΓòÉΓòÉ <hidden> Example of getmccoll ΓòÉΓòÉΓòÉ
  14660.  
  14661. /************************************************************************
  14662.  
  14663. This example uses getmccoll to find the first collating element in the string 
  14664. "de xyz" in the France locale. 
  14665.  
  14666. ************************************************************************/
  14667.  
  14668. #include <stdio.h>
  14669. #include <locale.h>
  14670. #include <collate.h>
  14671.  
  14672. int main(void)
  14673. {
  14674.    char     s[] = "de xyz";
  14675.    char     *str = s;
  14676.    collel_t x;
  14677.  
  14678.    if (NULL == setlocale(LC_ALL, LC_C_FRANCE)) {
  14679.       printf("Setlocale(LC_ALL, LC_A_FRANCE) failed.\n");
  14680.       exit(1);
  14681.    }
  14682.    x = getmccoll(&str);
  14683.    printf("getmccoll(\"%s\")\n", s);
  14684.    printf("  returns: \"%s\"\n", colltostr(x));
  14685.    printf("  remainder of string: \"%s\"\n", str);
  14686.    return 0;
  14687.  
  14688.    /****************************************************************************
  14689.       The output should be similar to :
  14690.  
  14691.       getmccoll("de xyz")
  14692.         returns: "de "
  14693.         remainder of string: "xyz"
  14694.    ****************************************************************************/
  14695. }
  14696.  
  14697.  
  14698. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14699.  
  14700. Example of getmccoll 
  14701.  
  14702.      cclass - Return Characters in Character Class 
  14703.      collequiv - Return List of Equivalent Collating Elements 
  14704.      collorder - Return List of Collating Elements 
  14705.      collrange - Calculate Range of Collating Elements 
  14706.      colltostr - Return String for Collating Element 
  14707.      getwmccoll - Get Next Collating Element from Wide String 
  14708.      ismccollel - Identify Multi-Character Collating Element 
  14709.      maxcoll - Return Maximum Collating Element 
  14710.      strtocoll - Return Collating Element for String 
  14711.      <collate.h> 
  14712.  
  14713.  
  14714. ΓòÉΓòÉΓòÉ 4.140. getpid - Get Process Identifier ΓòÉΓòÉΓòÉ
  14715.  
  14716.  
  14717. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14718.  
  14719. #include <process.h>
  14720. int getpid(void);
  14721.  
  14722.  
  14723. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14724.  
  14725. Language Level:  XPG4, Extension 
  14726.  
  14727. getpid gets the process identifier that uniquely identifies the calling 
  14728. process. 
  14729.  
  14730. Note:  In earlier releases of C Set ++, getpid began with an underscore 
  14731. (_getpid). Because it is defined by the X/Open standard, the underscore has 
  14732. been removed. For compatibility, VisualAge C++ will map _getpid to getpid for 
  14733. you. 
  14734.  
  14735. Return Value 
  14736. getpid function the process identifier as an integer value.  There is no error 
  14737. return value. 
  14738.  
  14739.  
  14740. ΓòÉΓòÉΓòÉ <hidden> Example of getpid ΓòÉΓòÉΓòÉ
  14741.  
  14742. /************************************************************************
  14743.  
  14744. This example prints the process identifier: 
  14745.  
  14746. ************************************************************************/
  14747.  
  14748. #include <process.h>
  14749. #include <string.h>
  14750. #include <stdio.h>
  14751. #include <stdlib.h>
  14752.  
  14753. int main(void)
  14754. {
  14755.    printf("Process identifier is %05d\n", getpid());
  14756.    return 0;
  14757.  
  14758.    /****************************************************************************
  14759.       The output should be similar to:
  14760.  
  14761.       Process identifier is 00242
  14762.    ****************************************************************************/
  14763. }
  14764.  
  14765.  
  14766. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14767.  
  14768. Example of getpid 
  14769.  
  14770.      _cwait - Wait for Child Process 
  14771.      execl - _execvpe - Load and Run Child Process 
  14772.      _spawnl - _spawnvpe - Start and Run Child Processes 
  14773.      wait - Wait for Child Process 
  14774.      <process.h> 
  14775.  
  14776.  
  14777. ΓòÉΓòÉΓòÉ 4.141. gets - Read a Line ΓòÉΓòÉΓòÉ
  14778.  
  14779.  
  14780. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14781.  
  14782. #include <stdio.h>
  14783. char *gets(char *buffer);
  14784.  
  14785.  
  14786. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14787.  
  14788. Language Level: ANSI, SAA, POSIX, XPG4 
  14789.  
  14790. gets reads a line from the standard input stream stdin and stores it in buffer. 
  14791. The line consists of all characters up to and including the first new-line 
  14792. character (\n) or EOF. gets then replaces the new-line character, if read, with 
  14793. a null character (\0) before returning the line. 
  14794.  
  14795. Return Value 
  14796. If successful, gets returns its argument.  A NULL pointer return value 
  14797. indicates an error or an end-of-file condition with no characters read. Use 
  14798. ferror or feof to determine which of these conditions occurred. If there is an 
  14799. error, the value stored in buffer is undefined.  If an end-of-file condition 
  14800. occurs, buffer is not changed. 
  14801.  
  14802.  
  14803. ΓòÉΓòÉΓòÉ <hidden> Example of gets ΓòÉΓòÉΓòÉ
  14804.  
  14805. /************************************************************************
  14806.  
  14807. This example gets a line of input from stdin. 
  14808.  
  14809. ************************************************************************/
  14810.  
  14811. #include <stdio.h>
  14812.  
  14813. #define  MAX_LINE      100
  14814.  
  14815. int main(void)
  14816. {
  14817.    char line[MAX_LINE];
  14818.    char *result;
  14819.  
  14820.    if ((result = gets(line)) != NULL) {
  14821.       if (ferror(stdin))
  14822.          perror("Error");
  14823.       printf("Input line : %s\n", result);
  14824.    }
  14825.    return 0;
  14826.  
  14827.    /****************************************************************************
  14828.       For the following input:
  14829.       This is a test for function gets.
  14830.  
  14831.       The output should be:
  14832.       Input line : This a test for function gets.
  14833.    ****************************************************************************/
  14834. }
  14835.  
  14836.  
  14837. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14838.  
  14839. Example of gets 
  14840.  
  14841.      _cgets - Read String of Characters from Keyboard 
  14842.      fgets - Read a String 
  14843.      feof - Test End-of-File Indicator 
  14844.      ferror - Test for Read/Write Errors 
  14845.      fputs - Write String 
  14846.      getc - getchar - Read a Character 
  14847.      puts - Write a String 
  14848.      <stdio.h> 
  14849.  
  14850.  
  14851. ΓòÉΓòÉΓòÉ 4.142. getsyntx - Return LC_SYNTAX Characters ΓòÉΓòÉΓòÉ
  14852.  
  14853.  
  14854. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14855.  
  14856. #include <variant.h>
  14857. struct variant *getsyntx(void);
  14858.  
  14859.  
  14860. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14861.  
  14862. Language Level:  Extension 
  14863.  
  14864. getsyntx determines the encoding of the special characters defined in the 
  14865. LC_SYNTAX category of the current locale, and stores the encoding values in the 
  14866. structure of type struct variant. For details of the structure type, see 
  14867. <variant.h>. 
  14868.  
  14869. Your program cannot modify the returned structure. The structure can be 
  14870. overwritten by a call to setlocale with the argument LC_ALL or LC_SYNTAX. 
  14871.  
  14872. Return Value 
  14873. getsyntx returns the pointer to the structure containing the values of the 
  14874. special characters. If the information about the special characters is not 
  14875. available in the current locale, getsyntx returns a null pointer. 
  14876.  
  14877.  
  14878. ΓòÉΓòÉΓòÉ <hidden> Example of getsyntx ΓòÉΓòÉΓòÉ
  14879.  
  14880. /************************************************************************
  14881.  
  14882. This example uses getsyntx to show the value of various special characters. 
  14883.  
  14884. ************************************************************************/
  14885.  
  14886. #include <stdio.h>
  14887. #include <variant.h>
  14888. #include <locale.h>
  14889.  
  14890. int main(void)
  14891. {
  14892.    struct variant *var;
  14893.  
  14894.    setlocale(LC_ALL, LC_C_USA);
  14895.    var = getsyntx();
  14896.    printf("codeset         : %s\n", var->codeset         );
  14897.    printf("backslash       : %c\n", var->backslash       );
  14898.    printf("right_bracket   : %c\n", var->right_bracket   );
  14899.    printf("left_bracket    : %c\n", var->left_bracket    );
  14900.    printf("right_brace     : %c\n", var->right_brace     );
  14901.    printf("left_brace      : %c\n", var->left_brace      );
  14902.    printf("circumflex      : %c\n", var->circumflex      );
  14903.    printf("tilde           : %c\n", var->tilde           );
  14904.    printf("exclamation_mark: %c\n", var->exclamation_mark);
  14905.    printf("number_sign     : %c\n", var->number_sign     );
  14906.    printf("vertical_line   : %c\n", var->vertical_line   );
  14907.    printf("dollar_sign     : %c\n", var->dollar_sign     );
  14908.    printf("commercial_at   : %c\n", var->commercial_at   );
  14909.    printf("grave_accent    : %c\n", var->grave_accent    );
  14910.    return 0;
  14911.  
  14912.    /****************************************************************************
  14913.       The output should be similar to :
  14914.  
  14915.       codeset         : IBM-850
  14916.       backslash       : \
  14917.       right_bracket   : ]
  14918.       left_bracket    : [
  14919.       right_brace     : }
  14920.       left_brace      : {
  14921.       circumflex      : ^
  14922.       tilde           : ~
  14923.       exclamation_mark: !
  14924.       number_sign     : #
  14925.       vertical_line   : |
  14926.       dollar_sign     : $
  14927.       commercial_at   : @
  14928.       grave_accent    : `
  14929.    ****************************************************************************/
  14930. }
  14931.  
  14932.  
  14933. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  14934.  
  14935. Example of getsyntx 
  14936.  
  14937.      setlocale - Set Locale 
  14938.      <locale.h> 
  14939.      <variant.h> 
  14940.  
  14941.  
  14942. ΓòÉΓòÉΓòÉ 4.143. _getTIBvalue - Get Thread Information Block Value ΓòÉΓòÉΓòÉ
  14943.  
  14944.  
  14945. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  14946.  
  14947. #include <builtin.h>
  14948. unsigned long _getTIBvalue(const unsigned int offset);
  14949.  
  14950.  
  14951. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  14952.  
  14953. Language Level:  Extension 
  14954.  
  14955. _getTIBvalue retrieves an unsigned long value from the thread information block 
  14956. (TIB) at the offset specified. The selector value for the TIB belonging to the 
  14957. current thread of execution is stored in the FS segment register. You should 
  14958. use the offsetof macro to calculate offset. 
  14959.  
  14960. Note:  _getTIBvalue is a built-in function, which means it is implemented as an 
  14961. inline instruction and has no backing code in the library.  For this reason: 
  14962.  
  14963.      You cannot take the address of _getTIBvalue. 
  14964.      You cannot parenthesize a call to _getTIBvalue. (Parentheses specify a 
  14965.       call to the function's backing code, and _getTIBvalue has none.) 
  14966.  
  14967.  Return Value 
  14968.  _getTIBvalue returns an unsigned long value from the TIB. There is no error 
  14969.  return value and _getTIBvalue does not set errno.  If offset is too large, it 
  14970.  will cause an access violation when running the program. 
  14971.  
  14972.  
  14973. ΓòÉΓòÉΓòÉ <hidden> Example of _getTIBvalue ΓòÉΓòÉΓòÉ
  14974.  
  14975. /************************************************************************
  14976.  
  14977. This example prints out all the values in the TIB structure. 
  14978.  
  14979. ************************************************************************/
  14980.  
  14981. #define INCL_DOS
  14982. #include <os2.h>
  14983. #include <builtin.h>
  14984. #include <stdio.h>
  14985. #include <stddef.h>
  14986.  
  14987. int main(void)
  14988. {
  14989.    printf("Values in Thread Information Block are:\n\n" );
  14990.  
  14991.    printf("Exception chain pointer: %lx\n",
  14992.           _getTIBvalue(offsetof(TIB, tib_pexchain)));
  14993.    printf("Base stack address: %lx\n",
  14994.           _getTIBvalue(offsetof(TIB, tib_pstack)));
  14995.    printf("End of stack address: %lx\n",
  14996.           _getTIBvalue(offsetof(TIB, tib_pstacklimit)));
  14997.    printf("System specific TIB pointer: %p\n",
  14998.           _getTIBvalue(offsetof(TIB, tib_ptib2)));
  14999.    printf("Version number: %lu\n",
  15000.           _getTIBvalue(offsetof(TIB, tib_version)));
  15001.    printf("Ordinal number: %lu\n",
  15002.           _getTIBvalue(offsetof(TIB, tib_ordinal)));
  15003.    return 0;
  15004.  
  15005.    /****************************************************************************
  15006.       The output should be similar to :
  15007.  
  15008.       Values in Thread Information Block are:
  15009.  
  15010.       Exception chain pointer: 38844
  15011.       Base stack address: 30000
  15012.       End of stack address: 38860
  15013.       System specific TIB pointer: 50048
  15014.       Version number: 20
  15015.       Ordinal number: 122
  15016.    ****************************************************************************/
  15017. }
  15018.  
  15019.  
  15020. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15021.  
  15022. Example of _getTIBvalue 
  15023.  
  15024.      _threadstore - Access Thread-Specific Storage 
  15025.  
  15026.      <builtin.h> 
  15027.  
  15028.  
  15029. ΓòÉΓòÉΓòÉ 4.144. getwc - Read Wide Character from Stream ΓòÉΓòÉΓòÉ
  15030.  
  15031.  
  15032. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15033.  
  15034. #include <stdio.h>
  15035. #include <wchar.h>
  15036. wint_t getwc(FILE *stream);
  15037.  
  15038.  
  15039. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15040.  
  15041. Language Level:  ANSI 93, XPG4 
  15042.  
  15043. getwc reads the next multibyte character from stream, converts it to a wide 
  15044. character, and advances the associated file position indicator for stream. 
  15045.  
  15046. getwc is equivalent to fgetwc except that, if it is implemented as a macro, it 
  15047. can evaluate stream more than once. Therefore, the argument should never be an 
  15048. expression with side effects. 
  15049.  
  15050. The behavior of getwc is affected by the LC_CTYPE category of the current 
  15051. locale. If you change the category between subsequent read operations on the 
  15052. same stream, undefined results can occur. 
  15053.  
  15054. Using non-wide-character functions with getwc on the same stream results in 
  15055. undefined behavior. 
  15056.  
  15057. After calling getwc, flush the buffer or reposition the stream pointer before 
  15058. calling a write function for the stream, unless EOF has been reached. After a 
  15059. write operation on the stream, flush the buffer or reposition the stream 
  15060. pointer before calling getwc. 
  15061.  
  15062. Return Value 
  15063. getwc returns the next wide character from the input stream, or WEOF. If an 
  15064. error occurs, getwc sets the error indicator. If getwc encounters the 
  15065. end-of-file, it sets the EOF indicator. If an encoding error occurs during 
  15066. conversion of the multibyte character, getwc sets errno to EILSEQ. 
  15067.  
  15068. Use ferror or feof to determine whether an error or an EOF condition occurred. 
  15069. EOF is only reached when an attempt is made to read past the last byte of data. 
  15070. Reading up to and including the last byte of data does not turn on the EOF 
  15071. indicator. 
  15072.  
  15073.  
  15074. ΓòÉΓòÉΓòÉ <hidden> Example of getwc ΓòÉΓòÉΓòÉ
  15075.  
  15076. /************************************************************************
  15077.  
  15078. This example opens a file and uses getwc to read wide characters from the file. 
  15079.  
  15080. ************************************************************************/
  15081.  
  15082. #include <errno.h>
  15083. #include <stdio.h>
  15084. #include <wchar.h>
  15085.  
  15086. int main(void)
  15087. {
  15088.    FILE    *stream;
  15089.    wint_t  wc;
  15090.  
  15091.    if (NULL == (stream = fopen("getwc.dat", "r"))) {
  15092.       printf("Unable to open: \"getwc.dat\".\n");
  15093.       exit(1);
  15094.    }
  15095.  
  15096.    errno = 0;
  15097.    while (WEOF !=(wc = getwc(stream)))
  15098.       printf("wc = %lc\n", wc);
  15099.  
  15100.    if (EILSEQ == errno) {
  15101.       printf("An invalid wide character was encountered.\n");
  15102.       exit(1);
  15103.    }
  15104.    fclose(stream);
  15105.    return 0;
  15106.  
  15107.    /****************************************************************************
  15108.       Assuming the file getwc.dat contains:
  15109.  
  15110.       Hello world!
  15111.  
  15112.       The output should be:
  15113.  
  15114.       wc = H
  15115.       wc = e
  15116.       wc = l
  15117.       wc = l
  15118.       wc = o
  15119.       :
  15120.    ****************************************************************************/
  15121. }
  15122.  
  15123.  
  15124. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15125.  
  15126. Example of getwc 
  15127.  
  15128.      fgetwc - Read Wide Character from Stream 
  15129.      getwchar - Get Wide Character from stdin 
  15130.      getc - getchar - Read a Character 
  15131.      _getch - _getche - Read Character from Keyboard 
  15132.      putwc - Write Wide Character 
  15133.      <stdio.h> 
  15134.      <wchar.h> 
  15135.  
  15136.  
  15137. ΓòÉΓòÉΓòÉ 4.145. getwchar - Get Wide Character from stdin ΓòÉΓòÉΓòÉ
  15138.  
  15139.  
  15140. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15141.  
  15142. #include <wchar.h>
  15143. wint_t getwchar(void);
  15144.  
  15145.  
  15146. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15147.  
  15148. Language Level: ANSI, SAA, XPG4 
  15149.  
  15150. getwchar reads the next multibyte character from stdin, converts it to a wide 
  15151. character, and advances the associated file position indicator for stdin. A 
  15152. call to  getwchar is equivalent to a call to getwc(stdin). 
  15153.  
  15154. The behavior of getwchar is affected by the LC_CTYPE category of the current 
  15155. locale. If you change the category between subsequent read operations on the 
  15156. same stream, undefined results can occur. 
  15157.  
  15158. Using non-wide-character functions with getwchar on the same stream results in 
  15159. undefined behavior. 
  15160.  
  15161. Return Value 
  15162. getwchar returns the next wide character from stdin or WEOF. If getwchar 
  15163. encounters EOF, it sets the EOF indicator for the stream and returns WEOF. If a 
  15164. read error occurs, the error indicator for the stream is set and getwchar 
  15165. returns WEOF. If an encoding error occurs during the conversion of the 
  15166. multibyte character to a wide character, getwchar sets errno to EILSEQ and 
  15167. returns WEOF. 
  15168.  
  15169. Use ferror or feof to determine whether an error or an EOF condition occurred. 
  15170. EOF is only reached when an attempt is made to read past the last byte of data. 
  15171. Reading up to and including the last byte of data does not turn on the EOF 
  15172. indicator. 
  15173.  
  15174.  
  15175. ΓòÉΓòÉΓòÉ <hidden> Example of getwchar ΓòÉΓòÉΓòÉ
  15176.  
  15177. /************************************************************************
  15178.  
  15179. This example uses getwchar to read wide characters from the keyboard, then 
  15180. prints the wide characters. 
  15181.  
  15182. ************************************************************************/
  15183.  
  15184. #include <errno.h>
  15185. #include <stdio.h>
  15186. #include <wchar.h>
  15187.  
  15188. int main(void)
  15189. {
  15190.    wint_t  wc;
  15191.  
  15192.    errno = 0;
  15193.    while (WEOF != (wc = getwchar()))
  15194.       printf("wc = %lc\n", wc);
  15195.  
  15196.    if (EILSEQ == errno) {
  15197.       printf("An invalid wide character was encountered.\n");
  15198.       exit(1);
  15199.    }
  15200.    return 0;
  15201.  
  15202.    /****************************************************************************
  15203.       Assuming you enter: abcde^Z                        (note: ^Z is CNTRL-Z)
  15204.  
  15205.       The output should be:
  15206.  
  15207.       wc = a
  15208.       wc = b
  15209.       wc = c
  15210.       wc = d
  15211.       wc = e
  15212.    ****************************************************************************/
  15213. }
  15214.  
  15215.  
  15216. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15217.  
  15218. Example of getwchar 
  15219.  
  15220.      fgetc - Read a Character 
  15221.      _fgetchar - Read Single Character from stdin 
  15222.      getc - getchar - Read a Character 
  15223.      _getch - _getche - Read Character from Keyboard 
  15224.      getwc - Read Wide Character from Stream 
  15225.      <wchar.h> 
  15226.  
  15227.  
  15228. ΓòÉΓòÉΓòÉ 4.146. getwmccoll - Get Next Collating Element from Wide String ΓòÉΓòÉΓòÉ
  15229.  
  15230.  
  15231. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15232.  
  15233. #include <collate.h>
  15234. #include <wchar.h>
  15235. collel_t getwmccoll(wchar_t **src);
  15236.  
  15237.  
  15238. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15239.  
  15240. Language Level:  Extension 
  15241.  
  15242. getwmccoll finds the first sequence of wide characters in the array pointed to 
  15243. by src that constitute a valid multi-wide-character collating element. It then 
  15244. produces the collel_t value that corresponds to that collating element. It also 
  15245. changes src to point to the next byte following that collating element. 
  15246.  
  15247. Return Value 
  15248. getwmccoll returns the collel_t value that represents the collating element 
  15249. found. If the object pointed to by src is a null pointer or points to a null 
  15250. wide character, getwmccoll returns 0. If the object pointed to by src points to 
  15251. an invalid wide character, getwmccoll returns -1 and sets errno to EILSEQ. 
  15252.  
  15253.  
  15254. ΓòÉΓòÉΓòÉ <hidden> Example of getwmccoll ΓòÉΓòÉΓòÉ
  15255.  
  15256. /************************************************************************
  15257.  
  15258. This example uses getwmccoll to find the first collating element in the wide 
  15259. string s. 
  15260.  
  15261.  ***********************************************************************/
  15262.  
  15263. #include <stdio.h>
  15264. #include <locale.h>
  15265. #include <collate.h>
  15266. #include <wchar.h>
  15267.  
  15268. int main(void)
  15269. {
  15270.    wchar_t  s[] = L"\x8141\x64";
  15271.    wchar_t  *str = s;
  15272.    collel_t x;
  15273.  
  15274.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  15275.       printf("Setlocale(LC_ALL, \"ja_jp.ibm-932\") failed.\n");
  15276.       exit(1);
  15277.    }
  15278.    x = getwmccoll(&str);
  15279.    printf("getwmccoll(\"%s\")\n", s);
  15280.    printf("  returns: 0x%x\n", x);
  15281.    printf("  remainder of string: <%s>\n", str);
  15282.    return 0;
  15283.  
  15284.    /****************************************************************************
  15285.       The output should be similar to :
  15286.  
  15287.       getwmccoll("AΓöÇd")
  15288.         returns: 0x8141
  15289.         remainder of string: <d>
  15290.    ****************************************************************************/
  15291. }
  15292.  
  15293.  
  15294. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15295.  
  15296. Example of getwmccoll 
  15297.  
  15298.      cclass - Return Characters in Character Class 
  15299.      collequiv - Return List of Equivalent Collating Elements 
  15300.      collorder - Return List of Collating Elements 
  15301.      collrange - Calculate Range of Collating Elements 
  15302.      colltostr - Return String for Collating Element 
  15303.      getmccoll - Get Next Collating Element from String 
  15304.      ismccollel - Identify Multi-Character Collating Element 
  15305.      maxcoll - Return Maximum Collating Element 
  15306.      strtocoll - Return Collating Element for String 
  15307.      <collate.h> 
  15308.      <wchar.h> 
  15309.  
  15310.  
  15311. ΓòÉΓòÉΓòÉ 4.147. gmtime - Convert Time ΓòÉΓòÉΓòÉ
  15312.  
  15313.  
  15314. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15315.  
  15316. #include <time.h>
  15317. struct tm *gmtime(const time_t *time);
  15318.  
  15319.  
  15320. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15321.  
  15322. Language Level: ANSI, SAA, POSIX, XPG4 
  15323.  
  15324. The gmtime function breaks down the time value and stores it in a tm structure, 
  15325. defined in time.h.  The structure pointed to by the return value reflects 
  15326. Coordinated Universal Time, not local time. The value time is usually obtained 
  15327. from a call to time. 
  15328.  
  15329. The fields of the tm structure include: 
  15330.  
  15331.  tm_sec         Seconds (0-61) 
  15332.  tm_min         Minutes (0-59) 
  15333.  tm_hour        Hours (0-23) 
  15334.  tm_mday        Day of month (1-31) 
  15335.  tm_mon         Month (0-11;  January = 0) 
  15336.  tm_year        Year (current year minus 1900) 
  15337.  tm_wday        Day of week (0-6;  Sunday = 0) 
  15338.  tm_yday        Day of year (0-365;  January 1 = 0) 
  15339.  tm_isdst       Zero if Daylight Saving Time is not in effect;  positive if 
  15340.                 Daylight Saving Time is in effect;  negative if the information 
  15341.                 is not available. 
  15342.  
  15343.  Return Value 
  15344.  gmtime returns a pointer to the resulting tm structure. It returns NULL if 
  15345.  Coordinated Universal Time is not available. 
  15346.  
  15347.  Note: 
  15348.  
  15349.    1. The range (0-61) for tm_sec allows for as many as two leap seconds. 
  15350.  
  15351.    2. The gmtime and localtime functions may use a common, statically allocated 
  15352.       buffer for the conversion. Each call to one of these functions may alter 
  15353.       the result of the previous call. 
  15354.  
  15355.    3. The time and date functions begin at 00:00:00 Coordinated Universal Time, 
  15356.       January 1, 1970. 
  15357.  
  15358.  
  15359. ΓòÉΓòÉΓòÉ <hidden> Example of gmtime ΓòÉΓòÉΓòÉ
  15360.  
  15361. /************************************************************************
  15362.  
  15363. This example uses gmtime to adjust a time_t representation to a Coordinated 
  15364. Universal Time character string, and then converts it to a printable string 
  15365. using asctime. 
  15366.  
  15367. ************************************************************************/
  15368.  
  15369. #include <stdio.h>
  15370. #include <time.h>
  15371.  
  15372. int main(void)
  15373. {
  15374.    time_t ltime;
  15375.  
  15376.    time(<ime);
  15377.    printf("Coordinated Universal Time is %s\n", asctime(gmtime(<ime)));
  15378.    return 0;
  15379.  
  15380.    /****************************************************************************
  15381.       The output should be similar to:
  15382.  
  15383.       Coordinated Universal Time is Mon Sep 16 21:44 1995
  15384.    ****************************************************************************/
  15385. }
  15386.  
  15387.  
  15388. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15389.  
  15390. Example of gmtime 
  15391.  
  15392.      asctime - Convert Time to Character String 
  15393.      ctime - Convert Time to Character String 
  15394.      localtime - Convert Time 
  15395.      mktime - Convert Local Time 
  15396.      time - Determine Current Time 
  15397.      <time.h> 
  15398.  
  15399.  
  15400. ΓòÉΓòÉΓòÉ 4.148. _heap_check - Validate Default Memory Heap ΓòÉΓòÉΓòÉ
  15401.  
  15402.  
  15403. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15404.  
  15405. #include <stdlib.h>    /* also in <malloc.h> */
  15406. void _heap_check(void);
  15407.  
  15408.  
  15409. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15410.  
  15411. Language Level:  Extension 
  15412.  
  15413. _heap_check checks all memory blocks in the default heap that have been 
  15414. allocated or freed using the debug memory management functions (_debug_calloc, 
  15415. _debug_malloc, and so on). _heap_check checks that your program has not 
  15416. overwritten freed memory blocks or memory outside the bounds of allocated 
  15417. blocks. 
  15418.  
  15419. When you call a debug memory management function (such as _debug_malloc), it 
  15420. calls _heap_check automatically. You can also call _heap_check explicitly. 
  15421. Place calls to _heap_check throughout your code, especially in areas that you 
  15422. suspect have memory problems. 
  15423.  
  15424. Calling _heap_check frequently (explicitly or through the debug memory 
  15425. functions) can increase your program's memory requirements and decrease its 
  15426. execution speed.  To reduce the overhead of heap-checking, you can use the 
  15427. DDE4_HEAP_SKIP environment variable to control how often the functions check 
  15428. the heap. For example: 
  15429.  
  15430.   SET DDE4_HEAP_SKIP=10
  15431. specifies that every tenth call to any debug memory function (regardless of the 
  15432. type or heap) checks the heap. Explicit calls to _heap_check are always 
  15433. performed. For more details on DDE4_HEAP_SKIP, see "Skipping Heap Checks" in 
  15434. the Programming Guide. 
  15435.  
  15436. To use _heap_check and the debug memory management functions, you must compile 
  15437. with the debug memory (/Tm) compiler option. 
  15438.  
  15439. Note:  The /Tm option maps all calls to memory management functions (including 
  15440. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  15441. call from being mapped, parenthesize the function name. 
  15442.  
  15443. Heap-specific and tiled versions of this function (_uheap_check and 
  15444. _theap_check) are also available. _heap_check always checks the default heap. 
  15445.  
  15446. Return Value 
  15447. There is no return value. 
  15448.  
  15449.  
  15450. ΓòÉΓòÉΓòÉ <hidden> Example of _heap_check ΓòÉΓòÉΓòÉ
  15451.  
  15452. /************************************************************************
  15453.  
  15454. This example allocates 5000 bytes of storage, and then attempts to write to 
  15455. storage that was not allocated.  The call to _heap_check detects the error, 
  15456. generates several messages, and stops the program. 
  15457.  
  15458. ************************************************************************/
  15459.  
  15460. #include <stdlib.h>
  15461. #include <stdio.h>
  15462.  
  15463. int main(void)
  15464. {
  15465.    char *ptr;
  15466.  
  15467.    if (NULL == (ptr = malloc(5000))) {
  15468.       puts("Could not allocate memory block.");
  15469.       return EXIT_FAILURE;
  15470.    }
  15471.  
  15472.    *(ptr-1) = 'a';            /* overwrites storage that was not allocated    */
  15473.    _heap_check();
  15474.    puts("_heap_check did not detect that a memory block was overwritten.");
  15475.    return 0;
  15476.  
  15477.    /****************************************************************************
  15478.       The output should be similar to:
  15479.  
  15480.       Header information of object 0x00073890 was overwritten at 0x0007388c.
  15481.       The first eight bytes of the memory block (in hex) are: AAAAAAAAAAAAAAAA.
  15482.       This memory block was (re)allocated at line number 8 in _heap_check.c.
  15483.       Heap state was valid at line 8 of _heap_check.c.
  15484.       Memory error detected at line 14 of _heap_check.c.
  15485.    ****************************************************************************/
  15486. }
  15487.  
  15488.  
  15489. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15490.  
  15491. Example of _heap_check 
  15492.  
  15493.      Memory Management in the Programming Guide 
  15494.      Debugging Your Heaps in the Programming Guide 
  15495.      Differentiating between Memory Management Functions 
  15496.      _debug_calloc - Allocate and Initialize Memory 
  15497.      _debug_free - Release Memory 
  15498.      _debug_heapmin - Release Unused Memory in the Default Heap 
  15499.      _debug_malloc - Allocate Memory 
  15500.      _debug_realloc - Reallocate Memory Block 
  15501.      _dump_allocated - Get Information about Allocated Memory 
  15502.      _dump_allocated_delta - Get Information about Allocated Memory 
  15503.      _heapchk - Validate Default Memory Heap 
  15504.      _uheap_check - Validate User Memory Heap 
  15505.      <malloc.h> 
  15506.      <stdlib.h> 
  15507.  
  15508.  
  15509. ΓòÉΓòÉΓòÉ 4.149. _heapchk - Validate Default Memory Heap ΓòÉΓòÉΓòÉ
  15510.  
  15511.  
  15512. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15513.  
  15514. #include <malloc.h>
  15515. int _heapchk(void);
  15516.  
  15517.  
  15518. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15519.  
  15520. Language Level:  Extension 
  15521.  
  15522. _heapchk checks the default storage heap for minimal consistency by checking 
  15523. all allocated and freed objects on the heap. 
  15524.  
  15525. A heap-specific version of this function, _uheapchk, is also available. 
  15526.  
  15527. Note:  Using the _heapchk, _heapset, and _heap_walk functions (and their 
  15528. heap-specific equivalents) may add overhead to each object allocated from the 
  15529. heap. 
  15530.  
  15531. Return Value 
  15532. _heapchk returns one of the following values, defined in <malloc.h>: 
  15533.  
  15534.  _HEAPBADBEGIN     The heap specified is not valid. (Only occurs if you changed 
  15535.                    the default heap and then later closed or destroyed it.) 
  15536.  _HEAPBADNODE      A memory node is corrupted, or the heap is damaged. 
  15537.  _HEAPEMPTY        The heap has not been initialized. 
  15538.  _HEAPOK           The heap appears to be consistent. 
  15539.  
  15540.  
  15541. ΓòÉΓòÉΓòÉ <hidden> Example of _heapchk ΓòÉΓòÉΓòÉ
  15542.  
  15543. /************************************************************************
  15544.  
  15545. This example performs some memory allocations, then calls _heapchk to check the 
  15546. heap. 
  15547.  
  15548. ***********************************************************************/
  15549.  
  15550. #include <stdlib.h>
  15551. #include <stdio.h>
  15552. #include <malloc.h>
  15553.  
  15554. int main(void)
  15555. {
  15556.    char *ptr;
  15557.    int  rc;
  15558.  
  15559.    if (NULL == (ptr = malloc(10))) {
  15560.       puts("Could not allocate memory block.");
  15561.       exit(EXIT_FAILURE);
  15562.    }
  15563.    *(ptr - 1) = 'x';      /* overwrites storage that was not allocated */
  15564.  
  15565.    if (_HEAPOK != (rc = _heapchk())) {
  15566.       switch(rc) {
  15567.          case _HEAPEMPTY:
  15568.             puts("The heap has not been initialized.");
  15569.             break;
  15570.          case _HEAPBADNODE:
  15571.             puts("A memory node is corrupted or the heap is damaged.");
  15572.             break;
  15573.          case _HEAPBADBEGIN:
  15574.             puts("The heap specified is not valid.");
  15575.             break;
  15576.       }
  15577.       exit(rc);
  15578.    }
  15579.    free(ptr);
  15580.    return 0;
  15581.  
  15582.    /****************************************************************************
  15583.       The output should be similar to :
  15584.  
  15585.       A memory node is corrupted or the heap is damaged.
  15586.    ****************************************************************************/
  15587. }
  15588.  
  15589.  
  15590. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15591.  
  15592. Example of _heapchk 
  15593.  
  15594.      "Managing Memory" in the Programming Guide 
  15595.      _uheapchk - Validate Memory Heap 
  15596.      _heapmin - Release Unused Memory from Default Heap 
  15597.      _heapset - Validate and Set Default Heap 
  15598.      _heap_walk - Return Information about Default Heap 
  15599.      <malloc.h> 
  15600.      <umalloc.h> 
  15601.  
  15602.  
  15603. ΓòÉΓòÉΓòÉ 4.150. _heapmin - Release Unused Memory from Default Heap ΓòÉΓòÉΓòÉ
  15604.  
  15605.  
  15606. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15607.  
  15608. #include <stdlib.h>  /* also in <malloc.h> */
  15609. int _heapmin(void);
  15610.  
  15611.  
  15612. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15613.  
  15614. Language Level:  Extension 
  15615.  
  15616. _heapmin returns all unused memory from the default runtime heap to the 
  15617. operating system. 
  15618.  
  15619. Heap-specific, tiled, and debug versions of this function (_uheapmin, 
  15620. _theapmin, and _debug_heapmin) are also available. _heapmin always operates on 
  15621. the default heap. 
  15622.  
  15623. Note:  If you create your own heap and make it the default heap, _heapmin calls 
  15624. the release function that you provide to return the memory. 
  15625.  
  15626. Return Value 
  15627. _heapmin returns 0 if successful; if not, it returns -1. 
  15628.  
  15629.  
  15630. ΓòÉΓòÉΓòÉ <hidden> Example of _heapmin ΓòÉΓòÉΓòÉ
  15631.  
  15632. /************************************************************************
  15633.  
  15634. This example shows how to use the _heapmin function. 
  15635.  
  15636. ************************************************************************/
  15637.  
  15638. #include <stdio.h>
  15639. #include <stdlib.h>
  15640.  
  15641. int main(void)
  15642. {
  15643.    if (_heapmin())
  15644.       printf("_heapmin failed.\n");
  15645.    else
  15646.       printf("_heapmin was successful.\n");
  15647.    return 0;
  15648.  
  15649.    /****************************************************************************
  15650.       The output should be:
  15651.  
  15652.      _heapmin was successful.
  15653.    ****************************************************************************/
  15654. }
  15655.  
  15656.  
  15657. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15658.  
  15659. Example of _heapmin 
  15660.  
  15661.      Managing Memory in the Programming Guide 
  15662.      _debug_heapmin - Release Unused Memory in the Default Heap 
  15663.      _debug_theapmin - Release Unused Tiled Memory 
  15664.      _debug_uheapmin - Release Unused Memory in User Heap 
  15665.      _theapmin - Release Unused Tiled Memory 
  15666.      _uheapmin - Release Unused Memory in User Heap 
  15667.      <malloc.h> 
  15668.      <stdlib.h> 
  15669.  
  15670.  
  15671. ΓòÉΓòÉΓòÉ 4.151. _heapset - Validate and Set Default Heap ΓòÉΓòÉΓòÉ
  15672.  
  15673.  
  15674. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15675.  
  15676. #include <malloc.h>
  15677. int _heapset(unsigned int fill);
  15678.  
  15679.  
  15680. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15681.  
  15682. Language Level:  Extension 
  15683.  
  15684. _heapset checks the default storage heap for minimal consistency by checking 
  15685. all allocated and freed objects on the heap (similar to _heapchk). It then sets 
  15686. each byte of the heap's free objects to the value of fill. 
  15687.  
  15688. Using _heapset can help you locate problems where your program continues to use 
  15689. a freed pointer to an object. After you set the free heap to a specific value, 
  15690. when your program tries to interpret the set values in the freed object as 
  15691. data, unexpected results occur, indicating a problem. 
  15692.  
  15693. A heap-specific version of this function, _uheapset, is also available. 
  15694.  
  15695. Note:  Using the _heapchk, _heapset, and _heap_walk functions (and their 
  15696. heap-specific equivalents) may add overhead to each object allocated from the 
  15697. heap. 
  15698.  
  15699. Return Value 
  15700. _heapset returns one of the following values, defined in <malloc.h>: 
  15701.  
  15702.  _HEAPBADBEGIN     The heap specified is not valid; it may have been closed or 
  15703.                    destroyed. 
  15704.  _HEAPBADNODE      A memory node is corrupted, or the heap is damaged. 
  15705.  _HEAPEMPTY        The heap has not been initialized. 
  15706.  _HEAPOK           The heap appears to be consistent. 
  15707.  
  15708.  
  15709. ΓòÉΓòÉΓòÉ <hidden> Example of _heapset ΓòÉΓòÉΓòÉ
  15710.  
  15711. /************************************************************************
  15712.  
  15713. This example allocates and frees memory, then uses _heapset to set the free 
  15714. heap to X. It checks the return code from _heapset to ensure the heap is still 
  15715. valid. 
  15716.  
  15717. *********************************************************************** /
  15718.  
  15719. #include <stdlib.h>
  15720. #include <stdio.h>
  15721. #include <malloc.h>
  15722.  
  15723. int main (void)
  15724. {
  15725.    char  *ptr;
  15726.    int   rc;
  15727.  
  15728.    if (NULL == (ptr = malloc(10))) {
  15729.       puts("Could not allocate memory block.");
  15730.       exit(EXIT_FAILURE);
  15731.    }
  15732.    memset(ptr,'A',5);
  15733.    free(ptr);
  15734.  
  15735.    if (_HEAPOK != (rc = _heapset('X'))) {
  15736.       switch(rc) {
  15737.          case _HEAPEMPTY:
  15738.             puts("The heap has not been initialized.");
  15739.             break;
  15740.          case _HEAPBADNODE:
  15741.             puts("A memory node is corrupted or the heap is damaged.");
  15742.             break;
  15743.          case _HEAPBADBEGIN:
  15744.             puts("The heap specified is not valid.");
  15745.             break;
  15746.       }
  15747.       exit(rc);
  15748.    }
  15749.    return 0;
  15750. }
  15751.  
  15752.  
  15753. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15754.  
  15755. Example of _heapset 
  15756.  
  15757.      "Managing Memory" in the Programming Guide 
  15758.      _heapchk - Validate Default Memory Heap 
  15759.      _heapmin - Release Unused Memory from Default Heap 
  15760.      _heap_walk - Return Information about Default Heap 
  15761.      _uheapset - Validate and Set Memory Heap 
  15762.      <malloc.h> 
  15763.      <umalloc.h> 
  15764.  
  15765.  
  15766. ΓòÉΓòÉΓòÉ 4.152. _heap_walk - Return Information about Default Heap ΓòÉΓòÉΓòÉ
  15767.  
  15768.  
  15769. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15770.  
  15771. #include <malloc.h>
  15772. int _heap_walk(int (*callback_fn)(const void *object, size_t size,
  15773.                                               int flag, int status,
  15774.                                               const char* file, int line) );
  15775.  
  15776.  
  15777. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15778.  
  15779. Language Level:  Extension 
  15780.  
  15781. _heap_walk traverses the default heap, and for each allocated or freed object, 
  15782. it calls the callback_fn function that you provide. For each object, it passes 
  15783. your function: 
  15784.  
  15785.  object    A pointer to the object. 
  15786.  size      The size of the object. 
  15787.  flag      The value _USEDENTRY if the object is currently allocated, or 
  15788.            _FREEENTRY if the object has been freed.  (Both values are defined 
  15789.            in <malloc.h>.) 
  15790.  status    One of the following values, defined in <malloc.h>, depending on the 
  15791.            status of the object: 
  15792.            _HEAPBADBEGIN          The heap specified is not valid; it may have 
  15793.                                   been closed or destroyed. 
  15794.            _HEAPBADNODE           A memory node is corrupted, or the heap is 
  15795.                                   damaged. 
  15796.            _HEAPEMPTY             The heap has not been initialized. 
  15797.            _HEAPOK                The heap appears to be consistent. 
  15798.  file      The name of the file where the object was allocated. 
  15799.  line      The line where the object was allocated. 
  15800.  
  15801.  _heap_walk provides information about all objects, regardless of which memory 
  15802.  management functions were used to allocate them. However, the file and line 
  15803.  information are only available if the object was allocated and freed using the 
  15804.  debug versions of the memory management functions. Otherwise, file is NULL and 
  15805.  line is 0. 
  15806.  
  15807.  _heap_walk calls callback_fn for each object until one of the following 
  15808.  occurs: 
  15809.  
  15810.      All objects have been traversed. 
  15811.      callback_fn returns a nonzero value to _heap_walk. 
  15812.      It cannot continue because of a problem with the heap. 
  15813.  
  15814.  You may want to code your callback_fn to return a nonzero value if the status 
  15815.  of the object is not _HEAPOK. Even if callback_fn returns 0 for an object that 
  15816.  is corrupted, _heap_walk cannot continue because of the state of the heap and 
  15817.  returns to its caller. 
  15818.  
  15819.  You can use callback_fn to process the information from _heap_walk in various 
  15820.  ways. For example, you may want to print the information to a file or use it 
  15821.  to generate your own error messages. You can use the information to look for 
  15822.  memory leaks and objects incorrectly allocated or freed from the heap. It can 
  15823.  be especially useful to call _heap_walk when _heapchk returns an error. 
  15824.  
  15825.  A heap-specific version of this function, _uheap_walk, is also available. 
  15826.  
  15827.  Note: 
  15828.  
  15829.    1. Using the _heapchk, _heapset, and _heap_walk functions (and their 
  15830.       heap-specific equivalents) may add overhead to each object allocated from 
  15831.       the heap. 
  15832.  
  15833.    2. _heap_walk locks the heap while it traverses it, to ensure that no other 
  15834.       operations use the heap until _heap_walk finishes. As a result, in your 
  15835.       callback_fn, you cannot call any critical functions in the runtime 
  15836.       library, either explicitly or by calling another function that calls a 
  15837.       critical function. See the Programming Guide for a list of critical 
  15838.       functions. 
  15839.  
  15840.  Return Value 
  15841.  _heap_walk returns the last value of status to the caller. 
  15842.  
  15843.  
  15844. ΓòÉΓòÉΓòÉ <hidden> Example of _heap_walk ΓòÉΓòÉΓòÉ
  15845.  
  15846. /************************************************************************
  15847.  
  15848. This example allocates some memory, then uses _heap_walk to walk the heap and 
  15849. pass information about allocated objects to the callback function 
  15850. callback_function. callback_function then checks the information and keeps 
  15851. track of the number of allocated objects. 
  15852.  
  15853. *********************************************************************** /
  15854.  
  15855. #include <stdlib.h>
  15856. #include <stdio.h>
  15857. #include <malloc.h>
  15858.  
  15859. int callback_function(const void *pentry, size_t sz, int useflag, int status,
  15860.                       const char *filename, size_t line)
  15861. {
  15862.    if (_HEAPOK != status) {
  15863.       puts("status is not _HEAPOK.");
  15864.       exit(status);
  15865.    }
  15866.    if (_USEDENTRY == useflag)
  15867.       printf("allocated  %p     %u\n", pentry, sz);
  15868.    else
  15869.       printf("freed      %p     %u\n", pentry, sz);
  15870.    return 0;
  15871. }
  15872.  
  15873. int main(void)
  15874. {
  15875.    char  *p1, *p2, *p3;
  15876.  
  15877.    if (NULL == (p1 = malloc(100)) ||
  15878.        NULL == (p2 = malloc(200)) ||
  15879.        NULL == (p3 = malloc(300))) {
  15880.       puts("Could not allocate memory block.");
  15881.       exit(EXIT_FAILURE);
  15882.    }
  15883.    free(p2);
  15884.    puts("usage      address   size\n-----      -------   ----");
  15885.  
  15886.    _heap_walk(callback_function);
  15887.  
  15888.    free(p1);
  15889.    free(p3);
  15890.    return 0;
  15891.  
  15892.    /****************************************************************************
  15893.       The output should be similar to :
  15894.  
  15895.       usage      address   size
  15896.       -----      -------   ----
  15897.       allocated  73A10     300
  15898.       allocated  738B0     100
  15899.        :
  15900.        :
  15901.       freed      73920     224
  15902.    ****************************************************************************/
  15903. }
  15904.  
  15905.  
  15906. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15907.  
  15908. Example of _heap_walk 
  15909.  
  15910.      "Managing Memory" in the Programming Guide 
  15911.      "Debugging Your Heaps" in the Programming Guide 
  15912.      _heapchk - Validate Default Memory Heap 
  15913.      _heapmin - Release Unused Memory from Default Heap 
  15914.      _heapset - Validate and Set Default Heap 
  15915.      _uheap_walk - Return Information about Memory Heap 
  15916.      <malloc.h> 
  15917.  
  15918.  
  15919. ΓòÉΓòÉΓòÉ 4.153. hypot - Calculate Hypotenuse ΓòÉΓòÉΓòÉ
  15920.  
  15921.  
  15922. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15923.  
  15924. #include <math.h>
  15925. double hypot(double side1, double side2);
  15926.  
  15927.  
  15928. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15929.  
  15930. Language Level: SAA, XPG4 
  15931.  
  15932. hypot calculates the length of the hypotenuse of a right-angled triangle based 
  15933. on the lengths of two sides side1 and side2.  A call to hypot is equivalent to: 
  15934.  
  15935.    sqrt(side1 * side1 + side2 * side2);
  15936.  
  15937. Return Value 
  15938. hypot returns the length of the hypotenuse. If an overflow results, hypot sets 
  15939. errno to ERANGE and returns the value HUGE_VAL. If an underflow results, hypot 
  15940. sets errno to ERANGE and returns zero. 
  15941.  
  15942.  
  15943. ΓòÉΓòÉΓòÉ <hidden> Example of hypot ΓòÉΓòÉΓòÉ
  15944.  
  15945. /************************************************************************
  15946.  
  15947. This example calculates the hypotenuse of a right-angled triangle with sides of 
  15948. 3.0 and 4.0. 
  15949.  
  15950. ************************************************************************/
  15951.  
  15952. #include <math.h>
  15953.  
  15954. int main(void)
  15955. {
  15956.    double x,y,z;
  15957.  
  15958.    x = 3.0;
  15959.    y = 4.0;
  15960.    z = hypot(x, y);
  15961.    printf("The hypotenuse of the triangle with sides %lf and %lf"
  15962.    " is %lf\n", x, y, z);
  15963.    return 0;
  15964.  
  15965.    /****************************************************************************
  15966.       The output should be:
  15967.  
  15968.      The hypotenuse of the triangle with sides 3.000000 and 4.000000 is 5.000000
  15969.    ****************************************************************************/
  15970. }
  15971.  
  15972.  
  15973. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  15974.  
  15975. Example of hypot 
  15976.  
  15977.      _fsqrt -  Calculate Square Root 
  15978.      sqrt - Calculate Square Root 
  15979.      <math.h> 
  15980.  
  15981.  
  15982. ΓòÉΓòÉΓòÉ 4.154. iconv - Convert Characters to New Code Set ΓòÉΓòÉΓòÉ
  15983.  
  15984.  
  15985. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  15986.  
  15987. #include <iconv.h>
  15988. size_t iconv(iconv_t cd, char **inbuf, size_t *insize,
  15989.              char **outbuf, size_t *outsize);
  15990.  
  15991.  
  15992. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  15993.  
  15994. Language Level:  XPG4 
  15995.  
  15996. iconv converts a sequence of characters in one encoded character set, in the 
  15997. array indirectly pointed to by inbuf and converts them to a sequence of 
  15998. corresponding characters in another encoded character set. It stores the 
  15999. corresponding sequence in the array indirectly pointed to by outbuf. cd is the 
  16000. conversion descriptor returned from iconv_open that describes which codesets 
  16001. are used in the conversion. 
  16002.  
  16003. inbuf points to a variable that points to the first character of input, and 
  16004. insize indicates the number of bytes of input. outbuf points to a variable that 
  16005. points to the first character of output, and outsize indicates the number of 
  16006. available bytes for output. 
  16007.  
  16008. As iconv converts the characters, it updates the variable pointed to by inbuf 
  16009. to point to the next byte in the input buffer, and updates the variable pointed 
  16010. to by outbut to the byte following the last successfully converted character. 
  16011. It also decrements insize and outsize to reflect the number of bytes of input 
  16012. remaining and the number of bytes still available for output, respectively. If 
  16013. the entire input string is converted, insize will be 0; if an error stops the 
  16014. conversion, insize will have a nonzero value. 
  16015.  
  16016. If it encounters a valid input character that does not have a defined 
  16017. conversion in cd, iconv translates the character to the ASCII value 0x1a. 
  16018.  
  16019. Sharing a conversion descriptor in iconv across multiple threads may result in 
  16020. undefined behavior. 
  16021.  
  16022. Return Value 
  16023. iconv returns the number of characters successfully converted. If an error 
  16024. occurs, conversion stops after the previous successfully converted character; 
  16025. iconv returns (size_t)-1, and sets errno to one of the following values: 
  16026.  
  16027.  Value       Meaning 
  16028.  EILSEQ      A sequence of input bytes does not form a valid character in the 
  16029.              specified encoded character set. 
  16030.  E2BIG       outbuf is not large enough to hold the converted value. 
  16031.  EINVAL      The input ends with an incomplete character. 
  16032.  EBADF       cd is not a valid conversion descriptor. 
  16033.  
  16034.  
  16035. ΓòÉΓòÉΓòÉ <hidden> Example of iconv ΓòÉΓòÉΓòÉ
  16036.  
  16037. /************************************************************************
  16038.  
  16039. This example converts an array of characters coded in encoded character set 
  16040. IBM-850 (in in) to an array of characters coded in encoded character set 
  16041. IBM-037 (stored in out). 
  16042.  
  16043. ************************************************************************/
  16044.  
  16045. #include <iconv.h>
  16046. #include <stdlib.h>
  16047. #include <stdio.h>
  16048.  
  16049. int main(void)
  16050. {
  16051.    const char   fromcode[] = "IBM-850";
  16052.    const char   tocode[] = "IBM-037";
  16053.    iconv_t      cd;
  16054.    char         in[] = "ABCDEabcde";
  16055.    size_t       in_size;
  16056.    char         *inptr = in;
  16057.    char         out[100];
  16058.    size_t       out_size = sizeof(out);
  16059.    char         *outptr = out;
  16060.    int          i;
  16061.  
  16062.    if ((iconv_t)(-1) == (cd = iconv_open(tocode, fromcode))) {
  16063.       printf("Failed to iconv_open %s to %s.\n", fromcode, tocode);
  16064.       exit(EXIT_FAILURE);
  16065.    }
  16066.    /* Convert the first 3 characters in array "in". */
  16067.    in_size = 3;
  16068.    if ((size_t)(-1) == iconv(cd, &inptr, &in_size, &outptr, &out_size)) {
  16069.       printf("Fail to convert first 3 characters to new code set.\n");
  16070.       exit(EXIT_FAILURE);
  16071.    }
  16072.    /* Convert the rest of the characters in array "in". */
  16073.    in_size = sizeof(in) - 3;
  16074.    if ((size_t)(-1) == iconv(cd, &inptr, &in_size, &outptr, &out_size)) {
  16075.       printf("Fail to convert the rest of the characters to new code set.\n");
  16076.       exit(EXIT_FAILURE);
  16077.    }
  16078.    *outptr = '\0';
  16079.    printf("The hex representation of string %s are:\n  In codepage %s ==> ",
  16080.           in, fromcode);
  16081.    for (i = 0; in[i] != '\0'; i++) {
  16082.       printf("0x%02x ", in[i]);
  16083.    }
  16084.    printf("\n  In codepage %s ==> ", tocode);
  16085.    for (i = 0; out[i] != '\0'; i++) {
  16086.       printf("0x%02x ", out[i]);
  16087.    }
  16088.    if (-1 == iconv_close(cd)) {
  16089.       printf("Fail to iconv_close.\n");
  16090.       exit(EXIT_FAILURE);
  16091.    }
  16092.    return 0;
  16093.  
  16094.    /****************************************************************************
  16095.       The output should be similar to :
  16096.  
  16097.       The hex representation of string ABCDEabcde are:
  16098.         In codepage IBM-850 ==> 0x41 0x42 0x43 0x44 0x45 0x61 0x62 0x63 0x64 0x65
  16099.         In codepage IBM-037 ==> 0xc1 0xc2 0xc3 0xc4 0xc5 0x81 0x82 0x83 0x84 0x85
  16100.    ****************************************************************************/
  16101. }
  16102.  
  16103.  
  16104. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16105.  
  16106. Example of iconv 
  16107.  
  16108.      iconv_close - Remove Conversion Descriptor 
  16109.      iconv_open - Create Conversion Descriptor 
  16110.      setlocale - Set Locale 
  16111.      "Introduction to Locale" in the Programming Guide 
  16112.      <locale.h> 
  16113.  
  16114.  
  16115. ΓòÉΓòÉΓòÉ 4.155. iconv_close - Remove Conversion Descriptor ΓòÉΓòÉΓòÉ
  16116.  
  16117.  
  16118. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16119.  
  16120. #include <iconv.h>
  16121. int iconv_close(iconv_t cd);
  16122.  
  16123.  
  16124. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16125.  
  16126. Language Level:  XPG4 
  16127.  
  16128. iconv_close deallocates the conversion descriptor cd and all other associated 
  16129. resources allocated by the iconv_open function. 
  16130.  
  16131. Return Value 
  16132. If successful, iconv_close returns 0.  Otherwise, iconv_close returns -1 is 
  16133. returned and sets errno to indicate the cause of the error. If cd is not a 
  16134. valid descriptor, an error occurs and iconv_close sets errno to EBADF. 
  16135.  
  16136.  
  16137. ΓòÉΓòÉΓòÉ <hidden> Example of iconv_close ΓòÉΓòÉΓòÉ
  16138.  
  16139. /************************************************************************
  16140.  
  16141. This example shows how you would use iconv_close to remove a conversion 
  16142. descriptor. 
  16143.  
  16144. ************************************************************************/
  16145.  
  16146. #include <iconv.h>
  16147. #include <stdlib.h>
  16148. #include <stdio.h>
  16149.  
  16150. int main(void)
  16151. {
  16152.    const char   fromcode[] = "IBM-850";
  16153.    const char   tocode[] = "IBM-863";
  16154.    iconv_t      cd;
  16155.  
  16156.    if ((iconv_t)(-1) == (cd = iconv_open(tocode, fromcode))) {
  16157.       printf("Failed to iconv_open %s to %s.\n", fromcode, tocode);
  16158.       exit(EXIT_FAILURE);
  16159.    }
  16160.    if (-1 == iconv_close(cd)) {
  16161.       printf("Fail to iconv_close.\n");
  16162.       exit(EXIT_FAILURE);
  16163.    }
  16164.    return 0;
  16165. }
  16166.  
  16167.  
  16168. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16169.  
  16170. Example of iconv_close 
  16171.  
  16172.      iconv - Convert Characters to New Code Set 
  16173.      iconv_open - Create Conversion Descriptor 
  16174.      setlocale - Set Locale 
  16175.      "Introduction to Locale" in the Programming Guide 
  16176.      <locale.h> 
  16177.  
  16178.  
  16179. ΓòÉΓòÉΓòÉ 4.156. iconv_open - Create Conversion Descriptor ΓòÉΓòÉΓòÉ
  16180.  
  16181.  
  16182. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16183.  
  16184. #include <iconv.h>
  16185. iconv_t iconv_open(const char *tocode, const char *fromcode);
  16186.  
  16187.  
  16188. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16189.  
  16190. Language Level:  XPG4 
  16191.  
  16192. iconv_open performs all the initialization needed to convert characters from 
  16193. the encoded character set specified in the array pointed to by fromcode to the 
  16194. encoded character set specified in the array pointed to by tocode. It creates a 
  16195. conversion descriptor that relates the two encoded character sets. You can then 
  16196. use the conversion descriptor with the iconv function to convert characters 
  16197. between the codesets. 
  16198.  
  16199. The conversion descriptor remains valid until you close it with iconv_close. 
  16200.  
  16201. For information about the settings of fromcode, tocode, and their permitted 
  16202. combinations, see the section on internationalization in the Programming Guide. 
  16203.  
  16204. Return Value 
  16205. If successful, iconv_open returns a conversion descriptor of type iconv_t. 
  16206. Otherwise, it returns (iconv_t)-1, and sets errno to indicate the error. If you 
  16207. cannot convert between the encoded character sets specified, an error occurs 
  16208. and iconv_open sets errno to EINVAL. 
  16209.  
  16210.  
  16211. ΓòÉΓòÉΓòÉ <hidden> Example of iconv_open ΓòÉΓòÉΓòÉ
  16212.  
  16213. /************************************************************************
  16214.  
  16215. This example shows how to use iconv_open, iconv, and iconv_close to convert 
  16216. characters from one codeset to another. 
  16217.  
  16218. ************************************************************************/
  16219.  
  16220. #include <iconv.h>
  16221. #include <stdlib.h>
  16222. #include <stdio.h>
  16223.  
  16224. int main(void)
  16225. {
  16226.    const char   fromcode[] = "IBM-932";
  16227.    const char   tocode[] = "IBM-930";
  16228.    iconv_t      cd;
  16229.    char         in[] = "\x81\x40\x81\x80";
  16230.    size_t       in_size = sizeof(in);
  16231.    char         *inptr = in;
  16232.    char         out[100];
  16233.    size_t       out_size = sizeof(out);
  16234.    char         *outptr = out;
  16235.    int          i;
  16236.  
  16237.    if ((iconv_t)(-1) == (cd = iconv_open(tocode, fromcode))) {
  16238.       printf("Failed to iconv_open %s to %s.\n", fromcode, tocode);
  16239.       exit(EXIT_FAILURE);
  16240.    }
  16241.    if ((size_t)(-1) == iconv(cd, &inptr, &in_size, &outptr, &out_size)) {
  16242.       printf("Fail to convert characters to new code set.\n");
  16243.       exit(EXIT_FAILURE);
  16244.    }
  16245.    *outptr = '\0';
  16246.    printf("The hex representation of string %s are:\n  In codepage %s ==> ",
  16247.           in, fromcode);
  16248.    for (i = 0; in[i] != '\0'; i++) {
  16249.       printf("0x%02x ", in[i]);
  16250.    }
  16251.    printf("\n  In codepage %s ==> ", tocode);
  16252.    for (i = 0; out[i] != '\0'; i++) {
  16253.       printf("0x%02x ", out[i]);
  16254.    }
  16255.    if (-1 == iconv_close(cd)) {
  16256.       printf("Fail to iconv_close.\n");
  16257.       exit(EXIT_FAILURE);
  16258.    }
  16259.    return 0;
  16260.  
  16261.    /****************************************************************************
  16262.       The output should be similar to :
  16263.  
  16264.       The hex representation of string ΓöÇ@ΓöÇ╨ö are:
  16265.         In codepage IBM-932 ==> 0x81 0x40 0x81 0x80
  16266.         In codepage IBM-930 ==> 0x0e 0x40 0x40 0x44 0x7b 0x0f
  16267.    ****************************************************************************/
  16268. }
  16269.  
  16270.  
  16271. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16272.  
  16273. Example of iconv_open 
  16274.  
  16275.      iconv - Convert Characters to New Code Set 
  16276.      iconv_close - Remove Conversion Descriptor 
  16277.      setlocale - Set Locale 
  16278.      "Introduction to Locale" in the Programming Guide 
  16279.      <locale.h> 
  16280.  
  16281.  
  16282. ΓòÉΓòÉΓòÉ 4.157. _inp - Read Byte from Input Port ΓòÉΓòÉΓòÉ
  16283.  
  16284.  
  16285. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16286.  
  16287. #include <conio.h>  /* also in <builtin.h>  */
  16288. int _inp(const unsigned int port);
  16289.  
  16290.  
  16291. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16292.  
  16293. Language Level:  Extension 
  16294.  
  16295. _inp reads a byte from the specified input port. The port number must be an 
  16296. unsigned int value in the range 0 to 65 535 inclusive. 
  16297.  
  16298. Note:  _inp is a built-in function, which means it is implemented as an inline 
  16299. instruction and has no backing code in the library.  For this reason: 
  16300.  
  16301.      You cannot take the address of _inp. 
  16302.      You cannot parenthesize a call to _inp. (Parentheses specify a call to 
  16303.       the function's backing code, and _inp has none.) 
  16304.  
  16305.  You can run code containing this function only at ring zero. Otherwise, an 
  16306.  invalid instruction exception is generated. 
  16307.  
  16308.  Return Value 
  16309.  _inp returns the byte value as an integer that was read from the specified 
  16310.  port. There is no error return value, and _inp does not set errno. 
  16311.  
  16312.  
  16313. ΓòÉΓòÉΓòÉ <hidden> Example of _inp ΓòÉΓòÉΓòÉ
  16314.  
  16315. /************************************************************************
  16316.  
  16317. This example uses _inp to read a byte from a specified input port and return 
  16318. the data read. 
  16319.  
  16320. ************************************************************************/
  16321.  
  16322. #include <builtin.h>
  16323.  
  16324. #define LOWER 0
  16325. #define UPPER 65535
  16326.  
  16327. int Add1(int j);
  16328.  
  16329. int    g;
  16330. enum   fruit {apples=10, bananas, cantaloupes};
  16331. int    arr[] = {cantaloupes, bananas, apples};
  16332. struct
  16333. {
  16334.    int  i;
  16335.    char ch;
  16336. } st;
  16337.  
  16338. int main(void)
  16339. {
  16340.    int i;
  16341.    volatile const int c = 0;
  16342.  
  16343.    i = _inp(0);
  16344.    g = _inp(LOWER + 1);    /* put the data read in a global variable  */
  16345.    i = _inp(apples);          /* passing enumerated type as the       */
  16346.                               /* port number                          */
  16347.                               /* ===================================  */
  16348.                               /* Types of port number passed :        */
  16349.                               /* -----------------------------------  */
  16350.    i = _inp(c);               /* - constant                           */
  16351.    i = _inp(arr[c]);          /* - element of array                   */
  16352.    st.i = Add1(c);            /*                                      */
  16353.    i = _inp(st.i);            /* - element of structure               */
  16354.    i = _inp(Add1(LOWER));     /* - return value from a function call  */
  16355.    i = _inp(UPPER);           /* - #define constant                   */
  16356.    i = _inp(256);             /* - the exact port number              */
  16357.                               /* -----------------------------------  */
  16358.    return 0;
  16359. }
  16360.  
  16361. int Add1(int j)
  16362. {
  16363.    j += 1;
  16364.    return j;
  16365. }
  16366.  
  16367.  
  16368. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16369.  
  16370. Example of _inp 
  16371.  
  16372.      _inpw - Read Unsigned Short from Input Port 
  16373.      _inpd - Read Doubleword from Input Port 
  16374.      isatty - Test Handle for Character Device 
  16375.      _outp - Write Byte to Output Port 
  16376.      _outpw - Write Word to Output Port 
  16377.      _outpd - Write Double Word to Output Port 
  16378.      <builtin.h> 
  16379.      <conio.h> 
  16380.  
  16381.  
  16382. ΓòÉΓòÉΓòÉ 4.158. _inpd - Read Doubleword from Input Port ΓòÉΓòÉΓòÉ
  16383.  
  16384.  
  16385. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16386.  
  16387. #include <conio.h>  /* also in <builtin.h> */
  16388. unsigned long _inpd(const unsigned int port);
  16389.  
  16390.  
  16391. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16392.  
  16393. Language Level:  Extension 
  16394.  
  16395. _inpd reads a 4-byte (doubleword) unsigned value from the specified input port. 
  16396. The port number must be an unsigned short value within the range 0 to 65 535 
  16397. inclusive. 
  16398.  
  16399. Note:  _inpd is a built-in function, which means it is implemented as an inline 
  16400. instruction and has no backing code in the library.  For this reason: 
  16401.  
  16402.      You cannot take the address of _inpd. 
  16403.      You cannot parenthesize a call to _inpd. (Parentheses specify a call to 
  16404.       the function's backing code, and _inpd has none.) 
  16405.  
  16406.  You can run code containing this function only at ring zero. Otherwise, an 
  16407.  invalid instruction exception is generated. 
  16408.  
  16409.  Return Value 
  16410.  _inpd returns the value read from the specified port. There is no error return 
  16411.  value, and _inpd does not set errno. 
  16412.  
  16413.  
  16414. ΓòÉΓòÉΓòÉ <hidden> Example of _inpd ΓòÉΓòÉΓòÉ
  16415.  
  16416. /************************************************************************
  16417.  
  16418. This example uses _inpd to read a doubleword value from the specified input 
  16419. port and return the data read. 
  16420.  
  16421. ************************************************************************/
  16422.  
  16423. #include <builtin.h>
  16424.  
  16425. #define LOWER 0
  16426. #define UPPER 65535
  16427.  
  16428. int Add1(int j);
  16429.  
  16430. static long g;
  16431. enum        fruit {apples=10, bananas, cantaloupes};
  16432. int         arr[] = {cantaloupes, bananas, apples};
  16433. union
  16434. {
  16435.    int  i;
  16436.    char ch;
  16437. } un;
  16438.  
  16439. int main(void)
  16440. {
  16441.    unsigned long      l;
  16442.    volatile const int c = 0;
  16443.  
  16444.    un.i = 65534;
  16445.    g = _inpd(255);         /* put the data read in a global variable  */
  16446.                                        /* =========================== */
  16447.                                        /* Types of port number passed:*/
  16448.                                        /* --------------------------- */
  16449.    l = _inpd(c);                       /* - constant                  */
  16450.    l = _inpd(un.i);                    /* - element of union          */
  16451.    l = _inpd(Add1(cantaloupes));        /* - return value from a       */
  16452.                                        /*   function call             */
  16453.    l = _inpd(_inp(arr[Add1(LOWER)]));  /* - return value from a       */
  16454.                                        /*   builtin function call     */
  16455.                                        /* --------------------------- */
  16456.    return 0;
  16457. }
  16458.  
  16459. int Add1(int j)
  16460. {
  16461.    j += 1;
  16462.    return j;
  16463. }
  16464.  
  16465.  
  16466. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16467.  
  16468. Example of _inpd 
  16469.  
  16470.      _inp - Read Byte from Input Port 
  16471.      _inpw - Read Unsigned Short from Input Port 
  16472.      isatty - Test Handle for Character Device 
  16473.      _outp - Write Byte to Output Port 
  16474.      _outpw - Write Word to Output Port 
  16475.      _outpd - Write Double Word to Output Port 
  16476.      <builtin.h> 
  16477.      <conio.h> 
  16478.  
  16479.  
  16480. ΓòÉΓòÉΓòÉ 4.159. _inpw - Read Unsigned Short from Input Port ΓòÉΓòÉΓòÉ
  16481.  
  16482.  
  16483. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16484.  
  16485. #include <conio.h>  /* also in <builtin.h> */
  16486. unsigned short _inpw(const unsigned int port);
  16487.  
  16488.  
  16489. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16490.  
  16491. Language Level:  Extension 
  16492.  
  16493. _inpw reads an unsigned short value from the specified input port. The port 
  16494. number must be an unsigned short value within the range 0 to 65 535 inclusive. 
  16495.  
  16496. Note:  _inpw is a built-in function, which means it is implemented as an inline 
  16497. instruction and has no backing code in the library.  For this reason: 
  16498.  
  16499.      You cannot take the address of _inpw. 
  16500.      You cannot parenthesize a call to _inpw. (Parentheses specify a call to 
  16501.       the function's backing code, and _inpw has none.) 
  16502.  
  16503.  You can run code containing this function only at ring zero. Otherwise, an 
  16504.  invalid instruction exception is generated. 
  16505.  
  16506.  Return Value 
  16507.  _inpw returns the value read from the specified port. There is no error return 
  16508.  value, and _inpw does not set errno. 
  16509.  
  16510.  
  16511. ΓòÉΓòÉΓòÉ <hidden> Example of _inpw ΓòÉΓòÉΓòÉ
  16512.  
  16513. /************************************************************************
  16514.  
  16515. This example uses _inpw to read an unsigned short value from the specified 
  16516. input port and return the data read. 
  16517.  
  16518. ************************************************************************/
  16519.  
  16520. #include <builtin.h>
  16521.  
  16522. #define LOWER 0
  16523. #define UPPER 65535
  16524.  
  16525. int Add1(int j);
  16526.  
  16527. volatile short g;
  16528.  
  16529. int main(void)
  16530. {
  16531.    volatile unsigned short s;
  16532.    volatile const int c = 0;
  16533.    int i = 65534;
  16534.    enum fruit {apples, bananas, cantaloupes};
  16535.    int arr[] = {cantaloupes, bananas, apples};
  16536.  
  16537.    g = _inpw(LOWER);       /* put the data read in a global variable  */
  16538.    s = _inpw(bananas);                 /* passing enumerated type     */
  16539.                                        /* as the port number          */
  16540.                                        /* =========================== */
  16541.                                        /* Types of port number passed:*/
  16542.                                        /* --------------------------- */
  16543.    s = _inpw(c);                       /* - constant                  */
  16544.    s = _inpw(i+1);                     /* - integer                   */
  16545.    s = _inpw(arr[bananas]);            /* - element of array          */
  16546.    s = _inpw(_outp(UPPER,cantaloupes)); /* - return value from a       */
  16547.                                        /*   builtin function call     */
  16548.                                        /* --------------------------- */
  16549.    return 0;
  16550. }
  16551.  
  16552. int Add1(int j)
  16553. {
  16554.    j += 1;
  16555.    return j;
  16556. }
  16557.  
  16558.  
  16559. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16560.  
  16561. Example of _inpw 
  16562.  
  16563.      _inp - Read Byte from Input Port 
  16564.      _inpd - Read Doubleword from Input Port 
  16565.      isatty - Test Handle for Character Device 
  16566.      _outp - Write Byte to Output Port 
  16567.      _outpw - Write Word to Output Port 
  16568.      _outpd - Write Double Word to Output Port 
  16569.      <builtin.h> 
  16570.      <conio.h> 
  16571.  
  16572.  
  16573. ΓòÉΓòÉΓòÉ 4.160. _interrupt - Call Interrupt  Procedure ΓòÉΓòÉΓòÉ
  16574.  
  16575.  
  16576. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16577.  
  16578. #include <builtin.h>
  16579. void _interrupt(const unsigned int intnum);
  16580.  
  16581.  
  16582. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16583.  
  16584. Language Level:  Extension 
  16585.  
  16586. _interrupt calls the interrupt procedure specified by intnum using the INT 
  16587. machine instruction. The integer intnum must have a value within the range 0 to 
  16588. 255 inclusive. 
  16589.  
  16590. Note:  _interrupt is a built-in function, which means it is implemented as an 
  16591. inline instruction and has no backing code in the library.  For this reason: 
  16592.  
  16593.      You cannot take the address of _interrupt. 
  16594.      You cannot parenthesize a call to _interrupt. (Parentheses specify a call 
  16595.       to the function's backing code, and _interrupt has none.) 
  16596.  
  16597.  Return Value 
  16598.  There is no return value, and _interrupt does not set errno. 
  16599.  
  16600.  
  16601. ΓòÉΓòÉΓòÉ <hidden> Example of _interrupt ΓòÉΓòÉΓòÉ
  16602.  
  16603. /************************************************************************
  16604.  
  16605. This example calls interrupt 3, which is a breakpoint. 
  16606.  
  16607. ************************************************************************/
  16608.  
  16609. #include <builtin.h>
  16610.  
  16611. int main(void)
  16612. {
  16613.    /* A breakpoint will occur when running this program */
  16614.    /* within a debugger.                                */
  16615.    _interrupt(3);
  16616.  
  16617.    return 0;
  16618. }
  16619.  
  16620.  
  16621. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16622.  
  16623. Example of _interrupt 
  16624.  
  16625.      _disable - Disable Interrupts 
  16626.      _enable - Enable Interrupts 
  16627.      <builtin.h> 
  16628.  
  16629.  
  16630. ΓòÉΓòÉΓòÉ 4.161. isalnum to isxdigit - Test Integer Value ΓòÉΓòÉΓòÉ
  16631.  
  16632.  
  16633. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16634.  
  16635. #include <ctype.h>
  16636.                               /* test for:              */
  16637. int isalnum(int c);  /* alphanumeric character */
  16638. int isalpha(int c);  /* alphabetic character   */
  16639. int iscntrl(int c);  /* control character      */
  16640. int isdigit(int c);  /* decimal digit          */
  16641. int isgraph(int c);  /* printable character, excluding space */
  16642. int islower(int c);  /* lowercase character    */
  16643. int isprint(int c);  /* printable character, including space */
  16644. int ispunct(int c);  /* nonalphanumeric printable character, excluding space */
  16645. int isspace(int c);  /* whitespace character   */
  16646. int isupper(int c);  /* uppercase character    */
  16647. int isxdigit(int c); /* hexadecimal digit      */
  16648.  
  16649.  
  16650. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16651.  
  16652. Language Level:  ANSI, SAA, POSIX, XPG4 
  16653.  
  16654. These functions test a given integer value c to determine if it has a certain 
  16655. property as defined by the LC_CTYPE category of your current locale. The value 
  16656. of c must be representable as an unsigned char, or EOF. 
  16657.  
  16658. The functions test for the following: 
  16659.  
  16660.  isalnum 
  16661.     Alphanumeric character (upper- or lowercase letter, or decimal digit), as 
  16662.     defined in the locale source file in the alnum class of the LC_CTYPE 
  16663.     category of the current locale. 
  16664.  
  16665.  isalpha 
  16666.     Alphabetic character, as defined in the locale source file in the alpha 
  16667.     class of the LC_CTYPE category of the current locale. 
  16668.  
  16669.  iscntrl 
  16670.     Control character, as defined in the locale source file in the cntrl class 
  16671.     of the LC_CTYPE category of the current locale. 
  16672.  
  16673.  isdigit 
  16674.     Decimal digit (0 through 9), as defined in the locale source file in the 
  16675.     digit class of the LC_CTYPE category of the current locale. 
  16676.  
  16677.  isgraph 
  16678.     Printable character, excluding the space character, as defined in the 
  16679.     locale source file in the graph class of the LC_CTYPE category of the 
  16680.     current locale. 
  16681.  
  16682.  islower 
  16683.     Lowercase letter, as defined in the locale source file in the lower class 
  16684.     of the LC_CTYPE category of the current locale. 
  16685.  
  16686.  isprint 
  16687.     Printable character, including the space character, as defined in the 
  16688.     locale source file in the print class of the LC_CTYPE category of the 
  16689.     current locale. 
  16690.  
  16691.  ispunct 
  16692.     Nonalphanumeric printable character, excluding the space character, as 
  16693.     defined in the locale source file in the punct class of the LC_CTYPE 
  16694.     category of the current locale. 
  16695.  
  16696.  isspace 
  16697.     White-space character, as defined in the locale source file in the space 
  16698.     class of the LC_CTYPE category of the current locale. 
  16699.  
  16700.  isupper 
  16701.     Uppercase letter, as defined in the locale source file in the upper class 
  16702.     of the LC_CTYPE category of the current locale. 
  16703.  
  16704.  isxdigit 
  16705.     Hexadecimal digit (0 through 9, a through f, or A through F), as defined in 
  16706.     the locale source file in the xdigit class of the LC_CTYPE category of the 
  16707.     current locale. 
  16708.  
  16709.  You can redefine any character class in the LC_CTYPE category of the current 
  16710.  locale, with some restrictions. See the section about the LC_CTYPE class in 
  16711.  the Programming Guide for details about these restrictions. 
  16712.  
  16713.  Return Value 
  16714.  These functions return a nonzero value if the integer satisfies the test 
  16715.  condition, or 0 if it does not. 
  16716.  
  16717.  
  16718. ΓòÉΓòÉΓòÉ <hidden> Example of isalnum to isxdigit ΓòÉΓòÉΓòÉ
  16719.  
  16720. /************************************************************************
  16721.  
  16722. This example analyzes all characters between 0x0 and 0xFF. The output of this 
  16723. example is a 256-line table showing the characters from 0 to 255, indicating 
  16724. whether they have the properties tested for. 
  16725.  
  16726. ************************************************************************/
  16727.  
  16728. #include <stdio.h>
  16729. #include <ctype.h>
  16730. #include <locale.h>
  16731.  
  16732. #define UPPER_LIMIT   0xFF
  16733.  
  16734. int main(void)
  16735. {
  16736.    int ch;
  16737.  
  16738.    setlocale(LC_ALL, LC_C_USA);
  16739.  
  16740.    for (ch = 0; ch <= UPPER_LIMIT; ++ch) {
  16741.       printf("%#04x ", ch);
  16742.       printf("%c", isprint(ch)  ? ch     : ' ');
  16743.       printf("%s", isalnum(ch)  ? " AN"  : "   ");
  16744.       printf("%s", isalpha(ch)  ? " A "  : "   ");
  16745.       printf("%s", iscntrl(ch)  ? " C "  : "   ");
  16746.       printf("%s", isdigit(ch)  ? " D "  : "   ");
  16747.       printf("%s", isgraph(ch)  ? " G "  : "   ");
  16748.       printf("%s", islower(ch)  ? " L "  : "   ");
  16749.       printf("%s", ispunct(ch)  ? " PU"  : "   ");
  16750.       printf("%s", isspace(ch)  ? " S "  : "   ");
  16751.       printf("%s", isprint(ch)  ? " PR"  : "   ");
  16752.       printf("%s", isupper(ch)  ? " U "  : "   ");
  16753.       printf("%s", isxdigit(ch) ? " H "  : "   ");
  16754.       putchar('\n');
  16755.    }
  16756.    return 0;
  16757.  
  16758.    /****************************************************************************
  16759.       The output should be similar to :
  16760.       :
  16761.       0x20                        S  PR
  16762.       0x21 !             G     PU    PR
  16763.       0x22 "             G     PU    PR
  16764.       0x23 #             G     PU    PR
  16765.       0x24 $             G     PU    PR
  16766.       0x25 %             G     PU    PR
  16767.       0x26 &             G     PU    PR
  16768.       0x27 '             G     PU    PR
  16769.       0x28 (             G     PU    PR
  16770.       0x29 )             G     PU    PR
  16771.       0x2a *             G     PU    PR
  16772.       0x2b +             G     PU    PR
  16773.       0x2c ,             G     PU    PR
  16774.       0x2d -             G     PU    PR
  16775.       0x2e .             G     PU    PR
  16776.       0x2f /             G     PU    PR
  16777.       0x30 0 AN       D  G           PR    H
  16778.       0x31 1 AN       D  G           PR    H
  16779.       0x32 2 AN       D  G           PR    H
  16780.       0x33 3 AN       D  G           PR    H
  16781.       0x34 4 AN       D  G           PR    H
  16782.       0x35 5 AN       D  G           PR    H
  16783.       0x36 6 AN       D  G           PR    H
  16784.       0x37 7 AN       D  G           PR    H
  16785.       0x38 8 AN       D  G           PR    H
  16786.       0x39 9 AN       D  G           PR    H
  16787.       :
  16788.    ****************************************************************************/
  16789. }
  16790.  
  16791.  
  16792. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16793.  
  16794. Example of isalnum to isxdigit 
  16795.  
  16796.      isascii - Test Integer Values 
  16797.      _iscsym - _iscsymf - Test Integer 
  16798.      iswalnum to iswxdigit - Test Wide Integer Value 
  16799.      setlocale - Set Locale 
  16800.      tolower() - toupper() - Convert Character Case 
  16801.      _toascii - _tolower - _toupper - Convert Character 
  16802.      <ctype.h> 
  16803.  
  16804.  
  16805. ΓòÉΓòÉΓòÉ 4.162. isascii - Test Integer Values ΓòÉΓòÉΓòÉ
  16806.  
  16807.  
  16808. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16809.  
  16810. #include <ctype.h>
  16811. int isascii(int c);
  16812.  
  16813.  
  16814. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16815.  
  16816. Language Level:  XPG4, Extension 
  16817.  
  16818. isascii tests if an integer is within the ASCII range.  This macro assumes that 
  16819. the system uses the ASCII character set. 
  16820.  
  16821. Note:  In earlier releases of C Set ++, isascii began with an underscore 
  16822. (_isascii). Because it is defined by the X/Open standard, the underscore has 
  16823. been removed. For compatibility, VisualAge C++ will map _isascii to isascii for 
  16824. you. 
  16825.  
  16826. Return Value 
  16827. isascii returns a nonzero value if the integer is within the ASCII set, and 0 
  16828. if it is not. 
  16829.  
  16830.  
  16831. ΓòÉΓòÉΓòÉ <hidden> Example of isascii ΓòÉΓòÉΓòÉ
  16832.  
  16833. /************************************************************************
  16834.  
  16835. This example tests the integers from 0x7c to 0x82, and prints the corresponding 
  16836. ASCII character if the integer is within the ASCII range. 
  16837.  
  16838. ************************************************************************/
  16839.  
  16840. #include <stdio.h>
  16841. #include <ctype.h>
  16842.  
  16843. int main(void)
  16844. {
  16845.    int ch;
  16846.  
  16847.    for (ch = 0x7c; ch <= 0x82; ch++) {
  16848.       printf("%#04x    ", ch);
  16849.       if (isascii(ch))
  16850.          printf("The ASCII character is %c\n", ch);
  16851.       else
  16852.          printf("Not an ASCII character\n");
  16853.    }
  16854.    return 0;
  16855.  
  16856.    /****************************************************************************
  16857.       The output should be:
  16858.  
  16859.       0x7c    The ASCII character is |
  16860.       0x7d    The ASCII character is }
  16861.       0x7e    The ASCII character is ~
  16862.       0x7f    The ASCII character is 
  16863.       0x80    Not an ASCII character
  16864.       0x81    Not an ASCII character
  16865.       0x82    Not an ASCII character
  16866.    ****************************************************************************/
  16867. }
  16868.  
  16869.  
  16870. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16871.  
  16872. Example of isascii 
  16873.  
  16874.      isalnum to isxdigit - Test Integer Value 
  16875.      _iscsym - _iscsymf - Test Integer 
  16876.      iswalnum to iswxdigit - Test Wide Integer Value 
  16877.      _toascii - _tolower - _toupper - Convert Character 
  16878.      tolower() - toupper() - Convert Character Case 
  16879.      <ctype.h> 
  16880.  
  16881.  
  16882. ΓòÉΓòÉΓòÉ 4.163. isatty - Test Handle for Character Device ΓòÉΓòÉΓòÉ
  16883.  
  16884.  
  16885. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16886.  
  16887. #include <io.h>
  16888. int isatty(int handle);
  16889.  
  16890.  
  16891. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16892.  
  16893. Language Level:  XPG4, Extension 
  16894.  
  16895. isatty determines whether the given handle is associated with a character 
  16896. device (a keyboard, display, or printer or serial port). 
  16897.  
  16898. Note:  In earlier releases of C Set ++, isatty began with an underscore 
  16899. (_isatty). Because it is defined by the X/Open standard, the underscore has 
  16900. been removed. For compatibility, VisualAge C++ will map _isatty to isatty for 
  16901. you. 
  16902.  
  16903. Return Value 
  16904. isatty returns a nonzero value if the device is a character device. Otherwise, 
  16905. the return value is 0. 
  16906.  
  16907.  
  16908. ΓòÉΓòÉΓòÉ <hidden> Example of isatty ΓòÉΓòÉΓòÉ
  16909.  
  16910. /************************************************************************
  16911.  
  16912. This example opens the console and determines if it is a character device: 
  16913.  
  16914. ************************************************************************/
  16915.  
  16916. #include <io.h>
  16917. #include <stdio.h>
  16918. #include <stdlib.h>
  16919. #include <fcntl.h>
  16920. #include <sys\stat.h>
  16921.  
  16922. int main(void)
  16923. {
  16924.    int fh,result;
  16925.  
  16926.    if (-1 == (fh = open("CON", O_RDWR, (S_IREAD|S_IWRITE)))) {
  16927.       perror("Error opening console\n");
  16928.       return EXIT_FAILURE;
  16929.    }
  16930.    result = isatty(fh);
  16931.    if (0 != result)
  16932.       printf("CON is a character device.\n");
  16933.    else
  16934.       printf("CON is not a character device.\n");
  16935.    close(fh);
  16936.    return 0;
  16937.  
  16938.    /****************************************************************************
  16939.       The output should be:
  16940.  
  16941.       CON is a character device.
  16942.    ****************************************************************************/
  16943. }
  16944.  
  16945.  
  16946. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  16947.  
  16948. Example of isatty 
  16949.  
  16950.      _inp - Read Byte from Input Port 
  16951.      _inpd - Read Doubleword from Input Port 
  16952.      _inpw - Read Unsigned Short from Input Port 
  16953.      _outp - Write Byte to Output Port 
  16954.      _outpd - Write Double Word to Output Port 
  16955.      _outpw - Write Word to Output Port 
  16956.      <io.h> 
  16957.  
  16958.  
  16959. ΓòÉΓòÉΓòÉ 4.164. isblank - Test for Blank Character Classification ΓòÉΓòÉΓòÉ
  16960.  
  16961.  
  16962. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  16963.  
  16964. #include <ctype.h>
  16965. int isblank(int c);
  16966.  
  16967.  
  16968. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  16969.  
  16970. Language Level:  Extension 
  16971.  
  16972. isblank tests whether the current LC_CTYPE locale category assigns c the blank 
  16973. character attribute. 
  16974.  
  16975. The value for c must be representable as an unsigned character, or EOF. 
  16976.  
  16977. In the "POSIX" and "C" locales, the tab and space characters have the blank 
  16978. attribute. 
  16979.  
  16980. Return Value 
  16981. isblank returns a nonzero value if the integer c has the blank attribute; 0 if 
  16982. it does not. 
  16983.  
  16984.  
  16985. ΓòÉΓòÉΓòÉ <hidden> Example of isblank ΓòÉΓòÉΓòÉ
  16986.  
  16987. /************************************************************************
  16988.  
  16989. This example tests if c is a blank type. 
  16990.  
  16991. ************************************************************************/
  16992.  
  16993. #include <ctype.h>
  16994. #include <locale.h>
  16995. #include <stdio.h>
  16996.  
  16997. void check(char c) {
  16998.    if ((' ' != c) && (isprint(c)))
  16999.       printf("  %c is ", c);
  17000.    else
  17001.       printf("x%02x is ", c);
  17002.    if (!isblank(c))
  17003.       printf("not ");
  17004.    puts("a blank type character");
  17005.    return;
  17006. }
  17007.  
  17008. int main(void)
  17009. {
  17010.    printf("In LC_CTYPE category of locale name \"%s\":\n",
  17011.           setlocale(LC_CTYPE, NULL));
  17012.    check('a');
  17013.    check(' ');
  17014.    check(0x00);
  17015.    check('\n');
  17016.    check('\t');
  17017.    return 0;
  17018.  
  17019.    /****************************************************************************
  17020.       The output should be similar to :
  17021.  
  17022.       In LC_CTYPE category of locale name "C":
  17023.         a is not a blank type character
  17024.       x20 is a blank type character
  17025.       x00 is not a blank type character
  17026.       x0a is not a blank type character
  17027.       x09 is a blank type character
  17028.    ****************************************************************************/
  17029. }
  17030.  
  17031.  
  17032. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17033.  
  17034. Example of isblank 
  17035.  
  17036.      isalnum to isxdigit - Test Integer Value 
  17037.      isascii - Test Integer Values 
  17038.      _iscsym - _iscsymf - Test Integer 
  17039.      iswalnum to iswxdigit - Test Wide Integer Value 
  17040.      iswblank - Test for Wide Blank Character Classification 
  17041.      setlocale - Set Locale 
  17042.      <ctype.h> 
  17043.  
  17044.  
  17045. ΓòÉΓòÉΓòÉ 4.165. _iscsym - _iscsymf - Test Integer ΓòÉΓòÉΓòÉ
  17046.  
  17047.  
  17048. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17049.  
  17050. #include <ctype.h>
  17051. int _iscsym(int c);
  17052. int _iscsymf(int c);
  17053.  
  17054.  
  17055. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17056.  
  17057. _iscsymf macro tests if a character is alphabetic or an underscore (_). 
  17058.  
  17059. Language Level:  Extension 
  17060.  
  17061. These macros test if an integer is within a particular ASCII set. The macros 
  17062. assume that the system uses the ASCII character set. 
  17063.  
  17064. _iscsym tests if a character is alphabetic, a digit, or an underscore (_). 
  17065. _iscsymf tests is a character is alphabetic or an underscore. 
  17066.  
  17067. Return Value 
  17068. _iscsym and _iscsymf return a nonzero value if the integer is within the ASCII 
  17069. set for which it tests, and 0 if it is not. 
  17070.  
  17071.  
  17072. ΓòÉΓòÉΓòÉ <hidden> Example of _iscsym - _iscsymf ΓòÉΓòÉΓòÉ
  17073.  
  17074. /************************************************************************
  17075.  
  17076. This example uses _iscsym and _iscsymf to test the characters a, _, and 1. If 
  17077. the character falls within the ASCII set tested for, the macro returns TRUE. 
  17078. Otherwise, it returns FALSE. 
  17079.  
  17080. ************************************************************************/
  17081.  
  17082. #include <stdio.h>
  17083. #include <ctype.h>
  17084.  
  17085. int main(void)
  17086. {
  17087.    int ch[3] =  { 'a','_','1' };
  17088.    int i;
  17089.  
  17090.    for (i = 0; i < 3; i++) {
  17091.       printf("_iscsym('%c') returns %s\n", ch[i], _iscsym(ch[i])?"TRUE":"FALSE");
  17092.       printf("_iscsymf('%c') returns %s\n\n", ch[i], _iscsymf(ch[i])?"TRUE":
  17093.          "FALSE");
  17094.    }
  17095.    return 0;
  17096.  
  17097.    /****************************************************************************
  17098.       The output should be:
  17099.  
  17100.       _iscsym('a') returns TRUE
  17101.       _iscsymf('a') returns TRUE
  17102.  
  17103.       _iscsym('_') returns TRUE
  17104.       _iscsymf('_') returns TRUE
  17105.  
  17106.       _iscsym('1') returns TRUE
  17107.       _iscsymf('1') returns FALSE
  17108.    ****************************************************************************/
  17109. }
  17110.  
  17111.  
  17112. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17113.  
  17114. Example of _iscsym - _iscsymf 
  17115.  
  17116.      isalnum to isxdigit - Test Integer Value 
  17117.      isascii - Test Integer Values 
  17118.      isblank - Test for Blank Character Classification 
  17119.      iswalnum to iswxdigit - Test Wide Integer Value 
  17120.      iswblank - Test for Wide Blank Character Classification 
  17121.      tolower() - toupper() - Convert Character Case 
  17122.      _toascii - _tolower - _toupper - Convert Character 
  17123.      <ctype.h> 
  17124.  
  17125.  
  17126. ΓòÉΓòÉΓòÉ 4.166. ismccollel - Identify Multi-Character Collating Element ΓòÉΓòÉΓòÉ
  17127.  
  17128.  
  17129. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17130.  
  17131. #include <collate.h>
  17132. int ismccollel(collel_t c);
  17133.  
  17134.  
  17135. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17136.  
  17137. Language Level:  Extension 
  17138.  
  17139. ismccollel determines whether the collel_t value represents a multicharacter 
  17140. collating element. 
  17141.  
  17142. A collating element is a glyph, usually a character, that has a value that 
  17143. defines its order in a collating sequence. A multicharacter collating element 
  17144. is a sequence of two or more characters that are to be collated as one entity. 
  17145.  
  17146. Note:  If c is greater than 255 and is not a multicharacter collating element, 
  17147. as determined by the LC_COLLATE category of the current locale, it is a 
  17148. multibyte character. c is the wide character representation for the multibyte 
  17149. character. 
  17150.  
  17151. Return Value 
  17152. ismccollel returns: 
  17153.  
  17154.  1    if c represents a multi-character collating element. 
  17155.  0    if c represents a single-character collating element. 
  17156.  -1   if c is out of range or otherwise invalid. 
  17157.  
  17158.  
  17159. ΓòÉΓòÉΓòÉ <hidden> Example of ismccollel ΓòÉΓòÉΓòÉ
  17160.  
  17161. /************************************************************************
  17162.  
  17163. This example prints all the collating elements in the collating sequence by 
  17164. using the ismccollel function to determine if the collating element is a 
  17165. multicharacter collating element. 
  17166.  
  17167. ************************************************************************/
  17168.  
  17169. #include <stdio.h>
  17170. #include <locale.h>
  17171. #include <collate.h>
  17172. #include <wchar.h>
  17173.  
  17174. int main(void)
  17175. {
  17176.    collel_t *rp;
  17177.    int      i;
  17178.  
  17179.    setlocale(LC_ALL, LC_C_FRANCE);
  17180.    i = collorder(&rp);
  17181.    for (; i > 0; rp++, i--) {
  17182.       if (ismccollel(*rp))
  17183.          printf("'%s' ", colltostr(*rp));
  17184.       else if (iswprint(*rp))
  17185.               printf("'%lc' ", *rp);
  17186.            else
  17187.               printf("'%x' ", *rp);
  17188.    }
  17189.    return 0;
  17190.  
  17191.    /****************************************************************************
  17192.       The output should be similar to :
  17193.        :
  17194.        :
  17195.       ' ' '!' '"' '#' '$' '%' '&' '(' ''' ')' '-' '*' 'Du ' 'Des ' 'De ' 'D''
  17196.       'Les ' 'Le ' 'La ' 'L'' 'du ' 'des ' 'de ' 'd'' 'les ' 'le ' 'la ' 'l''
  17197.       '+' ',' '.' '/'
  17198.       '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' ':' ';' '<' '=' '>' '?'
  17199.       '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O'
  17200.       'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '[' '\' ']' '^' '_'
  17201.        :
  17202.    ****************************************************************************/
  17203. }
  17204.  
  17205.  
  17206. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17207.  
  17208. Example of ismccollel 
  17209.  
  17210.      cclass - Return Characters in Character Class 
  17211.      collequiv - Return List of Equivalent Collating Elements 
  17212.      collorder - Return List of Collating Elements 
  17213.      collrange - Calculate Range of Collating Elements 
  17214.      colltostr - Return String for Collating Element 
  17215.      getmccoll - Get Next Collating Element from String 
  17216.      getwmccoll - Get Next Collating Element from Wide String 
  17217.      maxcoll - Return Maximum Collating Element 
  17218.      strtocoll - Return Collating Element for String 
  17219.      <collate.h> 
  17220.  
  17221.  
  17222. ΓòÉΓòÉΓòÉ 4.167. iswalnum to iswxdigit - Test Wide Integer Value ΓòÉΓòÉΓòÉ
  17223.  
  17224.  
  17225. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17226.  
  17227. #include <wctype.h>
  17228.                              /* test for:     */
  17229. int iswalnum(wint_t wc);  /* wide alphanumeric character */
  17230. int iswalpha(wint_t wc);  /* wide alphabetic character   */
  17231. int iswcntrl(wint_t wc);  /* wide control character      */
  17232. int iswdigit(wint_t wc);  /* wide decimal digit          */
  17233. int iswgraph(wint_t wc);  /* wide printable character, excluding space */
  17234. int iswlower(wint_t wc);  /* wide lowercase character    */
  17235. int iswprint(wint_t wc);  /* wide printable character, including space */
  17236. int iswpunct(wint_t wc);  /* wide punctuation character, excluding space */
  17237. int iswspace(wint_t wc);  /* wide whitespace character   */
  17238. int iswupper(wint_t wc);  /* wide uppercase character    */
  17239. int iswxdigit(wint_t wc); /* wide hexadecimal digit      */
  17240.  
  17241.  
  17242. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17243.  
  17244. Language Level:  ANSI 93, POSIX, XPG4 
  17245.  
  17246. These functions test a given wide integer value wc to determine whether it has 
  17247. a certain property as defined by the LC_CTYPE category of your current locale. 
  17248. The value of wc must be representable as a wchar_t, or WEOF. 
  17249.  
  17250. The functions test for the following: 
  17251.  
  17252.  iswalnum 
  17253.     Wide alphanumeric character (upper- or lowercase letter, or decimal digit), 
  17254.     as defined in the locale source file in the alnum class of the LC_CTYPE 
  17255.     category of the current locale. 
  17256.  
  17257.  iswalpha 
  17258.     Wide alphabetic character, as defined in the locale source file in the 
  17259.     alpha class of the LC_CTYPE category of the current locale. 
  17260.  
  17261.  iswcntrl 
  17262.     Wide control character, as defined in the locale source file in the cntrl 
  17263.     class of the LC_CTYPE category of the current locale. 
  17264.  
  17265.  iswdigit 
  17266.     Wide decimal digit (0 through 9), as defined in the locale source file in 
  17267.     the digit class of the LC_CTYPE category of the current locale. 
  17268.  
  17269.  iswgraph 
  17270.     Wide printable character, excluding the space character, as defined in the 
  17271.     locale source file in the graph class of the LC_CTYPE category of the 
  17272.     current locale. 
  17273.  
  17274.  iswlower 
  17275.     Wide lowercase letter, as defined in the locale source file in the lower 
  17276.     class of the LC_CTYPE category of the current locale. 
  17277.  
  17278.  iswprint 
  17279.     Wide printable character, including the space character, as defined in the 
  17280.     locale source file in the print class of the LC_CTYPE category of the 
  17281.     current locale. 
  17282.  
  17283.  iswpunct 
  17284.     Wide non-alphanumeric printable character, excluding the space character, 
  17285.     as defined in the locale source file in the punct class of the LC_CTYPE 
  17286.     category of the current locale. 
  17287.  
  17288.  iswspace 
  17289.     Wide white-space character, as defined in the locale source file in the 
  17290.     space class of the LC_CTYPE category of the current locale. 
  17291.  
  17292.  iswupper 
  17293.     Wide uppercase letter, as defined in the locale source file in the upper 
  17294.     class of the LC_CTYPE category of the current locale. 
  17295.  
  17296.  iswxdigit 
  17297.     Wide hexadecimal digit (0 through 9, a through f, or A through F), as 
  17298.     defined in the locale source file in the xdigit class of the LC_CTYPE 
  17299.     category of the current locale. 
  17300.  You can redefine any character class in the LC_CTYPE category of the current 
  17301.  locale.  For more information, see "Introduction to Locales" in the 
  17302.  Programming Guide. 
  17303.  
  17304.  Return Value 
  17305.  These functions return a nonzero value if the wide integer satisfies the test 
  17306.  value; 0 if it does not. 
  17307.  
  17308.  
  17309. ΓòÉΓòÉΓòÉ <hidden> Example of iswalnum to iswxdigit ΓòÉΓòÉΓòÉ
  17310.  
  17311. /************************************************************************
  17312.  
  17313. This example analyzes all characters between 0x0 and 0xFF. The output of this 
  17314. example is a 256-line table showing the characters from 0 to 255, indicating 
  17315. whether they have the properties tested for. 
  17316.  
  17317. ************************************************************************/
  17318.  
  17319. #include <locale.h>
  17320. #include <stdio.h>
  17321. #include <wctype.h>
  17322.  
  17323. #define UPPER_LIMIT   0xFF
  17324.  
  17325. int main(void)
  17326. {
  17327.    wint_t wc;
  17328.  
  17329.    setlocale(LC_ALL, LC_C_USA);
  17330.  
  17331.    for (wc = 0; wc <= UPPER_LIMIT; wc++) {
  17332.       printf("%#4x ", wc);
  17333.       printf("%c", iswprint(wc)  ? wc    : ' ');
  17334.       printf("%s", iswalnum(wc)  ? " AN" : "   ");
  17335.       printf("%s", iswalpha(wc)  ? " A " : "   ");
  17336.       printf("%s", iswcntrl(wc)  ? " C " : "   ");
  17337.       printf("%s", iswdigit(wc)  ? " D " : "   ");
  17338.       printf("%s", iswgraph(wc)  ? " G " : "   ");
  17339.       printf("%s", iswlower(wc)  ? " L " : "   ");
  17340.       printf("%s", iswpunct(wc)  ? " PU" : "   ");
  17341.       printf("%s", iswspace(wc)  ? " S " : "   ");
  17342.       printf("%s", iswprint(wc)  ? " PR" : "   ");
  17343.       printf("%s", iswupper(wc)  ? " U " : "   ");
  17344.       printf("%s", iswxdigit(wc) ? " H " : "   ");
  17345.       putchar('\n');
  17346.    }
  17347.    return 0;
  17348.  
  17349.    /****************************************************************************
  17350.       The output should be similar to :
  17351.       :
  17352.       0x20                        S  PR
  17353.       0x21 !             G     PU    PR
  17354.       0x22 "             G     PU    PR
  17355.       0x23 #             G     PU    PR
  17356.       0x24 $             G     PU    PR
  17357.       0x25 %             G     PU    PR
  17358.       0x26 &             G     PU    PR
  17359.       0x27 '             G     PU    PR
  17360.       0x28 (             G     PU    PR
  17361.       0x29 )             G     PU    PR
  17362.       0x2a *             G     PU    PR
  17363.       0x2b +             G     PU    PR
  17364.       0x2c ,             G     PU    PR
  17365.       0x2d -             G     PU    PR
  17366.       0x2e .             G     PU    PR
  17367.       0x2f /             G     PU    PR
  17368.       0x30 0 AN       D  G           PR    H
  17369.       0x31 1 AN       D  G           PR    H
  17370.       0x32 2 AN       D  G           PR    H
  17371.       0x33 3 AN       D  G           PR    H
  17372.       0x34 4 AN       D  G           PR    H
  17373.       0x35 5 AN       D  G           PR    H
  17374.       0x36 6 AN       D  G           PR    H
  17375.       0x37 7 AN       D  G           PR    H
  17376.       0x38 8 AN       D  G           PR    H
  17377.       0x39 9 AN       D  G           PR    H
  17378.       :
  17379.    ****************************************************************************/
  17380. }
  17381.  
  17382.  
  17383. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17384.  
  17385. Example of iswalnum to iswxdigit 
  17386.  
  17387.      isalnum to isxdigit - Test Integer Value 
  17388.      isascii - Test Integer Values 
  17389.      isblank - Test for Blank Character Classification 
  17390.      _iscsym - _iscsymf - Test Integer 
  17391.      iswblank - Test for Wide Blank Character Classification 
  17392.      iswctype - Test for Character Property 
  17393.      <wctype.h> 
  17394.  
  17395.  
  17396. ΓòÉΓòÉΓòÉ 4.168. iswblank - Test for Wide Blank Character Classification ΓòÉΓòÉΓòÉ
  17397.  
  17398.  
  17399. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17400.  
  17401. #include <wctype.h>
  17402. int iswblank(wint_t wc);
  17403.  
  17404.  
  17405. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17406.  
  17407. Language Level:  Extension 
  17408.  
  17409. iswblank tests whether the current LC_CTYPE locale category assigns the the 
  17410. blank character attribute to the wide character wc. 
  17411.  
  17412. The value for wc must be representable as a wchar_t, or WEOF. 
  17413.  
  17414. The behavior of iswblank is affected by the LC_CTYPE category of the current 
  17415. locale. 
  17416.  
  17417. In the "POSIX" and "C" locales, the tab and space characters have the blank 
  17418. attribute. 
  17419.  
  17420. Return Value 
  17421. iswblank returns a nonzero value if wc has the blank attribute; 0 if it does 
  17422. not. 
  17423.  
  17424.  
  17425. ΓòÉΓòÉΓòÉ <hidden> Example of iswblank ΓòÉΓòÉΓòÉ
  17426.  
  17427. /************************************************************************
  17428.  
  17429. This example tests whether wc is a blank type. 
  17430.  
  17431. ************************************************************************/
  17432.  
  17433. #include <stdio.h>
  17434. #include <wctype.h>
  17435. #include <wchar.h>
  17436. #include <locale.h>
  17437.  
  17438. void check(wchar_t wc) {
  17439.    if ((' ' != wc) && (iswprint(wc)))
  17440.       printf("  %lc is ", wc);
  17441.    else
  17442.       printf("x%02x is ", wc);
  17443.    if (!iswblank(wc))
  17444.       printf("not ");
  17445.    puts("a blank type character");
  17446.    return;
  17447. }
  17448.  
  17449. int main(void)
  17450. {
  17451.    printf("In LC_CTYPE category of locale name \"%s\":\n",
  17452.           setlocale(LC_CTYPE, NULL));
  17453.    check(L'a');
  17454.    check(L' ');
  17455.    check(0x00);
  17456.    check(L'\n');
  17457.    check(L'\t');
  17458.    return 0;
  17459.  
  17460.    /****************************************************************************
  17461.       The output should be similar to :
  17462.  
  17463.       In LC_CTYPE category of locale name "C":
  17464.         a is not a blank type character
  17465.       x20 is a blank type character
  17466.       x00 is not a blank type character
  17467.       x0a is not a blank type character
  17468.       x09 is a blank type character
  17469.    ****************************************************************************/
  17470. }
  17471.  
  17472.  
  17473. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17474.  
  17475. Example of iswblank 
  17476.  
  17477.      isalnum to isxdigit - Test Integer Value 
  17478.      isascii - Test Integer Values 
  17479.      isblank - Test for Blank Character Classification 
  17480.      _iscsym - _iscsymf - Test Integer 
  17481.      iswalnum to iswxdigit - Test Wide Integer Value 
  17482.      iswctype - Test for Character Property 
  17483.      <wctype.h> 
  17484.  
  17485.  
  17486. ΓòÉΓòÉΓòÉ 4.169. iswctype - Test for Character Property ΓòÉΓòÉΓòÉ
  17487.  
  17488.  
  17489. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17490.  
  17491. #include <wctype.h>
  17492. int iswctype(wint_t wc, wctype_t wc_prop);
  17493.  
  17494.  
  17495. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17496.  
  17497. Language Level:  ANSI 93, XPG4 
  17498.  
  17499. iswctype determines whether the wide character wc has the property wc_prop. It 
  17500. is similar in function to the iswalnum through isxdigit functions, but with 
  17501. iswctype you can specify the property to check for, or check for a property 
  17502. other than the standard ones. 
  17503.  
  17504. You must obtain the wc_prop value from a call to wctype.  If you do not, or if 
  17505. the LC_CTYPE category of the locale was modified after you called wctype, the 
  17506. behavior of iswctype is undefined. 
  17507.  
  17508. The value of wc must be representable as an unsigned wchar_t, or WEOF. 
  17509.  
  17510. The following strings correspond to the standard (basic) character classes or 
  17511. properties: 
  17512.  
  17513. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  17514. Γöé "         Γöé "         Γöé "         Γöé "         Γöé
  17515. Γöé "alnum"      Γöé "cntrl"      Γöé "lower"      Γöé "space"      Γöé
  17516. Γöé "alpha"      Γöé "digit"      Γöé "print"      Γöé "upper"      Γöé
  17517. Γöé "blank" "     Γöé "graph" "     Γöé "punct" "     Γöé "xdigit" "    Γöé
  17518. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  17519.  
  17520. The following shows calls to wctype and indicates the equivalent isw* function: 
  17521.  
  17522. iswctype(wc, wctype("alnum"));   /* iswalnum(wc);  */
  17523. iswctype(wc, wctype("alpha"));   /* iswalpha(wc);  */
  17524. iswctype(wc, wctype("blank"));   /* iswblank(wc);  */
  17525. iswctype(wc, wctype("cntrl"));   /* iswcntrl(wc);  */
  17526. iswctype(wc, wctype("digit"));   /* iswdigit(wc);  */
  17527. iswctype(wc, wctype("graph"));   /* iswgraph(wc);  */
  17528. iswctype(wc, wctype("lower"));   /* iswlower(wc);  */
  17529. iswctype(wc, wctype("print"));   /* iswprint(wc);  */
  17530. iswctype(wc, wctype("punct"));   /* iswpunct(wc);  */
  17531. iswctype(wc, wctype("space"));   /* iswspace(wc);  */
  17532. iswctype(wc, wctype("upper"));   /* iswupper(wc);  */
  17533. iswctype(wc, wctype("xdigit"));  /* iswxdigit(wc); */
  17534.  
  17535. Return Value 
  17536. iswctype returns a nonzero value if the wide character has the property tested 
  17537. for. If the value for wc or wc_prop is not valid, the behavior is undefined. 
  17538.  
  17539.  
  17540. ΓòÉΓòÉΓòÉ <hidden> Example of iswctype ΓòÉΓòÉΓòÉ
  17541.  
  17542. /************************************************************************
  17543.  
  17544. This example analyzes all characters between 0x0 and 0xFF. The output of this 
  17545. example is a 256-line table showing the characters from 0 to 255, indicating 
  17546. whether they have the properties tested for. 
  17547.  
  17548. ************************************************************************/
  17549.  
  17550. #include <locale.h>
  17551. #include <stdio.h>
  17552. #include <wctype.h>
  17553.  
  17554. #define UPPER_LIMIT   0xFF
  17555.  
  17556. int main(void)
  17557. {
  17558.    wint_t wc;
  17559.  
  17560.    setlocale(LC_ALL, LC_C_USA);
  17561.  
  17562.    for (wc = 0; wc <= UPPER_LIMIT; wc++) {
  17563.       printf("%#4x ", wc);
  17564.       printf("%c", iswctype(wc, wctype("print"))  ? wc    : ' ');
  17565.       printf("%s", iswctype(wc, wctype("alnum"))  ? " AN" : "   ");
  17566.       printf("%s", iswctype(wc, wctype("alpha"))  ? " A " : "   ");
  17567.       printf("%s", iswctype(wc, wctype("blank"))  ? " B " : "   ");
  17568.       printf("%s", iswctype(wc, wctype("cntrl"))  ? " C " : "   ");
  17569.       printf("%s", iswctype(wc, wctype("digit"))  ? " D " : "   ");
  17570.       printf("%s", iswctype(wc, wctype("graph"))  ? " G " : "   ");
  17571.       printf("%s", iswctype(wc, wctype("lower"))  ? " L " : "   ");
  17572.       printf("%s", iswctype(wc, wctype("punct"))  ? " PU" : "   ");
  17573.       printf("%s", iswctype(wc, wctype("space"))  ? " S " : "   ");
  17574.       printf("%s", iswctype(wc, wctype("print"))  ? " PR" : "   ");
  17575.       printf("%s", iswctype(wc, wctype("upper"))  ? " U " : "   ");
  17576.       printf("%s", iswctype(wc, wctype("xdigit")) ? " H " : "   ");
  17577.       putchar('\n');
  17578.    }
  17579.    return 0;
  17580.  
  17581.    /****************************************************************************
  17582.       The output should be similar to :
  17583.        :
  17584.       0x1e            C
  17585.       0x1f            C
  17586.       0x20         B                 S  PR
  17587.       0x21 !                G     PU    PR
  17588.       0x22 "                G     PU    PR
  17589.       0x23 #                G     PU    PR
  17590.       0x24 $                G     PU    PR
  17591.       0x25 %                G     PU    PR
  17592.        :
  17593.       0x30 0 AN          D  G           PR    H
  17594.       0x31 1 AN          D  G           PR    H
  17595.       0x32 2 AN          D  G           PR    H
  17596.       0x33 3 AN          D  G           PR    H
  17597.       0x34 4 AN          D  G           PR    H
  17598.       0x35 5 AN          D  G           PR    H
  17599.        :
  17600.       0x43 C AN A           G           PR U  H
  17601.       0x44 D AN A           G           PR U  H
  17602.       0x45 E AN A           G           PR U  H
  17603.       0x46 F AN A           G           PR U  H
  17604.       0x47 G AN A           G           PR U
  17605.        :
  17606.    ****************************************************************************/
  17607. }
  17608.  
  17609.  
  17610. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17611.  
  17612. Example of iswctype 
  17613.  
  17614.      isalnum to isxdigit - Test Integer Value 
  17615.      isascii - Test Integer Values 
  17616.      isblank - Test for Blank Character Classification 
  17617.      _iscsym - _iscsymf - Test Integer 
  17618.      iswalnum to iswxdigit - Test Wide Integer Value 
  17619.      iswblank - Test for Wide Blank Character Classification 
  17620.      iswalnum to iswxdigit - Test Wide Integer Value 
  17621.      wctype - Get Handle for Character Property Classification 
  17622.      <wctype.h> 
  17623.  
  17624.  
  17625. ΓòÉΓòÉΓòÉ 4.170. _itoa - Convert Integer to String ΓòÉΓòÉΓòÉ
  17626.  
  17627.  
  17628. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17629.  
  17630. #include <stdlib.h>
  17631. char *_itoa(int value, char * string, int radix);
  17632.  
  17633.  
  17634. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17635.  
  17636. Language Level:  Extension 
  17637.  
  17638. _itoa converts the digits of the given value to a character string that ends 
  17639. with a null character and stores the result in string. The radix argument 
  17640. specifies the base of value; it must be in the range 2 to 36. If radix equals 
  17641. 10 and value is negative, the first character of the stored string is the minus 
  17642. sign (-). 
  17643.  
  17644. Note:  The space reserved for string must be large enough to hold the returned 
  17645. string. The function can return up to 33 bytes including the null character 
  17646. (\0). 
  17647.  
  17648. Return Value 
  17649. _itoa returns a pointer to string. There is no error return value. 
  17650.  
  17651.  
  17652. ΓòÉΓòÉΓòÉ <hidden> Example of _itoa ΓòÉΓòÉΓòÉ
  17653.  
  17654. /************************************************************************
  17655.  
  17656. This example converts the integer value -255 to a decimal, a binary, and a hex 
  17657. number, storing its character representation in the array buffer. 
  17658.  
  17659. ************************************************************************/
  17660.  
  17661. #include <stdio.h>
  17662. #include <stdlib.h>
  17663.  
  17664. int main(void)
  17665. {
  17666.    char buffer[35];
  17667.    char *p;
  17668.  
  17669.    p = _itoa(-255, buffer, 10);
  17670.    printf("The result of _itoa(-255) with radix of 10 is %s\n", p);
  17671.    p = _itoa(-255, buffer, 2);
  17672.    printf("The result of _itoa(-255) with radix of 2\n    is %s\n", p);
  17673.    p = _itoa(-255, buffer, 16);
  17674.    printf("The result of _itoa(-255) with radix of 16 is %s\n", p);
  17675.    return 0;
  17676.  
  17677.    /****************************************************************************
  17678.       The output should be:
  17679.  
  17680.       The result of _itoa(-255) with radix of 10 is -255
  17681.       The result of _itoa(-255) with radix of 2
  17682.           is 11111111111111111111111100000001
  17683.       The result of _itoa(-255) with radix of 16 is ffffff01
  17684.    ****************************************************************************/
  17685. }
  17686.  
  17687.  
  17688. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17689.  
  17690. Example of _itoa 
  17691.  
  17692.      _ecvt - Convert Floating-Point to Character 
  17693.      _fcvt - Convert Floating-Point to String 
  17694.      _gcvt - Convert Floating-Point to String 
  17695.      _ltoa - Convert Long Integer to String 
  17696.      _ultoa - Convert Unsigned Long Integer to String 
  17697.      <stdlib.h> 
  17698.  
  17699.  
  17700. ΓòÉΓòÉΓòÉ 4.171. _kbhit - Test for Keystroke ΓòÉΓòÉΓòÉ
  17701.  
  17702.  
  17703. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17704.  
  17705. include <conio.h>
  17706. int _kbhit(void);
  17707.  
  17708.  
  17709. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17710.  
  17711. Language Level:  Extension 
  17712.  
  17713. _kbhit tests if a key has been pressed on the keyboard.  If the result is 
  17714. nonzero, a keystroke is waiting in the buffer. You can read in the keystroke 
  17715. using the _getch or _getche function. If you call _getch or _getche without 
  17716. first calling _kbhit, the program waits for a key to be pressed. 
  17717.  
  17718. Return Value 
  17719. _kbhit returns a nonzero value if a key has been pressed. Otherwise, it returns 
  17720. 0. 
  17721.  
  17722.  
  17723. ΓòÉΓòÉΓòÉ <hidden> Example of _kbhit ΓòÉΓòÉΓòÉ
  17724.  
  17725. /************************************************************************
  17726.  
  17727. This example uses _kbhit to test for the pressing of a key on the keyboard and 
  17728. to print a statement with the test result. 
  17729.  
  17730. ************************************************************************/
  17731.  
  17732. #include <conio.h>
  17733. #include <stdio.h>
  17734.  
  17735. int main(void)
  17736. {
  17737.    int ch;
  17738.  
  17739.    printf("Type in some letters.\n");
  17740.    printf("If you type in an 'x', the program ends.\n");
  17741.  
  17742.    for (; ; ) {
  17743.       while (0==_kbhit()){
  17744.       /* Processing without waiting for a key to be pressed */
  17745.       }
  17746.  
  17747.       ch = _getch();
  17748.       printf("You have pressed the '%c' key.\n",ch);
  17749.  
  17750.       if ('x' == ch)
  17751.          break;
  17752.    }
  17753.    return 0;
  17754.  
  17755.    /****************************************************************************
  17756.       The output should be similar to:
  17757.  
  17758.       Type in some letters.
  17759.       If you type in an 'x', the program ends.
  17760.       You have pressed the 'f' key.
  17761.       You have pressed the 'e' key.
  17762.       You have pressed the 'l' key.
  17763.       You have pressed the 'i' key.
  17764.       You have pressed the 'x' key.
  17765.    ****************************************************************************/
  17766. }
  17767.  
  17768.  
  17769. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17770.  
  17771. Example of _kbhit 
  17772.  
  17773.      _getch - _getche - Read Character from Keyboard 
  17774.      <conio.h> 
  17775.  
  17776.  
  17777. ΓòÉΓòÉΓòÉ 4.172. labs - Calculate Absolute Value of Long Integer ΓòÉΓòÉΓòÉ
  17778.  
  17779.  
  17780. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17781.  
  17782. #include <stdlib.h>
  17783. long int labs(long int n);
  17784.  
  17785.  
  17786. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17787.  
  17788. Language Level:  ANSI, SAA, XPG4 
  17789.  
  17790. labs produces the absolute value of its long integer argument n. The result may 
  17791. be undefined when the argument is equal to LONG_MIN, the smallest available 
  17792. long integer (-2 147 483 647). The value LONG_MIN is defined in the <limits.h> 
  17793. include file. 
  17794.  
  17795. Return Value 
  17796. labs returns the absolute value of n. There is no error return value. 
  17797.  
  17798.  
  17799. ΓòÉΓòÉΓòÉ <hidden> Example of labs ΓòÉΓòÉΓòÉ
  17800.  
  17801. /************************************************************************
  17802.  
  17803. This example computes y as the absolute value of the long integer -41567. 
  17804.  
  17805. ************************************************************************/
  17806.  
  17807. #include <stdlib.h>
  17808.  
  17809. int main(void)
  17810. {
  17811.    long x,y;
  17812.  
  17813.    x = -41567L;
  17814.    y = labs(x);
  17815.    printf("The absolute value of %ld is %ld\n", x, y);
  17816.    return 0;
  17817.  
  17818.    /****************************************************************************
  17819.       The output should be:
  17820.  
  17821.       The absolute value of -41567 is 41567
  17822.    ****************************************************************************/
  17823. }
  17824.  
  17825.  
  17826. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17827.  
  17828. Example of labs 
  17829.  
  17830.      abs - Calculate Integer Absolute Value 
  17831.      _cabs - Calculate Absolute Value of Complex Number 
  17832.      fabs - Calculate Floating-Point Absolute Value 
  17833.      <limits.h> 
  17834.  
  17835.  
  17836. ΓòÉΓòÉΓòÉ 4.173. ldexp - Multiply by a Power of Two ΓòÉΓòÉΓòÉ
  17837.  
  17838.  
  17839. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17840.  
  17841. #include <math.h>
  17842. double ldexp(double x, int exp);
  17843.  
  17844.  
  17845. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17846.  
  17847. Language Level: ANSI, SAA, POSIX, XPG4 
  17848.  
  17849. ldexp calculates the value of x * (2**exp). 
  17850.  
  17851. Return Value 
  17852. ldexp returns the resulting value. If an overflow results, the function returns 
  17853. +HUGE_VAL for a large result or -HUGE_VAL for a small result, and sets errno to 
  17854. ERANGE. 
  17855.  
  17856.  
  17857. ΓòÉΓòÉΓòÉ <hidden> Example of ldexp ΓòÉΓòÉΓòÉ
  17858.  
  17859. /************************************************************************
  17860.  
  17861. This example computes y as 1.5 times 2 to the fifth power (1.5 * (2**5)): 
  17862.  
  17863. ************************************************************************/
  17864.  
  17865. #include <math.h>
  17866.  
  17867. int main(void)
  17868. {
  17869.    double x,y;
  17870.    int p;
  17871.  
  17872.    x = 1.5;
  17873.    p = 5;
  17874.    y = ldexp(x, p);
  17875.    printf("%lf times 2 to the power of %d is %lf\n", x, p, y);
  17876.    return 0;
  17877.  
  17878.    /****************************************************************************
  17879.       The output should be:
  17880.  
  17881.       1.500000 times 2 to the power of 5 is 48.000000
  17882.    ****************************************************************************/
  17883. }
  17884.  
  17885.  
  17886. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17887.  
  17888. Example of ldexp 
  17889.  
  17890.      exp - Calculate Exponential Function 
  17891.      frexp - Separate Floating-Point Value 
  17892.      modf - Separate Floating-Point Value 
  17893.      <math.h> 
  17894.  
  17895.  
  17896. ΓòÉΓòÉΓòÉ 4.174. ldiv - Perform Long Division ΓòÉΓòÉΓòÉ
  17897.  
  17898.  
  17899. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17900.  
  17901. #include <stdlib.h>
  17902. ldiv_t ldiv(long int numerator, long int denominator);
  17903.  
  17904.  
  17905. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17906.  
  17907. Language Level: ANSI, SAA, XPG4 
  17908.  
  17909. ldiv calculates the quotient and remainder of the division of numerator by 
  17910. denominator. 
  17911.  
  17912. Return Value 
  17913. ldiv returns a structure of type ldiv_t, containing both the quotient (long int 
  17914. quot) and the remainder (long int rem).  If the value cannot be represented, 
  17915. the return value is undefined. If denominator is 0, an exception is raised. 
  17916.  
  17917.  
  17918. ΓòÉΓòÉΓòÉ <hidden> Example of ldiv ΓòÉΓòÉΓòÉ
  17919.  
  17920. /************************************************************************
  17921.  
  17922. This example uses ldiv to calculate the quotients and remainders for a set of 
  17923. two dividends and two divisors. 
  17924.  
  17925. ************************************************************************/
  17926.  
  17927. #include <stdio.h>
  17928. #include <stdlib.h>
  17929.  
  17930. int main(void)
  17931. {
  17932.    long int num[2] =  { 45,-45 };
  17933.    long int den[2] =  { 7,-7 };
  17934.    ldiv_t ans;       /* ldiv_t is a struct type containing two long ints:
  17935.                         'quot' stores quotient; 'rem' stores remainder  */
  17936.    short i,j;
  17937.  
  17938.    printf("Results of long division:\n");
  17939.    for (i = 0; i < 2; i++)
  17940.       for (j = 0; j < 2; j++) {
  17941.          ans = ldiv(num[i], den[j]);
  17942.          printf("Dividend: %6ld  Divisor: %6ld", num[i], den[j]);
  17943.          printf("  Quotient: %6ld  Remainder: %6ld\n", ans.quot, ans.rem);
  17944.       }
  17945.    return 0;
  17946.  
  17947.    /****************************************************************************
  17948.       The output should be:
  17949.  
  17950.       Results of long division:
  17951.       Dividend:  45  Divisor:   7  Quotient:   6  Remainder:   3
  17952.       Dividend:  45  Divisor:  -7  Quotient:  -6  Remainder:   3
  17953.       Dividend: -45  Divisor:   7  Quotient:  -6  Remainder:  -3
  17954.       Dividend: -45  Divisor:  -7  Quotient:   6  Remainder:  -3
  17955.    ****************************************************************************/
  17956. }
  17957.  
  17958.  
  17959. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  17960.  
  17961. Example of ldiv 
  17962.  
  17963.      div  - Calculate Quotient and Remainder 
  17964.      <stdlib.h> 
  17965.  
  17966.  
  17967. ΓòÉΓòÉΓòÉ 4.175. lfind - lsearch - Find Key in Array ΓòÉΓòÉΓòÉ
  17968.  
  17969.  
  17970. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  17971.  
  17972. #include <search.h>
  17973. char *lfind(char *search_key, char *base,
  17974.              unsigned int *num, unsigned int *width,
  17975.              int (*compare)(const void *key, const void *element));
  17976. char *lsearch(char *search_key, char *base,
  17977.                unsigned int *num, unsigned int *width,
  17978.                int (*compare)(const void *key, const void *element));
  17979.  
  17980.  
  17981. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  17982.  
  17983. Language Level:  XPG4, Extension 
  17984.  
  17985. lfind and lsearch perform a linear search for the value search_key in an array 
  17986. of num elements, each of width bytes in size.  Unlike bsearch, lsearch and 
  17987. lfind do not require that you sort the array first.  The argument base points 
  17988. to the base of the array to be searched. 
  17989.  
  17990. If lsearch does not find the search_key, it adds the search_key to the end of 
  17991. the array and increments num by one. If lfind does not find the search_key, it 
  17992. does not add the search_key to the array. 
  17993.  
  17994. The compare argument is a pointer to a function you must supply that takes a 
  17995. pointer to the key argument and to an array element, in that order. Both lfind 
  17996. and lsearch call this function one or more times during the search. The 
  17997. function must compare the key and the element and return one of the following 
  17998. values: 
  17999.  
  18000.  Value             Meaning 
  18001.  Nonzero           key and element are different. 
  18002.  0                 key and element are identical. 
  18003.  
  18004.  Note:  In earlier releases of C Set ++, lfind and lsearch began with an 
  18005.  underscore (_lfind and _lsearch). Because they are defined by the X/Open 
  18006.  standard, the underscore has been removed. For compatibility, VisualAge C++ 
  18007.  will map _lfind and _lsearch to lfind and lsearch for you. 
  18008.  
  18009.  Return Value 
  18010.  
  18011.  If search_key is found, both lsearch and lfind return a pointer to that 
  18012.  element of the array to which base points. If search_key is not found, lsearch 
  18013.  returns a pointer to a newly added item at the end of the array, while lfind 
  18014.  returns NULL. 
  18015.  
  18016.  
  18017. ΓòÉΓòÉΓòÉ <hidden> Example of lfind ΓòÉΓòÉΓòÉ
  18018.  
  18019. /************************************************************************
  18020.  
  18021. This example uses lfind to search for the keyword PATH in the command-line 
  18022. arguments. 
  18023.  
  18024. ************************************************************************/
  18025.  
  18026. #include <search.h>
  18027. #include <string.h>
  18028. #include <stdio.h>
  18029.  
  18030. #define  CNT           2
  18031.  
  18032. /* Note: Library always calls functions internally with _Optlink              */
  18033. /*       linkage convention.  Ensure that compare() is always                 */
  18034. /*       _Optlink.                                                            */
  18035.  
  18036. int _Optlink compare(const void *arg1,const void *arg2)
  18037. {
  18038.    return (strncmp(*(char **)arg1, *(char **)arg2, strlen(*(char **)arg1)));
  18039. }
  18040.  
  18041. int main(void)
  18042. {
  18043.    char **result;
  18044.    char *key = "PATH";
  18045.    unsigned int num = CNT;
  18046.    char *string[CNT] =  {
  18047.       "PATH = d:\\david\\matthew\\heather\\ed\\simon","LIB = PATH\\abc" };
  18048.  
  18049.    /* The following statement finds the argument that starts with "PATH"      */
  18050.  
  18051.    if ((result = (char **)lfind((char *)&key, (char *)string, &num,
  18052.                   sizeof(char *), compare)) != NULL)
  18053.       printf("%s found\n", *result);
  18054.    else
  18055.       printf("PATH not found \n");
  18056.    return 0;
  18057.  
  18058.    /****************************************************************************
  18059.       The output should be:
  18060.  
  18061.       PATH = d:\david\matthew\heather\ed\simon found
  18062.    ****************************************************************************/
  18063. }
  18064.  
  18065.  
  18066. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  18067.  
  18068. Example of lfind 
  18069.  
  18070.      bsearch - Search Arrays 
  18071.      qsort - Sort Array 
  18072.      <search.h> 
  18073.  
  18074.  
  18075. ΓòÉΓòÉΓòÉ 4.176. _loadmod - Load DLL ΓòÉΓòÉΓòÉ
  18076.  
  18077.  
  18078. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18079.  
  18080. #include <stdlib.h>
  18081. int _loadmod(char *module_name, unsigned long *module_handle);
  18082.  
  18083.  
  18084. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18085.  
  18086. Language Level:  Extension 
  18087.  
  18088. _loadmod loads a dynamic link library (DLL) for the calling process. The 
  18089. module_name is the name of the DLL to be loaded, and the module_handle is the 
  18090. file handle associated with the DLL. 
  18091.  
  18092. Note:  _loadmod and _freemod perform exactly the same function as the OS/2 APIs 
  18093.        DosLoadModule and DosFreeModule. They are provided for compatibility 
  18094.        with earlier VisualAge C++ releases only, and will not be supported in 
  18095.        future versions. Use DosLoadModule and DosFreeModule instead. For more 
  18096.        details on these APIs, see the Control Program Guide and Reference. 
  18097.  
  18098.  If the operation is successful, _loadmod returns the handle of the loaded DLL 
  18099.  to the calling process.  The process can use this handle with the OS/2 API 
  18100.  DosQueryProcAddr to get the address of the required function from within the 
  18101.  DLL.  Once the reference is established, the calling process can then call the 
  18102.  specific function. 
  18103.  
  18104.  Return Value 
  18105.  _loadmod returns 0 if the DLL was successfully loaded. If unsuccessful, 
  18106.  _loadmod returns -1, and sets errno to one of the following values: 
  18107.  
  18108.  Value          Meaning 
  18109.  EMODNAME       The specified module_name is not valid. 
  18110.  EOS2ERR        A system error occurred. Check _doserrno for the specific OS/2 
  18111.                 error code. 
  18112.  
  18113.  
  18114. ΓòÉΓòÉΓòÉ <hidden> Example of _loadmod ΓòÉΓòÉΓòÉ
  18115.  
  18116. /************************************************************************
  18117.  
  18118. In this example, _loadmod loads the DLL mark and gets the address of the 
  18119. function PLUS within the DLL.  It then calls that function, which adds two 
  18120. integers passed to it. The types PFN and APIRET are required to use the OS/2 
  18121. DosQueryProcAddr API, and are defined by including the <os2.h> header file. 
  18122.  
  18123. Note:  To run this program, you must first create mark.dll. Copy the code for 
  18124. the PLUS function into a file called mark.c, and the code for the .DEF file 
  18125. into mark.def.  Eliminate the comments from these two files. Compile with the 
  18126. command: 
  18127.  
  18128.    icc /Ge- mark.c mark.def
  18129. You can then run the example. 
  18130.  
  18131. ************************************************************************/
  18132.  
  18133. #define  INCL_DOS
  18134. #include <os2.h>
  18135. #include <stdio.h>
  18136. #include <stdlib.h>
  18137.  
  18138.  /* This is the code for MARK.DEF
  18139.  LIBRARY MARK
  18140.  PROTMODE
  18141.  EXPORTS PLUS                                                                 */
  18142.  /* This is the code for PLUS function in the DLL
  18143.     #pragma linkage( PLUS, system )
  18144.     int PLUS( int a , int b)
  18145.     {
  18146.        return a + b;
  18147.     }                                                                         */
  18148.  
  18149. int main(void)
  18150. {
  18151.    int x = 4,y = 7;
  18152.    unsigned long handle;
  18153.    char *modname = "MARK";                                /* DLL name         */
  18154.    char *fname = "PLUS";                                  /* function name    */
  18155.    PFN faddr;                                          /* pointer to function */
  18156.    APIRET rc;                            /* return code from DosQueryProcAddr */
  18157.  
  18158.     /*  dynamically load the 'mark' DLL                                       */
  18159.  
  18160.    if (_loadmod(modname, &handle)) {
  18161.       printf("Error loading module %s\n", modname);
  18162.       return EXIT_FAILURE;
  18163.    }
  18164.  
  18165.     /*   get function address from DLL                                        */
  18166.  
  18167.    rc = DosQueryProcAddr(handle, 0, fname, &faddr);
  18168.    if (0 == rc) {
  18169.       printf("Calling the function from the %s DLL to add %d and %d\n", modname,
  18170.          x, y);
  18171.       printf("The result of the function call is %d\n", faddr(x, y));
  18172.    }
  18173.    else {
  18174.       printf("Error locating address of function %s\n", fname);
  18175.       _freemod(handle);
  18176.       return EXIT_FAILURE;
  18177.    }
  18178.    if (_freemod(handle)) {
  18179.       printf("Error in freeing the %s DLL module\n", modname);
  18180.       return EXIT_FAILURE;
  18181.    }
  18182.    printf("Reference to the %s DLL module has been freed\n", modname);
  18183.    return 0;
  18184.  
  18185.    /****************************************************************************
  18186.       The output should be:
  18187.  
  18188.       Calling the function from the MARK DLL to add 4 and 7
  18189.       The result of the function call is 11
  18190.       Reference to the MARK DLL module has been freed
  18191.    ****************************************************************************/
  18192. }
  18193.  
  18194.  
  18195. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  18196.  
  18197. Example of _loadmod 
  18198.  
  18199.      _freemod - Free User DLL 
  18200.      <stdlib.h> 
  18201.  
  18202.  
  18203. ΓòÉΓòÉΓòÉ 4.177. localdtconv - Return Date and Time Formatting Convention ΓòÉΓòÉΓòÉ
  18204.  
  18205.  
  18206. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18207.  
  18208. #include <locale.h>
  18209. struct dtconv *localdtconv(void);
  18210.  
  18211.  
  18212. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18213.  
  18214. Language Level:  Extension 
  18215.  
  18216. localdtconv determines the date and time formatting conventions of the current 
  18217. locale and places the information in a structure of type struct dtconv. The 
  18218. dtconv structure is described in detail on page <locale.h>. 
  18219.  
  18220. Subsequent calls to localdtconv or to setlocale with LC_ALL or LC_TIME can 
  18221. overwrite the structure. 
  18222.  
  18223. Return Value 
  18224. localdtconv returns the address of the dtconv structure. 
  18225.  
  18226.  
  18227. ΓòÉΓòÉΓòÉ <hidden> Example of localdtconv ΓòÉΓòÉΓòÉ
  18228.  
  18229. /************************************************************************
  18230.  
  18231. This example sets the Spanish locale, calls localdtconv to determine how date 
  18232. and time are formatted, and prints the fields from the resulting structure. 
  18233.  
  18234. ************************************************************************/
  18235.  
  18236. #include <stdio.h>
  18237. #include <locale.h>
  18238. #include <stdlib.h>
  18239.  
  18240. int main(void)
  18241. {
  18242.    struct dtconv *p;
  18243.    int           i;
  18244.  
  18245.    if (NULL == setlocale(LC_ALL, LC_C_SPAIN)) {
  18246.       printf("setlocale failed.\n");
  18247.       exit(EXIT_FAILURE);
  18248.    }
  18249.    else {
  18250.       p = localdtconv();
  18251.       printf("SPAIN date/time convention.\n");
  18252.       printf(" Abbreviated month names:");
  18253.       for (i = 0; i < 12; ++i)
  18254.          printf(" %s", p->abbrev_month_names[i]);
  18255.       printf("\n Full month names:");
  18256.       for (i = 0; i < 12; ++i)
  18257.          printf(" %s", p->month_names[i]);
  18258.       printf("\n Abbreviated day names:");
  18259.       for (i = 0; i < 7; ++i)
  18260.          printf(" %s", p->abbrev_day_names[i]);
  18261.       printf("\n Full day names:");
  18262.       for (i = 0; i < 7; ++i)
  18263.          printf(" %s", p->day_names[i]);
  18264.       printf("\n Date and time format:  %s\n", p->date_time_format);
  18265.       printf(" Date format:  %s\n",            p->date_format);
  18266.       printf(" Time format:  %s\n",            p->time_format);
  18267.       printf(" AM string:  %s\n",              p->am_string);
  18268.       printf(" PM string:  %s\n",              p->pm_string);
  18269.       printf(" Long date format:  %s\n",       p->time_format_ampm);
  18270.    }
  18271.    return 0;
  18272.  
  18273.    /****************************************************************************
  18274.       The output should be similar to :
  18275.  
  18276.       SPAIN date/time convention.
  18277.        Abbreviated month names: ENE FEB MAR ABR MAY JUN JUL AGO SEP OCT NOV DIC
  18278.        Full month names: Enero Febrero Marzo Abril Mayo Junio Julio Agosto
  18279.                          Septiembre Octubre Noviembre Diciembre
  18280.        Abbreviated day names: DOM LUN MAR MIE JUE VIE SAB
  18281.        Full day names: Domingo Lunes Martes Miercoles Jueves Viernes Sabado
  18282.        Date and time format:  %d %B %Y %H:%M:%S
  18283.        Date format:  %d/%m/%y
  18284.        Time format:  %H:%M:%S
  18285.        AM string:
  18286.        PM string:
  18287.        Long date format:  %H:%M:%S %p
  18288.    ****************************************************************************/
  18289. }
  18290.  
  18291.  
  18292. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  18293.  
  18294. Example of localdtconv 
  18295.  
  18296.      localeconv - Retrieve Information from the Environment 
  18297.      localtime - Convert Time 
  18298.      setlocale - Set Locale 
  18299.      strftime - Convert to Formatted Time 
  18300.      strptime - Convert to Formatted Date and Time 
  18301.      wcsftime - Convert to Formatted Date and Time 
  18302.      <locale.h> 
  18303.  
  18304.  
  18305. ΓòÉΓòÉΓòÉ 4.178. localeconv - Retrieve Information from the Environment ΓòÉΓòÉΓòÉ
  18306.  
  18307.  
  18308. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18309.  
  18310. #include <locale.h>
  18311. struct lconv *localeconv(void);
  18312.  
  18313.  
  18314. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18315.  
  18316. Language Level:  ANSI, SAA, XPG4 
  18317.  
  18318. localeconv retrieves information about the environment for the current locale 
  18319. and places the information in a structure of type struct lconv. Subsequent 
  18320. calls to localeconv, or to setlocale with the argument LC_ALL, LC_MONETARY, or 
  18321. LC_NUMERIC, can overwrite the structure. 
  18322.  
  18323. The structure contains the members listed below. Defaults shown are for the "C" 
  18324. locale. Pointers to strings with a value of "" indicate that the value is not 
  18325. available in this locale or is of zero length. Character types with a value of 
  18326. UCHAR_MAX indicate that the value is not available in this locale. 
  18327.  
  18328. ELEMENT          PURPOSE OF ELEMENT             DEFAULT
  18329. "char *decimal_point"   Decimal-point character for formatting   "."
  18330.              nonmonetary quantities.
  18331. "char *thousands_sep"   Character used to separate groups of    ""
  18332.              digits to the left of the decimal-point
  18333.              character in formatted nonmonetary quan-
  18334.              tities.
  18335. "char *grouping"     Size of each group of digits in for-    ""
  18336.              matted nonmonetary quantities.  The
  18337.              value of each character in the string
  18338.              determines the number of digits in a
  18339.              group.  "CHAR_MAX" indicates that there
  18340.              are no further groupings.  "0" indicates
  18341.              that the previous element is to be used
  18342.              for the remainder of the digits.
  18343. "char           International currency symbol.  The     ""
  18344. *int_curr_symbol"     first three characters contain the
  18345.              alphabetic international currency
  18346.              symbol.  The fourth character (usually a
  18347.              space) separates the international cur-
  18348.              rency symbol from the monetary quantity.
  18349. "char           Local currency symbol.           ""
  18350. *currency_symbol"
  18351. "char           Decimal-point character for formatting   "."
  18352. *mon_decimal_point"    monetary quantities.
  18353. "char           Separator for digits in formatted mone-   ""
  18354. *mon_thousands_sep"    tary quantities.
  18355. "char *mon_grouping"   Size of each group of digits in for-    ""
  18356.              matted monetary quantities.  The value
  18357.              of each character in the string deter-
  18358.              mines the number of digits in a group.
  18359.              "CHAR_MAX" indicates that there are no
  18360.              further groupings.  "0" indicates that
  18361.              the previous element is to be used for
  18362.              the remainder of the digits.
  18363. "char *positive_sign"   Positive sign used in monetary quanti-   ""
  18364.              ties.
  18365. "char *negative_sign"   Negative sign used in monetary quanti-   ""
  18366.              ties.
  18367. "char int_frac_digits"  Mumber of displayed digits to the right   UCHAR_MAX
  18368.              of the decimal place for internationally
  18369.              formatted monetary quantities.
  18370. "char frac_digits"    Number of digits to the right of the    UCHAR_MAX
  18371.              decimal place in monetary quantities.
  18372. "char p_cs_precedes"   1 if the "currency_symbol" precedes the   UCHAR_MAX
  18373.              value for a nonnegative formatted mone-
  18374.              tary quantity; "0" if it does not.
  18375. "char p_sep_by_space"   1 if the "currency_symbol" is separated   UCHAR_MAX
  18376.              by a space from the value of a nonnega-
  18377.              tive formatted monetary quantity;  "0"
  18378.              if it is not.
  18379. "char n_cs_precedes"   1 if the "currency_symbol" precedes the   UCHAR_MAX
  18380.              value for a negative formatted monetary
  18381.              quantity; "0" if it does not.
  18382. "char n_sep_by_space"   1 if the "currency_symbol" is separated   UCHAR_MAX
  18383.              by a space from the value of a negative
  18384.              formatted monetary quantity;  "0" if it
  18385.              is not.
  18386. "char p_sign_posn"    Position of the "positive_sign" for a    UCHAR_MAX
  18387.              nonnegative formatted monetary quantity.
  18388. "char n_sign_posn"    Position of the "negative_sign" for a    UCHAR_MAX
  18389.              negative formatted monetary quantity.
  18390. "char           Symbol to appear to the left of a      ""(""
  18391. *left_parenthesis"    negative-valued monetary symbol (such as
  18392.              a loss or deficit).
  18393. "char           Symbol to appear to the right of a     "")""
  18394. *right_parenthesis"    negative-valued monetary symbol (such as
  18395.              a loss or deficit).
  18396. "char *debit_sign"    String to indicate a non-negative-valued  ""DB""
  18397.              formatted monetary quantity.
  18398. "char *credit_sign"    String to indicate a negative-valued    ""CR""
  18399.              formatted monetary quantity.
  18400.  
  18401. The grouping and mon_grouping members can have the following values: 
  18402.  
  18403.  Value        Meaning 
  18404.  CHAR_MAX     No further grouping is to be performed. 
  18405.  0            The previous element is to be repeatedly used for the rest of the 
  18406.               digits. 
  18407.  other        The number of digits that comprise the current group.  The next 
  18408.               element is examined to determine the size of the next group of 
  18409.               digits before the current group. 
  18410.  
  18411.  The n_sign_posn and p_sign_posn elements can have the following values: 
  18412.  
  18413.  Value Meaning 
  18414.   0    The quantity and currency_symbol are enclosed in parentheses. 
  18415.   1    The sign precedes the quantity and currency_symbol. 
  18416.   2    The sign follows the quantity and currency_symbol. 
  18417.   3    The sign precedes the currency_symbol. 
  18418.   4    The sign follows the currency_symbol. 
  18419.   5    Use debit_sign for p_sign_posn or credit_sign for n_sign_posn. 
  18420.  
  18421.  Return Value 
  18422.  localeconv returns a pointer to the lconv structure. 
  18423.  
  18424.  
  18425. ΓòÉΓòÉΓòÉ <hidden> Example of localeconv ΓòÉΓòÉΓòÉ
  18426.  
  18427. /************************************************************************
  18428.  
  18429. This example prints out the default decimal point for your locale and then the 
  18430. decimal point for the LC_C_FRANCE locale. 
  18431.  
  18432. ************************************************************************/
  18433.  
  18434. #include <stdio.h>
  18435. #include <locale.h>
  18436.  
  18437. int main(void)
  18438. {
  18439.    struct lconv *mylocale;
  18440.  
  18441.    mylocale = localeconv();
  18442.    printf("Default decimal point is a %s\n", mylocale->decimal_point);
  18443.  
  18444.    if (NULL != setlocale(LC_ALL, LC_C_FRANCE)) {
  18445.       mylocale = localeconv();
  18446.       printf("France's decimal point is a %s\n", mylocale->decimal_point);
  18447.    } else {
  18448.       printf("setlocale(LC_ALL, LC_C_FRANCE) returned <NULL>\n");
  18449.    }
  18450.    return 0;
  18451.  
  18452.    /****************************************************************************
  18453.       The output should be similar to :
  18454.  
  18455.       Default decimal point is a .
  18456.       France's decimal point is a ,
  18457.    ****************************************************************************/
  18458. }
  18459.  
  18460.  
  18461. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  18462.  
  18463. Example of localeconv 
  18464.  
  18465.      setlocale - Set Locale 
  18466.      <locale.h> 
  18467.  
  18468.  
  18469. ΓòÉΓòÉΓòÉ 4.179. localtime - Convert Time ΓòÉΓòÉΓòÉ
  18470.  
  18471.  
  18472. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18473.  
  18474. #include <time.h>
  18475. struct tm *localtime(const time_t *timeval);
  18476.  
  18477.  
  18478. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18479.  
  18480. Language Level: ANSI, SAA, POSIX, XPG4 
  18481.  
  18482. localtime breaks down timeval, corrects for the local time zone and Daylight 
  18483. Saving Time, if appropriate, and stores the corrected time in a structure of 
  18484. type tm.  See gmtime for a description of the fields in a tm structure. 
  18485.  
  18486. The time value is usually obtained by a call to the time function. 
  18487.  
  18488. Note: 
  18489.  
  18490.    1. gmtime and localtime may use a common, statically allocated buffer for 
  18491.       the conversion.  Each call to one of these functions may alter the result 
  18492.       of the previous call. 
  18493.  
  18494.    2. The time and date functions begin at 00:00:00 Coordinated Universal Time, 
  18495.       January 1, 1970. 
  18496.  
  18497.  Return Value 
  18498.  localtime returns a pointer to the structure result. If unsuccessful, it 
  18499.  returns NULL. 
  18500.  
  18501.  
  18502. ΓòÉΓòÉΓòÉ <hidden> Example of localtime ΓòÉΓòÉΓòÉ
  18503.  
  18504. /************************************************************************
  18505.  
  18506. This example queries the system clock and displays the local time. 
  18507.  
  18508. ************************************************************************/
  18509.  
  18510. #include <time.h>
  18511. #include <stdio.h>
  18512.  
  18513. int main(void)
  18514. {
  18515.    struct tm *newtime;
  18516.    time_t ltime;
  18517.  
  18518.    time(<ime);
  18519.    newtime = localtime(<ime);
  18520.    printf("The date and time is %s", asctime(newtime));
  18521.    return 0;
  18522.  
  18523.    /****************************************************************************
  18524.       The output should be similar to:
  18525.  
  18526.       The date and time is Wed Oct 31 15:00:00 1995
  18527.    ****************************************************************************/
  18528. }
  18529.  
  18530.  
  18531. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  18532.  
  18533. Example of localtime 
  18534.  
  18535.      asctime - Convert Time to Character String 
  18536.      ctime - Convert Time to Character String 
  18537.      gmtime - Convert Time 
  18538.      mktime - Convert Local Time 
  18539.      time - Determine Current Time 
  18540.      <time.h> 
  18541.  
  18542.  
  18543. ΓòÉΓòÉΓòÉ 4.180. log - Calculate Natural Logarithm ΓòÉΓòÉΓòÉ
  18544.  
  18545.  
  18546. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18547.  
  18548. #include <math.h>
  18549. double log(double x);
  18550.  
  18551.  
  18552. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18553.  
  18554. Language Level: ANSI, SAA, POSIX, XPG4 
  18555.  
  18556. log calculates the natural logarithm (base e) of x. 
  18557.  
  18558. Return Value 
  18559. log returns the computed value.  If x is negative, log sets errno to EDOM and 
  18560. may return the value -HUGE_VAL. If x is zero, log returns the value -HUGE_VAL, 
  18561. and may set errno to ERANGE. 
  18562.  
  18563.  
  18564. ΓòÉΓòÉΓòÉ <hidden> Example of log ΓòÉΓòÉΓòÉ
  18565.  
  18566. /************************************************************************
  18567.  
  18568. This example calculates the natural logarithm of 1000.0. 
  18569.  
  18570. ************************************************************************/
  18571.  
  18572. #include <math.h>
  18573.  
  18574. int main(void)
  18575. {
  18576.    double x = 1000.0,y;
  18577.  
  18578.    y = log(x);
  18579.    printf("The natural logarithm of %lf is %lf\n", x, y);
  18580.    return 0;
  18581.  
  18582.    /****************************************************************************
  18583.       The output should be:
  18584.  
  18585.       The natural logarithm of 1000.000000 is 6.907755
  18586.    ****************************************************************************/
  18587. }
  18588.  
  18589.  
  18590. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  18591.  
  18592. Example of log 
  18593.  
  18594.      exp - Calculate Exponential Function 
  18595.      log10 - Calculate Base 10 Logarithm 
  18596.      pow - Compute Power 
  18597.      <math.h> 
  18598.  
  18599.  
  18600. ΓòÉΓòÉΓòÉ 4.181. log10 - Calculate Base 10 Logarithm ΓòÉΓòÉΓòÉ
  18601.  
  18602.  
  18603. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18604.  
  18605. #include <math.h>
  18606. double log10(double x);
  18607.  
  18608.  
  18609. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18610.  
  18611. Language Level:  ANSI, SAA, POSIX, XPG4 
  18612.  
  18613. log10 calculates the base 10 logarithm of x. 
  18614.  
  18615. Return Value 
  18616. log10 returns the computed value. If x is negative, log10 sets errno to EDOM 
  18617. and may return the value -HUGE_VAL. If x is zero, log10 returns the value 
  18618. -HUGE_VAL, and may set errno to ERANGE. 
  18619.  
  18620.  
  18621. ΓòÉΓòÉΓòÉ <hidden> Example of log10 ΓòÉΓòÉΓòÉ
  18622.  
  18623. /************************************************************************
  18624.  
  18625. This example calculates the base 10 logarithm of 1000.0. 
  18626.  
  18627. ************************************************************************/
  18628.  
  18629. #include <math.h>
  18630.  
  18631. int main(void)
  18632. {
  18633.    double x = 1000.0,y;
  18634.  
  18635.    y = log10(x);
  18636.    printf("The base 10 logarithm of %lf is %lf\n", x, y);
  18637.    return 0;
  18638.  
  18639.    /****************************************************************************
  18640.       The output should be:
  18641.  
  18642.       The base 10 logarithm of 1000.000000 is 3.000000
  18643.    ****************************************************************************/
  18644. }
  18645.  
  18646.  
  18647. ΓòÉΓòÉΓòÉ <hidden> Relative Information ΓòÉΓòÉΓòÉ
  18648.  
  18649. Example of log10 
  18650.  
  18651.      exp - Calculate Exponential Function 
  18652.      log - Calculate Natural Logarithm 
  18653.      pow - Compute Power 
  18654.      <math.h> 
  18655.  
  18656.  
  18657. ΓòÉΓòÉΓòÉ 4.182. longjmp - Restore Stack Environment ΓòÉΓòÉΓòÉ
  18658.  
  18659.  
  18660. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18661.  
  18662. #include <setjmp.h>
  18663. void longjmp(jmp_buf env, int value);
  18664.  
  18665.  
  18666. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18667.  
  18668. Language Level: ANSI, SAA, POSIX, XPG4 
  18669.  
  18670. longjmp restores a stack environment previously saved in env by setjmp. setjmp 
  18671. and longjmp provide a way to perform a nonlocal goto. They are often used in 
  18672. signal handlers. 
  18673.  
  18674. A call to setjmp causes the current stack environment to be saved in env.  A 
  18675. subsequent call to longjmp restores the saved environment and returns control 
  18676. to a point in the program corresponding to the setjmp call.  Execution resumes 
  18677. as if the setjmp call had just returned the given value. 
  18678.  
  18679. All variables (except register variables) that are accessible to the function 
  18680. that receives control contain the values they had when longjmp was called. The 
  18681. values of variables that are allocated to registers by the compiler are 
  18682. unpredictable. Because any auto variable could be allocated to a register in 
  18683. optimized code, you should consider the values of all auto variables to be 
  18684. unpredictable after a longjmp call. 
  18685.  
  18686. Note:  Ensure that the function that calls setjmp does not return before you 
  18687.        call the corresponding longjmp function. Calling longjmp after the 
  18688.        function calling setjmp returns causes unpredictable program behavior. 
  18689.  
  18690.  The value argument must be nonzero. If you give a zero argument for value, 
  18691.  longjmp substitutes 1 in its place. 
  18692.  
  18693.  C++ Considerations  When you call setjmp in a C++ program, ensure that that 
  18694.                      part of the program does not also create C++ objects that 
  18695.                      need to be destroyed. When you call longjmp, objects 
  18696.                      existing at the time of the setjmp call will still exist, 
  18697.                      but any destructors called after setjmp are not called. 
  18698.                      Click here for an example. 
  18699.  
  18700.  Return Value 
  18701.  longjmp does not use the normal function call and return mechanisms;  it has 
  18702.  no return value. 
  18703.  
  18704.  
  18705. ΓòÉΓòÉΓòÉ <hidden> Example of C++ setjmp/longjmp Restriction ΓòÉΓòÉΓòÉ
  18706.  
  18707. Given the following program: 
  18708.  
  18709. #include <stdio.h>
  18710. #include <setjmp.h>
  18711.  
  18712. class A {
  18713.    int i;
  18714.    public:
  18715.       A(int I) {i = I; printf("Constructed at line %d\n", i);}
  18716.       ~A() {printf("Destroying object constructed at line %d\n",i);}
  18717.    };
  18718. jmp_buf jBuf;
  18719.  
  18720. int main(void) {
  18721.    A a1(__LINE__);
  18722.    if (!setjmp(jBuf)) {
  18723.      A a2(__LINE__);
  18724.      printf("Press y (and Enter) to longjmp; anything else to return norm
  18725.      char c = getchar();
  18726.      if (c == 'y')
  18727.         longjmp(jBuf, 1);
  18728.    }
  18729.    A a3(__LINE__);
  18730.    return 0;
  18731. }
  18732.  
  18733. If you return normally, the output would be: 
  18734.  
  18735. Constructed at line 13
  18736. Constructed at line 15
  18737. Press y (and Enter) to longjmp; anything else to return normally
  18738. x
  18739. Destroying object constructed at line 15
  18740. Constructed at line 21
  18741. Destroying object constructed at line 21
  18742. Destroying object constructed at line 13
  18743.  
  18744. If you called longjmp, the output would be: 
  18745.  
  18746. Constructed at line 13
  18747. Constructed at line 15
  18748. Press y (and Enter) to longjmp; anything else to return normally
  18749. y
  18750. Constructed at line 21
  18751. Destroying object constructed at line 21
  18752. Destroying object constructed at line 13
  18753.  
  18754. Notice that the object from line 15 is not destroyed. 
  18755.  
  18756.  
  18757. ΓòÉΓòÉΓòÉ <hidden> Example of longjmp ΓòÉΓòÉΓòÉ
  18758.  
  18759. /************************************************************************
  18760.  
  18761. This example saves the stack environment at the statement: 
  18762.  
  18763.    if(setjmp(mark) != 0) ...
  18764.  
  18765. When the system first performs the if statement, it saves the environment in 
  18766. mark and sets the condition to FALSE because setjmp returns a 0 when it saves 
  18767. the environment. The program prints the message: 
  18768.  
  18769.   setjmp has been called
  18770.  
  18771. The subsequent call to function p tests for a local error condition, which can 
  18772. cause it to call longjmp.  Then, control returns to the original setjmp 
  18773. function using the environment saved in mark.  This time, the condition is TRUE 
  18774. because -1 is the return value from longjmp. The example then performs the 
  18775. statements in the block, prints longjmp has been called, calls recover, and 
  18776. leaves the program. 
  18777.  
  18778. ************************************************************************/
  18779.  
  18780. #include <stdio.h>
  18781. #include <setjmp.h>
  18782.  
  18783. jmp_buf mark;
  18784.  
  18785. int main(void)
  18786. {
  18787.    if (setjmp(mark) != 0) {
  18788.       printf("longjmp has been called\n");
  18789.       recover();
  18790.       exit(1);
  18791.    }
  18792.    printf("setjmp has been called\n");
  18793.  
  18794.    p();
  18795.  
  18796.    return 0;
  18797.  
  18798.    /****************************************************************************
  18799.       The output should be:
  18800.  
  18801.       setjmp has been called
  18802.       longjmp has been called
  18803.    ****************************************************************************/
  18804. }
  18805.  
  18806. int p(void)
  18807. {
  18808.    int error = 0;
  18809.  
  18810.    error = 9;
  18811.  
  18812.    if (error != 0)
  18813.       longjmp(mark, -1);
  18814.  
  18815. }
  18816.  
  18817. int recover(void)
  18818. {
  18819. }
  18820.  
  18821.  
  18822. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  18823.  
  18824. Example of longjmp 
  18825.  
  18826.      setjmp - Preserve Environment 
  18827.      goto in the Language Reference 
  18828.      <setjmp.h> 
  18829.  
  18830.  
  18831. ΓòÉΓòÉΓòÉ 4.183. _lrotl - _lrotr - Rotate Bits of Unsigned Long Value ΓòÉΓòÉΓòÉ
  18832.  
  18833.  
  18834. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18835.  
  18836. #include <stdlib.h>   /* also in <builtin.h> */
  18837. unsigned long _lrotl(unsigned long value, int shift);
  18838. unsigned long _lrotr(unsigned long value, int shift);
  18839.  
  18840.  
  18841. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18842.  
  18843. Language Level:  Extension 
  18844.  
  18845. _lrotl and _lrotr rotate the unsigned long integer value by shift bits. _lrotl 
  18846. rotates to the left, and _lrotr to the right. 
  18847.  
  18848. Note:  Both _lrotl and _lrotr are built-in functions, which means they are 
  18849. implemented as inline instructions and have no backing code in the library. For 
  18850. this reason: 
  18851.  
  18852.      You cannot take the address of these functions. 
  18853.      You cannot parenthesize a call to either function. (Parentheses specify a 
  18854.       call to the function's backing code, and these functions have none.) 
  18855.  
  18856.  Return Value 
  18857.  Both functions return the rotated value.  There is no error return value. 
  18858.  
  18859.  
  18860. ΓòÉΓòÉΓòÉ <hidden> Example of _lrotl - _lrotr ΓòÉΓòÉΓòÉ
  18861.  
  18862. /************************************************************************
  18863.  
  18864. This example uses _lrotl and _lrotr with different shift values to rotate the 
  18865. long integer value 0x01234567. 
  18866.  
  18867. ************************************************************************/
  18868.  
  18869. #include <stdio.h>
  18870. #include <stdlib.h>
  18871.  
  18872. int main(void)
  18873. {
  18874.    unsigned long val = 0X01234567;
  18875.  
  18876.    printf("The value of 0x%8.8lx rotated 4 bits to the left is 0x%8.8lx\n", val,
  18877.       _lrotl(val, 4));
  18878.    printf("The value of 0x%8.8lx rotated 16 bits to the right is 0x%8.8lx\n",
  18879.       val, _lrotr(val, 16));
  18880.    return 0;
  18881.  
  18882.    /****************************************************************************
  18883.       The output should be:
  18884.  
  18885.       The value of 0x01234567 rotated 4 bits to the left is 0x12345670
  18886.       The value of 0x01234567 rotated 16 bits to the right is 0x45670123
  18887.    ****************************************************************************/
  18888. }
  18889.  
  18890.  
  18891. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  18892.  
  18893. Example of _lrotl - _lrotr 
  18894.  
  18895.      _crotl - _crotr - Rotate Bits of Character Value 
  18896.      _rotl - _rotr - Rotate Bits of Unsigned Integer 
  18897.      _srotl - _srotr - Rotate Bits of Unsigned Short Value 
  18898.      <builtin.h> 
  18899.      <stdlib.h> 
  18900.  
  18901.  
  18902. ΓòÉΓòÉΓòÉ 4.184. lseek - Move File Pointer ΓòÉΓòÉΓòÉ
  18903.  
  18904.  
  18905. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  18906.  
  18907. #include <io.h>  /* constants in <stdio.h> */
  18908. long lseek(int handle, long offset, int origin);
  18909.  
  18910.  
  18911. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  18912.  
  18913. Language Level:  XPG4, Extension 
  18914.  
  18915. lseek moves any file pointer associated with handle to a new location that is 
  18916. offset bytes from the origin. The next operation on the file takes place at the 
  18917. new location. The origin must be one of the following constants, defined in 
  18918. <stdio.h>: 
  18919.  
  18920.  Origin         Definition 
  18921.  SEEK_SET       Beginning of file 
  18922.  SEEK_CUR       Current position of file pointer 
  18923.  SEEK_END       End of file. 
  18924.  
  18925.  lseek can reposition the pointer anywhere in a file. The pointer can also be 
  18926.  positioned beyond the end of the file; the data between the EOF and the new 
  18927.  file position is undefined. (See _chsize - Alter Length of File for more 
  18928.  information on extending the length of the file.) An attempt to position the 
  18929.  pointer before the beginning of the file causes an error. 
  18930.  
  18931.  Note:  In earlier releases of C Set ++, lseek began with an underscore 
  18932.  (_lseek). Because it is defined by the X/Open standard, the underscore has 
  18933.  been removed. For compatibility, VisualAge C++ will map _lseek to lseek for 
  18934.  you. 
  18935.  
  18936.  Return Value 
  18937.  lseek returns the offset, in bytes, of the new position from the beginning of 
  18938.  the file. A return value of -1L indicates an error, and lseek sets errno to 
  18939.  one of the following values: 
  18940.  
  18941.  Value        Meaning 
  18942.  EBADF        The file handle is incorrect. 
  18943.  EINVAL       The value for origin is incorrect, or the position specified by 
  18944.               offset is before the beginning of the file. 
  18945.  EOS2ERR      The call to the operating system was not successful. 
  18946.  
  18947.  On devices incapable of seeking (such as keyboards and printers), lseek 
  18948.  returns -1 and sets errno to EOS2ERR. 
  18949.  
  18950.  
  18951. ΓòÉΓòÉΓòÉ <hidden> Example of lseek ΓòÉΓòÉΓòÉ
  18952.  
  18953. /************************************************************************
  18954.  
  18955. This example opens the file sample.dat and, if successful, moves the file 
  18956. pointer to the eighth position in the file. The example then attempts to read 
  18957. bytes from the file, starting at the new pointer position, and reads them into 
  18958. the buffer. 
  18959.  
  18960. ************************************************************************/
  18961.  
  18962. #include <io.h>
  18963. #include <stdio.h>
  18964. #include <stdlib.h>
  18965. #include <fcntl.h>
  18966. #include <string.h>
  18967.  
  18968. int main(void)
  18969. {
  18970.    long length;
  18971.    int fh;
  18972.    char buffer[20];
  18973.  
  18974.    memset(buffer, '\0', 20);               /* Initialize the buffer           */
  18975.    printf("\nCreating sample.dat.\n");
  18976.    system("echo Sample Program > sample.dat");
  18977.    if (-1 == (fh = open("sample.dat", O_RDWR|O_APPEND))) {
  18978.       perror("Unable to open sample.dat.");
  18979.       exit(EXIT_FAILURE);
  18980.    }
  18981.    if (-1 == lseek(fh, 7, SEEK_SET)) {     /* place the file pointer at the   */
  18982.       perror("Unable to lseek");           /* eighth position in the file     */
  18983.       close(fh);
  18984.       return EXIT_FAILURE;
  18985.    }
  18986.    if (8 != read(fh, buffer, 8)) {
  18987.       perror("Unable to read from sample.dat.");
  18988.       close(fh);
  18989.       return EXIT_FAILURE;
  18990.    }
  18991.    printf("Successfully read in the following:\n%s.\n", buffer);
  18992.    close(fh);
  18993.    return 0;
  18994.  
  18995.    /****************************************************************************
  18996.       The output should be:
  18997.  
  18998.       Creating sample.dat.
  18999.       Successfully read in the following:
  19000.       Program .
  19001.    ****************************************************************************/
  19002. }
  19003.  
  19004.  
  19005. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19006.  
  19007. Example of lseek 
  19008.  
  19009.      _chsize - Alter Length of File 
  19010.      fseek - Reposition File Position 
  19011.      _tell - Get Pointer Position 
  19012.      <io.h> 
  19013.      <stdio.h> 
  19014.  
  19015.  
  19016. ΓòÉΓòÉΓòÉ 4.185. _ltoa - Convert Long Integer to String ΓòÉΓòÉΓòÉ
  19017.  
  19018.  
  19019. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19020.  
  19021. #include <stdlib.h>
  19022. char *_ltoa(long value, char *string, int radix);
  19023.  
  19024.  
  19025. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19026.  
  19027. Language Level:  Extension 
  19028.  
  19029. _ltoa converts the digits of the given long integer value to a character string 
  19030. that ends with a null character and stores the result in string. The radix 
  19031. argument specifies the base of value; it must be in the range 2 to 36. If radix 
  19032. equals 10 and value is negative, the first character of the stored string is 
  19033. the minus sign (-). 
  19034.  
  19035. Note:  The space allocated for string must be large enough to hold the returned 
  19036. string. The function can return up to 33 bytes, including the null character 
  19037. (\0). 
  19038.  
  19039. Return Value 
  19040. _ltoa returns a pointer to string. There is no error return value. 
  19041.  
  19042.  
  19043. ΓòÉΓòÉΓòÉ <hidden> Example of _ltoa ΓòÉΓòÉΓòÉ
  19044.  
  19045. /************************************************************************
  19046.  
  19047. This example converts the long integer -255L to a decimal, binary, and hex 
  19048. value, and stores its character representation in the array buffer. 
  19049.  
  19050. ************************************************************************/
  19051.  
  19052. #include <stdio.h>
  19053. #include <stdlib.h>
  19054.  
  19055. int main(void)
  19056. {
  19057.    char buffer[35];
  19058.    char *p;
  19059.  
  19060.    p = _ltoa(-255L, buffer, 10);
  19061.    printf("The result of _ltoa(-255) with radix of 10 is %s\n", p);
  19062.    p = _ltoa(-255L, buffer, 2);
  19063.    printf("The result of _ltoa(-255) with radix of 2\n    is %s\n", p);
  19064.    p = _ltoa(-255L, buffer, 16);
  19065.    printf("The result of _ltoa(-255) with radix of 16 is %s\n", p);
  19066.    return 0;
  19067.  
  19068.    /****************************************************************************
  19069.       The output should be:
  19070.  
  19071.       The result of _ltoa(-255) with radix of 10 is -255
  19072.       The result of _ltoa(-255) with radix of 2
  19073.           is 11111111111111111111111100000001
  19074.       The result of _ltoa(-255) with radix of 16 is ffffff01
  19075.    ****************************************************************************/
  19076. }
  19077.  
  19078.  
  19079. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19080.  
  19081. Example of _ltoa 
  19082.  
  19083.      atol - Convert Character String to Long Integer 
  19084.      _ecvt - Convert Floating-Point to Character 
  19085.      _fcvt - Convert Floating-Point to String 
  19086.      _gcvt - Convert Floating-Point to String 
  19087.      _itoa - Convert Integer to String 
  19088.      strtol - Convert Character String to Long Integer 
  19089.      _ultoa - Convert Unsigned Long Integer to String 
  19090.      wcstol - Convert Wide-Character to Long Integer 
  19091.      <stdlib.h> 
  19092.  
  19093.  
  19094. ΓòÉΓòÉΓòÉ 4.186. __lxchg - Exchange Integer Value with Memory ΓòÉΓòÉΓòÉ
  19095.  
  19096.  
  19097. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19098.  
  19099. #include <builtin.h>
  19100. int _Builtin __lxchg(volatile int*lockptr, int value);
  19101.  
  19102.  
  19103. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19104.  
  19105. Language Level:  Extension 
  19106.  
  19107. __lxchg puts the specified value in the memory location pointed to by lockptr, 
  19108. and returns the value that was previously in that location. 
  19109.  
  19110. Use this function to implement fast-RAM semaphores to serialize access to a 
  19111. critical resource (so that only one thread can use it at a time). You can also 
  19112. use OS/2 semaphores to serialize resource access, but they are slower. 
  19113. Typically you would create both a fast-RAM semaphore and an OS/2 semaphore for 
  19114. the resource. For more details about OS/2 semaphores and how to use them, see 
  19115. the Control Program Guide and Reference. 
  19116.  
  19117. To implement a fast-RAM semaphore, allocate a volatile memory location lockptr 
  19118. (for __lxchg, it must be of type int), and statically initialize it to 0 to 
  19119. indicate that the resource is free (not being used). To give a thread access to 
  19120. the resource, call __lxchg from the thread to exchange a non-zero value with 
  19121. that memory location. If __lxchg returns 0, the thread can access the resource; 
  19122. it has also set the memory location so that other threads can tell the resource 
  19123. is in use. When your thread no longer needs the resource, call __lxchg again to 
  19124. reset the memory location to 0. 
  19125.  
  19126. If __lxchg returns a non-zero value, another thread is already using the 
  19127. resource, and the calling thread must wait for access. You could then use the 
  19128. OS/2 semaphore to inform your waiting thread when the resource is unlocked by 
  19129. the thread currently using it. 
  19130.  
  19131. It is important that you set the memory to a nonzero value when you are using 
  19132. the resource.  You can use the same nonzero value for all threads, or a unique 
  19133. value for each. 
  19134.  
  19135. Note:  __lxchg is a built-in function, which means it is implemented as an 
  19136. inline instruction and has no backing code in the library.  For this reason: 
  19137.  
  19138.      You cannot take the address of __lxchg. 
  19139.      You cannot parenthesize a call to __lxchg. (Parentheses specify a call to 
  19140.       the function's backing code, and __lxchg has none.) 
  19141.  
  19142.  Return Value 
  19143.  __lxchg returns the previous value stored in the memory location pointed to by 
  19144.  lockptr. 
  19145.  
  19146.  
  19147. ΓòÉΓòÉΓòÉ <hidden> Example of __lxchg ΓòÉΓòÉΓòÉ
  19148.  
  19149. /************************************************************************
  19150.  
  19151. This example creates five separate threads, each associated with a State. At 
  19152. most two threads can have a State of Eating at the same time. When a thread 
  19153. calls PickUpChopSticks, that function checks the states of the preceding 
  19154. threads to make sure they are not already Eating, If the call to __lxchg is 
  19155. successful, the thread has locked the Lock semaphore and can change its State 
  19156. to Eating. It then calls __lxchg a second time to unlock the semaphore, and 
  19157. returns. 
  19158.  
  19159. If __lxchg cannot lock the semaphore, another thread has it locked.  The 
  19160. current thread then suspends itself briefly with DosSleep and tries again. The 
  19161. semaphore is used to ensure that two threads cannot simultaneously change their 
  19162. State to Eating, which would cause a deadlock. (Note that although the 
  19163. semaphore solves the problem of deadlock, it is not an optimal solution; some 
  19164. threads may never get the semaphore or the State of Eating.) 
  19165.  
  19166. Note:  You must compile this example with the multithread (/Gm) option. The 
  19167. example runs in an infinite loop; press Ctrl-C to end it. 
  19168.  
  19169. ************************************************************************/
  19170.  
  19171. #pragma strings(readonly)
  19172.  
  19173. #define INCL_DOS
  19174. #include <os2.h>
  19175. #include <stdlib.h>
  19176. #include <stdio.h>
  19177. #include <builtin.h>
  19178.  
  19179. typedef enum {
  19180.    Thinking,
  19181.    Eating,
  19182.    Hungry
  19183. } States;
  19184.  
  19185. #define UNLOCKED 0
  19186. #define LOCKED   1
  19187. #define NUM_PHILOSOPHERS 5
  19188.  
  19189. static volatile int Lock;
  19190. static States State[NUM_PHILOSOPHERS];
  19191. static const int NameMap[NUM_PHILOSOPHERS] = {0, 1, 2, 3, 4};
  19192. static const char * const Names[NUM_PHILOSOPHERS] = {"Plato",
  19193.                                                      "Socrates",
  19194.                                                      "Kant",
  19195.                                                      "Hegel",
  19196.                                                      "Nietsche"};
  19197.  
  19198. void PickUpChopSticks(int Ident);
  19199. void PutDownChopSticks(int Ident);
  19200. void Think(int Ident);
  19201. void Eat(int Ident);
  19202. void _Optlink StartPhilosopher(void *pIdent);
  19203.  
  19204. void _Optlink StartPhilosopher(void *pIdent)
  19205. {
  19206.    int Ident = *(int *)pIdent;
  19207.    while (1) {
  19208.       State[Ident] = Hungry;
  19209.       printf("%s hungry.\n", Names[Ident]);
  19210.       PickUpChopSticks(Ident);
  19211.       Eat(Ident);
  19212.       PutDownChopSticks(Ident);
  19213.       Think(Ident);
  19214.    }
  19215. }
  19216.  
  19217. int main(int argc, char *argv[], char *envp[])
  19218. {
  19219.    int           i;
  19220.    unsigned long tid;
  19221.  
  19222.    for (i = 0; i < NUM_PHILOSOPHERS; i++) {
  19223.       tid = _beginthread(StartPhilosopher, NULL, 8192, (void *)&NameMap[i]);
  19224.       if (tid == -1) {
  19225.          printf("Unable to start %s.\n", Names[i]);
  19226.       }
  19227.       else {
  19228.          printf("%s started with Thread Id = %d.\n", Names[i], tid);
  19229.       }
  19230.    }
  19231.    DosWaitThread(&tid, DCWW_WAIT);
  19232.  
  19233.    return 0;
  19234. }
  19235.  
  19236. void PickUpChopSticks(int Ident)
  19237. {
  19238.    while (1) {
  19239.       if (State[(Ident + NUM_PHILOSOPHERS - 1) % NUM_PHILOSOPHERS] != Eating &&
  19240.           State[(Ident + 1) % NUM_PHILOSOPHERS] != Eating                    &&
  19241.           !__lxchg(&Lock, LOCKED)) {
  19242.             State[Ident] = Eating;
  19243.             __lxchg(&Lock, UNLOCKED);
  19244.             return;
  19245.       }
  19246.       else {
  19247.          DosSleep(1);
  19248.       }
  19249.    }
  19250. }
  19251.  
  19252. void PutDownChopSticks(int Ident)
  19253. {
  19254.    State[Ident] = Thinking;
  19255. }
  19256.  
  19257. void Eat(int Ident)
  19258. {
  19259.    printf("%s eating.\n", Names[Ident]);
  19260.    DosSleep(1);
  19261. }
  19262.  
  19263. void Think(int Ident)
  19264. {
  19265.    printf("%s thinking.\n", Names[Ident]);
  19266.    DosSleep(1);
  19267. }
  19268.  
  19269.    /****************************************************************************
  19270.       The output should be similar to :
  19271.  
  19272.       Plato started with Thread Id = 2.
  19273.       Socrates started with Thread Id = 3.
  19274.       Kant started with Thread Id = 4.
  19275.       Hegel started with Thread Id = 5.
  19276.       Nietsche started with Thread Id = 6.
  19277.       Plato hungry.
  19278.       Plato eating.
  19279.       Socrates hungry.
  19280.       Kant hungry.
  19281.       Kant eating.
  19282.       Hegel hungry.
  19283.       Nietsche hungry.
  19284.       Kant thinking.
  19285.       Plato thinking.
  19286.       Plato hungry.
  19287.       Plato eating.
  19288.       Kant hungry.
  19289.       Kant eating.
  19290.         :
  19291.    ****************************************************************************/
  19292.  
  19293.  
  19294. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19295.  
  19296. Example of __lxchg 
  19297.  
  19298.      __cxchg - Exchange Character Value with Memory 
  19299.      __sxchg - Exchange Integer Value with Memory 
  19300.      <builtin.h> 
  19301.  
  19302.  
  19303. ΓòÉΓòÉΓòÉ 4.187. _makepath - Create Path ΓòÉΓòÉΓòÉ
  19304.  
  19305.  
  19306. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19307.  
  19308. #include <stdlib.h>
  19309. void _makepath(char *path, char *drive, char *dir, char *fname, char *ext);
  19310.  
  19311.  
  19312. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19313.  
  19314. Language Level:  Extension 
  19315.  
  19316. _makepath creates a single path name, composed of a drive letter, directory 
  19317. path, file name, and file name extension. 
  19318.  
  19319. The path argument should point to an empty buffer large enough to hold the 
  19320. complete path name. The constant _MAX_PATH, defined in <stdlib.h>, specifies 
  19321. the maximum size allowed for path. The other arguments point to the following 
  19322. buffers containing the path name elements: 
  19323.  
  19324.  drive   A letter (A, B, ...) corresponding to the desired drive and an 
  19325.          optional following colon. _makepath inserts the colon automatically in 
  19326.          the composite path name if it is missing.  If drive is a null 
  19327.          character or an empty string, no drive letter or colon appears in the 
  19328.          composite path string. 
  19329.  
  19330.  dir     The path of directories, not including the drive designator or the 
  19331.          actual file name.  The trailing slash is optional, and either slash 
  19332.          (/) or backslash (\) or both can be used in a single dir argument.  If 
  19333.          a trailing slash or backslash is not specified, it is inserted 
  19334.          automatically.  If dir is a null character or an empty string, no 
  19335.          slash is inserted in the composite path string. 
  19336.  
  19337.  fname   The base file name without any extensions. 
  19338.  
  19339.  ext     The actual file name extension, with or without a leading period. 
  19340.          _makepath inserts the period automatically if it does not appear in 
  19341.          ext.  If ext is a null character or an empty string, no period is 
  19342.          inserted in the composite path string. 
  19343.  
  19344.  The size limits on the above four fields are those specified by the constants 
  19345.  _MAX_DRIVE, _MAX_DIR, _MAX_FNAME, and _MAX_EXT, which are defined in 
  19346.  <stdlib.h>. The composite path should be no larger than the _MAX_PATH constant 
  19347.  also defined in <stdlib.h>; otherwise, the operating system does not handle it 
  19348.  correctly. 
  19349.  
  19350.  Note:  No checking is done to see if the syntax of the file name is correct. 
  19351.  
  19352.  Return Value 
  19353.  There is no return value. 
  19354.  
  19355.  
  19356. ΓòÉΓòÉΓòÉ <hidden> Example of _makepath ΓòÉΓòÉΓòÉ
  19357.  
  19358. /************************************************************************
  19359.  
  19360. This example builds a file name path from the specified components. 
  19361.  
  19362. ************************************************************************/
  19363.  
  19364. #include <stdio.h>
  19365. #include <stdlib.h>
  19366.  
  19367. int main(void)
  19368. {
  19369.    char path_buffer[_MAX_PATH];
  19370.    char drive[_MAX_DRIVE];
  19371.    char dir[_MAX_DIR];
  19372.    char fname[_MAX_FNAME];
  19373.    char ext[_MAX_EXT];
  19374.  
  19375.    _makepath(path_buffer, "c", "qc\\bob\\eclibref\\e", "makepath", "c");
  19376.    printf("Path created with _makepath: %s\n\n", path_buffer);
  19377.    _splitpath(path_buffer, drive, dir, fname, ext);
  19378.    printf("Path extracted with _splitpath:\n");
  19379.    printf("drive: %s\n", drive);
  19380.    printf("directory: %s\n", dir);
  19381.    printf("file name: %s\n", fname);
  19382.    printf("extension: %s\n", ext);
  19383.    return 0;
  19384.  
  19385.    /****************************************************************************
  19386.       The output should be:
  19387.  
  19388.       Path created with _makepath: c:qc\bob\eclibref\e\makepath.c
  19389.  
  19390.       Path extracted with _splitpath:
  19391.       drive: c:
  19392.       directory: qc\bob\eclibref\e\
  19393.       file name: makepath
  19394.       extension: .c
  19395.    ****************************************************************************/
  19396. }
  19397.  
  19398.  
  19399. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19400.  
  19401. Example of _makepath 
  19402.  
  19403.      _fullpath - Get Full Path Name of Partial Path 
  19404.      _splitpath - Decompose Path Name 
  19405.      <stdlib.h> 
  19406.  
  19407.  
  19408. ΓòÉΓòÉΓòÉ 4.188. malloc - Reserve Storage Block ΓòÉΓòÉΓòÉ
  19409.  
  19410.  
  19411. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19412.  
  19413. #include <stdlib.h>  /* also in <malloc.h> */
  19414. void *malloc(size_t size);
  19415.  
  19416.  
  19417. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19418.  
  19419. Language Level:  ANSI, SAA, POSIX, XPG4, Extension 
  19420.  
  19421. malloc reserves a block of storage of size bytes. Unlike calloc, malloc does 
  19422. not initialize all elements to 0. 
  19423.  
  19424. Heap-specific, tiled, and debug versions of this function (_umalloc, _tmalloc, 
  19425. and _debug_malloc) are also available. malloc always operates on the default 
  19426. heap. For more information about memory management, see Managing Memory in the 
  19427. Programming Guide. 
  19428.  
  19429. Return Value 
  19430. malloc returns a pointer to the reserved space. The storage space to which the 
  19431. return value points is suitably aligned for storage of any type of object. The 
  19432. return value is NULL if not enough storage is available, or if size was 
  19433. specified as zero. 
  19434.  
  19435.  
  19436. ΓòÉΓòÉΓòÉ <hidden> Example of malloc ΓòÉΓòÉΓòÉ
  19437.  
  19438. /************************************************************************
  19439.  
  19440. This example prompts for the number of array entries you want and then reserves 
  19441. enough space in storage for the entries. If malloc was successful, the example 
  19442. assigns values to the entries and prints out each entry;  otherwise, it prints 
  19443. out an error. 
  19444.  
  19445. ************************************************************************/
  19446.  
  19447. #include <stdio.h>
  19448. #include <stdlib.h>
  19449.  
  19450. int main(void)
  19451. {
  19452.    long *array;                              /* start of the array            */
  19453.    long *index;                                           /* index variable   */
  19454.    int i;                                                 /* index variable   */
  19455.    int num;                             /* number of entries of the array     */
  19456.  
  19457.    printf("Enter the size of the array\n");
  19458.    scanf("%i", &num);
  19459.  
  19460.    /* allocate num entries                                                    */
  19461.  
  19462.    if ((index = array = malloc(num *sizeof(long))) != NULL) {
  19463.       for (i = 0; i < num; ++i)             /* put values in array            */
  19464.          *index++ = i;                      /* using pointer notation         */
  19465.       for (i = 0; i < num; ++i)             /* print the array out            */
  19466.          printf("array[ %i ] = %i\n", i, array[i]);
  19467.    }
  19468.    else {                                                 /* malloc error     */
  19469.       perror("Out of storage");
  19470.       abort();
  19471.    }
  19472.    return 0;
  19473.  
  19474.    /****************************************************************************
  19475.       The output should be similar to:
  19476.  
  19477.       Enter the size of the array
  19478.       5
  19479.       array[ 0 ] = 0
  19480.       array[ 1 ] = 1
  19481.       array[ 2 ] = 2
  19482.       array[ 3 ] = 3
  19483.       array[ 4 ] = 4
  19484.    ****************************************************************************/
  19485. }
  19486.  
  19487.  
  19488. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19489.  
  19490. Example of malloc 
  19491.  
  19492.      calloc - Reserve and Initialize Storage 
  19493.      _debug_malloc - Allocate Memory 
  19494.      _debug_tmalloc - Reserve Tiled Memory 
  19495.      _debug_umalloc - Reserve Memory Blocks from User Heap 
  19496.      free - Release Storage Blocks 
  19497.      _mheap - Query Memory Heap for Allocated Object 
  19498.      _msize - Return Number of Bytes Allocated 
  19499.      realloc - Change Reserved Storage Block Size 
  19500.      _tmalloc - Reserve Tiled Storage Block 
  19501.      _umalloc - Reserve Memory Blocks from User Heap 
  19502.      <malloc.h> 
  19503.      <stdlib.h> 
  19504.  
  19505.  
  19506. ΓòÉΓòÉΓòÉ 4.189. _matherr - Process Math Library Errors ΓòÉΓòÉΓòÉ
  19507.  
  19508.  
  19509. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19510.  
  19511. #include <math.h>
  19512. int _matherr(struct exception *x);
  19513.  
  19514.  
  19515. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19516.  
  19517. Language Level:  Extension 
  19518.  
  19519. _matherr processes errors generated by the functions in the math library. The 
  19520. math functions call _matherr whenever they detect an error. The _matherr 
  19521. function supplied with the VisualAge C++ library performs no error handling and 
  19522. returns 0 to the calling function. 
  19523.  
  19524. You can provide a different definition of _matherr to carry out special error 
  19525. handling. Be sure to use the /NOE link option, if you are using your own 
  19526. _matherr function. For VisualAge C++ compiler, you can use the /B option on the 
  19527. icc command line to pass the /NOE option to the linker, as in the following: 
  19528.  
  19529.    icc /B"/NOE" yourfile.c
  19530.  
  19531. When an error occurs in a math routine, _matherr is called with a pointer to 
  19532. the following structure (defined in <math.h>) as an argument: 
  19533.  
  19534.    struct exception {
  19535.        int type;
  19536.        char *name;
  19537.        double arg1, arg2, retval;
  19538.    };
  19539.  
  19540. The type field specifies the type of math error. It has one of the following 
  19541. values, defined in <math.h>: 
  19542.  
  19543.  Value          Meaning 
  19544.  DOMAIN         Argument domain error 
  19545.  OVERFLOW       Overflow range error 
  19546.  UNDERFLOW      Underflow range error 
  19547.  TLOSS          Total loss of significance 
  19548.  PLOSS          Partial loss of significance 
  19549.  SING           Argument singularity. 
  19550.  
  19551.  PLOSS is provided for compatibility with other compilers; VisualAge C++ does 
  19552.  not generate this value. 
  19553.  
  19554.  The name is a pointer to a null-ended string containing the name of the 
  19555.  function that caused the error. The arg1 and arg2 fields specify the argument 
  19556.  values that caused the error. If only one argument is given, it is stored in 
  19557.  arg1. The retval is the default return value; you can change it. 
  19558.  
  19559.  Return Value 
  19560.  The return value from _matherr must specify whether or not an error actually 
  19561.  occurred. If _matherr returns 0, an error message appears, and errno is set to 
  19562.  an appropriate error value. If _matherr returns a nonzero value, no error 
  19563.  message appears and errno remains unchanged. 
  19564.  
  19565.  
  19566. ΓòÉΓòÉΓòÉ <hidden> Example of _matherr ΓòÉΓòÉΓòÉ
  19567.  
  19568. /************************************************************************
  19569.  
  19570. This example provides a _matherr function to handle errors from the log or 
  19571. log10 functions. The arguments to these logarithmic functions must be positive 
  19572. double values. _matherr processes a negative value in an argument (a domain 
  19573. error) by returning the log of its absolute value. It suppresses the error 
  19574. message normally displayed when this error occurs.  If the error is a zero 
  19575. argument or if some other routine produced the error, the example takes the 
  19576. default actions. 
  19577.  
  19578. Note:  You must compile this example with the /B"/NOE" compiler option. 
  19579.  
  19580. ************************************************************************/
  19581.  
  19582. #include <math.h>
  19583. #include <string.h>
  19584. #include <stdio.h>
  19585. #include <stdlib.h>
  19586.  
  19587. int main(void)
  19588. {
  19589.    int value;
  19590.  
  19591.    printf("Trying to evaluate log10(-1000.00) will create a math exception.\n");
  19592.    value = log10(-1000.00);
  19593.    printf("The _matherr() exception handler evaluates the expression to\n");
  19594.    printf("log10(-1000.00) = %d\n", value);
  19595.    return 0;
  19596.  
  19597.    /****************************************************************************
  19598.       The output should be:
  19599.  
  19600.       Trying to evaluate log10(-1000.00) will create a math exception.
  19601.       inside _matherr
  19602.       The _matherr() exception handler evaluates the expression to
  19603.       log10(-1000.00) = 3
  19604.    ****************************************************************************/
  19605. }
  19606.  
  19607. int _matherr(struct exception *x)
  19608. {
  19609.    printf("inside _matherr\n");
  19610.    if (DOMAIN == x->type) {
  19611.       if (0 == strcmp(x->name, "log")) {
  19612.          x->retval = log(-(x->arg1));
  19613.          return EXIT_FAILURE;
  19614.       }
  19615.       else
  19616.          if (0 == strcmp(x->name, "log10")) {
  19617.             x->retval = log10(-(x->arg1));
  19618.             return EXIT_FAILURE;
  19619.          }
  19620.    }
  19621.    return 0;                                  /* Use default actions          */
  19622. }
  19623.  
  19624.  
  19625. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19626.  
  19627. Example of _matherr 
  19628.  
  19629.      log - Calculate Natural Logarithm 
  19630.      log10 - Calculate Base 10 Logarithm 
  19631.      <math.h> 
  19632.  
  19633.  
  19634. ΓòÉΓòÉΓòÉ 4.190. max - Return Larger of Two Values ΓòÉΓòÉΓòÉ
  19635.  
  19636.  
  19637. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19638.  
  19639. #include <stdlib.h>
  19640. type max(type a, type b);
  19641.  
  19642.  
  19643. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19644.  
  19645. Language Level:  Extension 
  19646.  
  19647. max compares two values and determines the larger of the two. The data type can 
  19648. be any arithmetic data type, signed or unsigned.  Both arguments must have the 
  19649. same type for each call to max. 
  19650.  
  19651. Note:  Because max is a macro, if the evaluation of the arguments contains side 
  19652. effects (post-increment operators, for example), the results of both the side 
  19653. effects and the macro will be undefined. 
  19654.  
  19655. Return Value 
  19656. max returns the larger of the two values. 
  19657.  
  19658.  
  19659. ΓòÉΓòÉΓòÉ <hidden> Example of max ΓòÉΓòÉΓòÉ
  19660.  
  19661. /************************************************************************
  19662.  
  19663. This example prints the larger of the two values, a and b. 
  19664.  
  19665. ************************************************************************/
  19666.  
  19667. #include <stdlib.h>
  19668. #include <stdio.h>
  19669.  
  19670. int main(void)
  19671. {
  19672.    int a = 10;
  19673.    int b = 21;
  19674.  
  19675.    printf("The larger of %d and %d is %d\n", a, b, max(a, b));
  19676.    return 0;
  19677.  
  19678.    /****************************************************************************
  19679.       The output should be:
  19680.  
  19681.       The larger of 10 and 21 is 21
  19682.    ****************************************************************************/
  19683. }
  19684.  
  19685.  
  19686. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19687.  
  19688. Example of max 
  19689.  
  19690.      min - Return Lesser of Two Values 
  19691.      <stdlib.h> 
  19692.  
  19693.  
  19694. ΓòÉΓòÉΓòÉ 4.191. maxcoll - Return Maximum Collating Element ΓòÉΓòÉΓòÉ
  19695.  
  19696.  
  19697. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19698.  
  19699. #include <collate.h>
  19700. collel_t maxcoll(void);
  19701.  
  19702.  
  19703. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19704.  
  19705. Language Level:  Extension 
  19706.  
  19707. maxcoll determines the largest possible value of a collating element in the 
  19708. current locale. 
  19709.  
  19710. Return Value 
  19711. maxcoll returns the largest collating element. 
  19712.  
  19713.  
  19714. ΓòÉΓòÉΓòÉ <hidden> Example of maxcoll ΓòÉΓòÉΓòÉ
  19715.  
  19716. /************************************************************************
  19717.  
  19718. This example sets the current locale to several different locales, and uses 
  19719. maxcoll to determine the largest collating element for each. 
  19720.  
  19721. ************************************************************************/
  19722.  
  19723. #include <stdio.h>
  19724. #include <locale.h>
  19725. #include <collate.h>
  19726.  
  19727. #define LOCALEMAX   4
  19728. static char *locales[LOCALEMAX] =
  19729.    {"ES_ES.IBM-850", "EN_US.IBM-850", "FR_FR.IBM-850", "JA_JP.IBM-932"};
  19730.  
  19731. int main(void)
  19732. {
  19733.    int locnum;
  19734.  
  19735.    for (locnum = 0; locnum < LOCALEMAX; locnum++) {
  19736.       if (NULL == setlocale(LC_ALL, locales[locnum]))
  19737.          printf("setlocale(LC_ALL, \"%s\") failed.\n", locales[locnum]);
  19738.       else {
  19739.          printf("The current locale is %s.\n", locales[locnum]);
  19740.          printf("    maxcoll() returned %d\n", maxcoll());
  19741.       }
  19742.    }
  19743.    return 0;
  19744.  
  19745.    /****************************************************************************
  19746.       The output should be similar to :
  19747.  
  19748.       The current locale is ES_ES.IBM-850.
  19749.           maxcoll() returned 263
  19750.       The current locale is EN_US.IBM-850.
  19751.           maxcoll() returned 255
  19752.       The current locale is FR_FR.IBM-850.
  19753.           maxcoll() returned 255
  19754.       The current locale is JA_JP.IBM-932.
  19755.           maxcoll() returned 64587
  19756.    ****************************************************************************/
  19757. }
  19758.  
  19759.  
  19760. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19761.  
  19762. Example of maxcoll 
  19763.  
  19764.      cclass - Return Characters in Character Class 
  19765.      collequiv - Return List of Equivalent Collating Elements 
  19766.      collorder - Return List of Collating Elements 
  19767.      collrange - Calculate Range of Collating Elements 
  19768.      colltostr - Return String for Collating Element 
  19769.      getmccoll - Get Next Collating Element from String 
  19770.      getwmccoll - Get Next Collating Element from Wide String 
  19771.      ismccollel - Identify Multi-Character Collating Element 
  19772.      strtocoll - Return Collating Element for String 
  19773.      <collate.h> 
  19774.  
  19775.  
  19776. ΓòÉΓòÉΓòÉ 4.192. mblen - Determine Length of Multibyte Character ΓòÉΓòÉΓòÉ
  19777.  
  19778.  
  19779. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19780.  
  19781. #include <stdlib.h>
  19782. int mblen(const char *string, size_t n);
  19783.  
  19784.  
  19785. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19786.  
  19787. Language Level:  ANSI, SAA, XPG4 
  19788.  
  19789. mblen determines the length in bytes of the multibyte character pointed to by 
  19790. string. A maximum of n bytes is examined. 
  19791.  
  19792. The behavior of mblen is affected by the LC_CTYPE category of the current 
  19793. locale. 
  19794.  
  19795. Return Value 
  19796. If string is NULL, mblen returns 0. 
  19797.  
  19798. Note:  On platforms that support shift states, mblen can also return a nonzero 
  19799. value to indicate that the multibyte encoding is state-dependent.  Because 
  19800. VisualAge C++ does not support state-dependent encoding, mblen always returns 0 
  19801. when string is NULL. 
  19802.  
  19803. If string is not NULL, mblen returns: 
  19804.  
  19805.      0 if string points to the null character 
  19806.      The number of bytes comprising the multibyte character 
  19807.      The value -1 if string does not point to a valid multibyte character. 
  19808.  
  19809.  
  19810. ΓòÉΓòÉΓòÉ <hidden> Example of mblen ΓòÉΓòÉΓòÉ
  19811.  
  19812. /************************************************************************
  19813.  
  19814. This example uses mblen and mbtowc to convert a multibyte character into a 
  19815. single wide character. 
  19816.  
  19817. ************************************************************************/
  19818.  
  19819. #include <stdio.h>
  19820. #include <stdlib.h>
  19821. #include <wchar.h>
  19822. #include <locale.h>
  19823.  
  19824. int main(void)
  19825. {
  19826.    char     mb_string[] = "\x81\x41\x81\xc2" "b";
  19827.    int      length;
  19828.    wchar_t  widechar;
  19829.  
  19830.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  19831.       printf("setlocale failed.\n");
  19832.       exit(EXIT_FAILURE);
  19833.    }
  19834.    length = mblen(mb_string, MB_CUR_MAX);
  19835.    mbtowc(&widechar, mb_string, length);
  19836.    printf("The wide character %lc has length of %d.\n", widechar, length);
  19837.    return 0;
  19838.  
  19839.    /****************************************************************************
  19840.       The output should be similar to :
  19841.  
  19842.       The wide character ΓöÇA has length of 2.
  19843.    ****************************************************************************/
  19844. }
  19845.  
  19846.  
  19847. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19848.  
  19849. Example of mblen 
  19850.  
  19851.      mbrlen - Calculate Length of Multibyte Character 
  19852.      mbrtowc - Convert Multibyte Character to Wide Character 
  19853.      mbsrtowcs - Convert Multibyte String to Wide-Character String 
  19854.      mbstowcs - Convert Multibyte String to Wide-Character String 
  19855.      mbtowc - Convert Multibyte Character to Wide Character 
  19856.      setlocale - Set Locale 
  19857.      strlen - Determine String Length 
  19858.      wcrtomb - Convert Wide Character to Multibyte Character 
  19859.      wcslen - Calculate Length of Wide-Character String 
  19860.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  19861.      wctomb -  Convert Wide Character to Multibyte Character 
  19862.      <locale.h> 
  19863.      <stdlib.h> 
  19864.  
  19865.  
  19866. ΓòÉΓòÉΓòÉ 4.193. mbrlen - Calculate Length of Multibyte Character ΓòÉΓòÉΓòÉ
  19867.  
  19868.  
  19869. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19870.  
  19871. #include <wchar.h>
  19872. size_t mbrlen(const char *string, size_t n,
  19873.               mbstate_t *state);
  19874.  
  19875.  
  19876. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19877.  
  19878. Language Level:  ANSI 93 
  19879.  
  19880. mbrlen is a restartable version of mblen and performs the same function. It 
  19881. determines the length in bytes of the multibyte character pointed to by string. 
  19882. A maximum of n bytes are examined. 
  19883.  
  19884. With mbrlen, you can switch from one multibyte string to another. On platforms 
  19885. that support shift states, state represents the initial shift state of the 
  19886. string (0).  If you read in only part of the string, mbrlen sets state to the 
  19887. string's shift state at the point you stopped.  You can then call mbrlen again 
  19888. for that string and pass in the updated state value to continue reading where 
  19889. you left off. 
  19890.  
  19891. Note:  Because OS/2 does not have shift states, the state parameter is provided 
  19892. only for compatibility with other ANSI/ISO platforms.  VisualAge C++ ignores 
  19893. the value passed for state. 
  19894.  
  19895. The behavior of mbrlen is affected by the LC_CTYPE category of the current 
  19896. locale. 
  19897.  
  19898. Return Value 
  19899. If string is a null pointer, mbrlen returns 0. 
  19900.  
  19901. If string is not a null pointer, mbrlen returns the first of the following that 
  19902. applies: 
  19903.  
  19904.  0    If the next n or fewer bytes complete the valid multibyte character that 
  19905.       corresponds to the null wide character. 
  19906.  
  19907.  positive If the next n or fewer bytes complete the valid multibyte character; 
  19908.       the value returned is the number of bytes that complete the multibyte 
  19909.       character. 
  19910.  
  19911.  -2   If the next n bytes form an incomplete (but potentially valid) multibyte 
  19912.       character, and all n bytes have been processed. 
  19913.  
  19914.  -1   If an encoding error occurs (when the next n or fewer bytes do not form a 
  19915.       complete and valid multibyte character).  mbrlen sets errno to EILSEQ. 
  19916.  
  19917.  
  19918. ΓòÉΓòÉΓòÉ <hidden> Example of mbrlen ΓòÉΓòÉΓòÉ
  19919.  
  19920. /************************************************************************
  19921.  
  19922. This example uses mbrlen to determine the length of the strings mbs1 and mbs2. 
  19923.  
  19924. ************************************************************************/
  19925.  
  19926. #include <wchar.h>
  19927. #include <stdio.h>
  19928. #include <stdlib.h>
  19929. #include <locale.h>
  19930.  
  19931. int main(void)
  19932. {
  19933.    char       mbs1[] = "abc";
  19934.    char       mbs2[] = "\x81\x41" "a" "\x81\xc1";
  19935.    mbstate_t  ss1 = 0;
  19936.    mbstate_t  ss2 = 0;
  19937.    size_t     length1, length2;
  19938.  
  19939.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  19940.       printf("setlocale failed.\n");
  19941.       exit(EXIT_FAILURE);
  19942.    }
  19943.    length1 =  mbrlen(mbs1, MB_CUR_MAX, &ss1);             /* first char  */
  19944.    length2 =  mbrlen(mbs2, MB_CUR_MAX, &ss2);             /* first char  */
  19945.    length1 += mbrlen(mbs1 + length1, MB_CUR_MAX, &ss1);   /* second char */
  19946.    length2 += mbrlen(mbs2 + length2, MB_CUR_MAX, &ss2);   /* second char */
  19947.    length1 += mbrlen(mbs1 + length1, MB_CUR_MAX, &ss1);   /* third char  */
  19948.    length2 += mbrlen(mbs2 + length2, MB_CUR_MAX, &ss2);   /* third char  */
  19949.    printf("Length of the first multibyte string = %d\n", length1);
  19950.    printf("Length of the second multibyte string = %d\n", length2);
  19951.    return 0;
  19952.  
  19953.    /****************************************************************************
  19954.       The output should be similiar to :
  19955.  
  19956.       Length of the first multibyte string = 3
  19957.       Length of the second multibyte string = 5
  19958.    ****************************************************************************/
  19959. }
  19960.  
  19961.  
  19962. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  19963.  
  19964. Example of mbrlen 
  19965.  
  19966.      mblen - Determine Length of Multibyte Character 
  19967.      mbtowc - Convert Multibyte Character to Wide Character 
  19968.      mbrtowc - Convert Multibyte Character to Wide Character 
  19969.      mbsrtowcs - Convert Multibyte String to Wide-Character String 
  19970.      setlocale - Set Locale 
  19971.      wcrtomb - Convert Wide Character to Multibyte Character 
  19972.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  19973.      <locale.h> 
  19974.      <wchar.h> 
  19975.  
  19976.  
  19977. ΓòÉΓòÉΓòÉ 4.194. mbrtowc - Convert Multibyte Character to Wide Character ΓòÉΓòÉΓòÉ
  19978.  
  19979.  
  19980. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  19981.  
  19982. #include <wchar.h>
  19983. size_t mbrtowc (wchar_t *pwc, const char *string,
  19984.                 size_t n, mbstate_t *ps);
  19985.  
  19986.  
  19987. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  19988.  
  19989. Language Level:  ANSI 93 
  19990.  
  19991. mbrtowc is a restartable version of mbtowc, and performs the same function. It 
  19992. first determines the length of the multibyte character pointed to by string. It 
  19993. then converts the multibyte character to the corresponding wide character, and 
  19994. stores the converted character in the location pointed to by pwc, if pwc is not 
  19995. a null pointer. A maximum of n bytes are examined. 
  19996.  
  19997. With mbrtowc, you can switch from one multibyte string to another. On systems 
  19998. that support shift states, ps represents the initial shift state of the string 
  19999. (0).  If you read in only part of the string, mbrtowc sets ps to the string's 
  20000. shift state at the point you stopped.  You can then call mbrtowc again for that 
  20001. string and pass in the updated ps value to continue reading where you left off. 
  20002.  
  20003. Note:  Because OS/2 does not have shift states, the ps parameter is provided 
  20004. only for compatibility with other ANSI/ISO platforms.  VisualAge C++ ignores 
  20005. the value passed for ps. 
  20006.  
  20007. The behavior of mbrtowc is affected by the LC_CTYPE category of the current 
  20008. locale. 
  20009.  
  20010. Return Value 
  20011. If string is a null pointer, mbrtowc returns 0. 
  20012.  
  20013. If string is not a null pointer, mbrtowc returns the first of the following 
  20014. that applies: 
  20015.  
  20016.  0    If the next n or fewer bytes complete the valid multibyte character that 
  20017.       corresponds to the null wide character. 
  20018.  
  20019.  positive If the next n or fewer bytes complete the valid multibyte character; 
  20020.       the value returned is the number of bytes that complete the multibyte 
  20021.       character. 
  20022.  
  20023.  -2   If the next n bytes form an incomplete (but potentially valid) multibyte 
  20024.       character, and all n bytes have been processed. 
  20025.  
  20026.  -1   If an encoding error occurs (when the next n or fewer bytes do not form a 
  20027.       complete and valid multibyte character).  mbrtowc sets errno to EILSEQ. 
  20028.  
  20029.  
  20030. ΓòÉΓòÉΓòÉ <hidden> Example of mbrtowc ΓòÉΓòÉΓòÉ
  20031.  
  20032. /************************************************************************
  20033.  
  20034. This example uses mbrlen to move to the second character in a string, then 
  20035. calls mbrtowc to convert the multibyte character to a wide character. 
  20036.  
  20037. ************************************************************************/
  20038.  
  20039. #include <wchar.h>
  20040. #include <stdio.h>
  20041. #include <stdlib.h>
  20042. #include <locale.h>
  20043.  
  20044. int main(void)
  20045. {
  20046.    char       mbs1[] = "abc";
  20047.    char       mbs2[] = "\x81\x41\x81\x42" "m";
  20048.    mbstate_t  ss1 = 0;
  20049.    mbstate_t  ss2 = 0;
  20050.    size_t     length1, length2;
  20051.    wchar_t    wc1, wc2;
  20052.  
  20053.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  20054.       printf("setlocale failed.\n");
  20055.       exit(EXIT_FAILURE);
  20056.    }
  20057.    length1 = mbrlen(mbs1, MB_CUR_MAX, &ss1);
  20058.    length2 = mbrlen(mbs2, MB_CUR_MAX, &ss2);
  20059.    mbrtowc(&wc1, mbs1 + length1, MB_CUR_MAX, &ss1);
  20060.    mbrtowc(&wc2, mbs2 + length2, MB_CUR_MAX, &ss2);
  20061.    printf("The second wide character in mbs1 is: <%lc>\n", wc1);
  20062.    printf("The second wide character in mbs2 is: <%lc>\n", wc2);
  20063.    return 0;
  20064.  
  20065.    /****************************************************************************
  20066.       The output should be similiar to :
  20067.  
  20068.       The second wide character in mbs1 is: <b>
  20069.       The second wide character in mbs2 is: <ΓöÇB>
  20070.    ****************************************************************************/
  20071. }
  20072.  
  20073.  
  20074. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20075.  
  20076. Example of mbrtowc 
  20077.  
  20078.      mblen - Determine Length of Multibyte Character 
  20079.      mbrlen - Calculate Length of Multibyte Character 
  20080.      mbsrtowcs - Convert Multibyte String to Wide-Character String 
  20081.      setlocale - Set Locale 
  20082.      wcrtomb - Convert Wide Character to Multibyte Character 
  20083.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  20084.      <locale.h> 
  20085.      <wchar.h> 
  20086.  
  20087.  
  20088. ΓòÉΓòÉΓòÉ 4.195. mbsinit -  Test Object for Initial State ΓòÉΓòÉΓòÉ
  20089.  
  20090.  
  20091. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20092.  
  20093. #include <wchar.h>
  20094. int mbsinit(mbstate_t *state);
  20095.  
  20096.  
  20097. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20098.  
  20099. Language Level:  Extension 
  20100.  
  20101. mbsinit determines whether the state describes an initial conversion state. 
  20102.  
  20103. Note:  mbsinit is provided only for compatibility with EBCDIC systems that 
  20104. support conversion or shift states. OS/2 does not use shift states for 
  20105. multibyte character encoding. 
  20106.  
  20107. Return Value 
  20108. If state is a null pointer or points to 0, mbsinit returns a nonzero value. If 
  20109. state points to any other value, mbsinit returns 0. On systems that support 
  20110. shift states, mbsinit returns nonzero if state describes an initial conversion 
  20111. state, or 0 otherwise. 
  20112.  
  20113.  
  20114. ΓòÉΓòÉΓòÉ <hidden> Example of mbsinit ΓòÉΓòÉΓòÉ
  20115.  
  20116. /************************************************************************
  20117.  
  20118. This example checks the conversion state to see if it is in the initial state. 
  20119.  
  20120. ************************************************************************/
  20121.  
  20122. #include <wchar.h>
  20123. #include <stdio.h>
  20124. #include <stdlib.h>
  20125.  
  20126. int main(void)
  20127. {
  20128.    char      *string = "ABC";
  20129.    mbstate_t state = 0;
  20130.    wchar_t   wc;
  20131.  
  20132.    mbrtowc(&wc, string, MB_CUR_MAX, &state);
  20133.    if (0 != mbsinit(&state))
  20134.       printf("In initial conversion state.\n");
  20135.    return 0;
  20136.  
  20137.    /****************************************************************************
  20138.       The output should be similar to :
  20139.  
  20140.       In initial conversion state.
  20141.    ****************************************************************************/
  20142. }
  20143.  
  20144.  
  20145. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20146.  
  20147. Example of mbsinit 
  20148.  
  20149.      mbrlen - Calculate Length of Multibyte Character 
  20150.      mbrtowc - Convert Multibyte Character to Wide Character 
  20151.      mbsrtowcs - Convert Multibyte String to Wide-Character String 
  20152.      setlocale - Set Locale 
  20153.      wcrtomb - Convert Wide Character to Multibyte Character 
  20154.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  20155.      <locale.h> 
  20156.      <wchar.h> 
  20157.  
  20158.  
  20159. ΓòÉΓòÉΓòÉ 4.196. mbsrtowcs - Convert Multibyte String to Wide-Character String ΓòÉΓòÉΓòÉ
  20160.  
  20161.  
  20162. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20163.  
  20164. #include <wchar.h>
  20165. size_t mbsrtowcs (wchar_t *dest, const char **src,
  20166.                   size_t len, mbstate_t *ps);
  20167.  
  20168.  
  20169. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20170.  
  20171. Language Level:  ANSI 93 
  20172.  
  20173. mbsrtowcs is a restartable version of mbstowcs, and performs the same function. 
  20174. It converts the sequence of multibyte characters from the array indirectly 
  20175. pointed to by src into a sequence of corresponding wide characters, and then 
  20176. stores the converted characters in the array pointed to by dest. 
  20177.  
  20178. Conversion continues up to and including the terminating wchar_t null 
  20179. character. The terminating null wide character is also stored. Conversion stops 
  20180. earlier if a sequence of bytes does not form a valid multibyte character, or 
  20181. when len codes have been stored into the array pointed to by dest. Each 
  20182. conversion takes place as if by a call to the mbrtowc function. 
  20183.  
  20184. mbsrtowcs assigns the object pointed to by src either a null pointer (if 
  20185. conversion stopped because a terminating null character was reached) or the 
  20186. address just past the last multibyte character converted. 
  20187.  
  20188. With mbsrtowcs, you can switch from one multibyte string to another. On 
  20189. platforms that support shift states, ps represents the initial shift state of 
  20190. the string (0).  If you read in only part of the string, mbsrtowcs sets ps to 
  20191. the string's shift state at the point you stopped.  You can then call mbsrtowcs 
  20192. again for that string and pass in the updated ps value to continue reading 
  20193. where you left off. 
  20194.  
  20195. Note:  Because OS/2 does not have shift states, the ps parameter is provided 
  20196. only for compatibility with other ANSI/ISO platforms.  VisualAge C++ ignores 
  20197. the value passed for ps. 
  20198.  
  20199. The behavior of mbsrtowcs is affected by the LC_CTYPE category of the current 
  20200. locale. 
  20201.  
  20202. Return Value 
  20203. mbsrtowcs returns the number of multibyte characters successfully converted, 
  20204. not including the terminating null character. If dest is a null pointer, the 
  20205. value of len is ignored and mbsrtowcs returns the number of elements required 
  20206. for the converted wide characters. 
  20207.  
  20208. If the input string contains an invalid multibyte character, mbsrtowcs sets 
  20209. errno to EILSEQ and returns (size_t)-1. 
  20210.  
  20211.  
  20212. ΓòÉΓòÉΓòÉ <hidden> Example of mbsrtowcs ΓòÉΓòÉΓòÉ
  20213.  
  20214. /************************************************************************
  20215.  
  20216. This example uses mbsrtowcs to convert the multibyte characters in the arrays 
  20217. mbs1 and mbs2, and store them in the arrays wcs1 and wcs2. 
  20218.  
  20219. ************************************************************************/
  20220.  
  20221. #include <wchar.h>
  20222. #include <stdio.h>
  20223. #include <stdlib.h>
  20224. #include <locale.h>
  20225.  
  20226. #define SIZE 10
  20227.  
  20228. int main(void)
  20229. {
  20230.    char        mbs1[] = "abc";
  20231.    char        mbs2[] = "\x81\x41" "m" "\x81\x42";
  20232.    const char  *pmbs1 = mbs1;
  20233.    const char  *pmbs2 = mbs2;
  20234.    mbstate_t   ss1 = 0;
  20235.    mbstate_t   ss2 = 0;
  20236.    wchar_t     wcs1[SIZE], wcs2[SIZE];
  20237.  
  20238.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  20239.       printf("setlocale failed.\n");
  20240.       exit(EXIT_FAILURE);
  20241.    }
  20242.    mbsrtowcs(wcs1, &pmbs1, SIZE, &ss1);
  20243.    mbsrtowcs(wcs2, &pmbs2, SIZE, &ss2);
  20244.    printf("The first wide character string is %ls.\n", wcs1);
  20245.    printf("The second wide character string is %ls.\n", wcs2);
  20246.    return 0;
  20247.  
  20248.    /****************************************************************************
  20249.       The output should be similiar to :
  20250.  
  20251.       The first wide character string is abc.
  20252.       The second wide character string is ΓöÇAmΓöÇB.
  20253.    ****************************************************************************/
  20254. }
  20255.  
  20256.  
  20257. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20258.  
  20259. Example of mbsrtowcs 
  20260.  
  20261.      mblen - Determine Length of Multibyte Character 
  20262.      mbrlen - Calculate Length of Multibyte Character 
  20263.      mbrtowc - Convert Multibyte Character to Wide Character 
  20264.      mbstowcs - Convert Multibyte String to Wide-Character String 
  20265.      setlocale - Set Locale 
  20266.      wcrtomb - Convert Wide Character to Multibyte Character 
  20267.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  20268.      <locale.h> 
  20269.      <wchar.h> 
  20270.  
  20271.  
  20272. ΓòÉΓòÉΓòÉ 4.197. mbstowcs - Convert Multibyte String to Wide-Character String ΓòÉΓòÉΓòÉ
  20273.  
  20274.  
  20275. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20276.  
  20277. #include <stdlib.h>
  20278. size_t mbstowcs(wchar_t *dest, const char *string, size_t len);
  20279.  
  20280.  
  20281. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20282.  
  20283. Language Level: ANSI, SAA, XPG4 
  20284.  
  20285. mbstowcs converts the multibyte character string pointed to by string into the 
  20286. wide-character array pointed to by dest. Depending on the encoding scheme used 
  20287. by the code set, the multibyte character string can contain any combination of 
  20288. single-byte or double-byte characters. 
  20289.  
  20290. The conversion stops after len bytes in dest are filled or after a wchar_t null 
  20291. character is encountered. The terminating null character is converted to a wide 
  20292. character with the value 0; characters that follow it are not processed. 
  20293.  
  20294. The behavior of mbstowcs is affected by the LC_CTYPE category of the current 
  20295. locale. 
  20296.  
  20297. Return Value 
  20298. If successful, mbstowcs returns the number of characters converted and stored 
  20299. in dest, not counting the terminating null character. The string pointed to by 
  20300. dest ends with a null character unless mbstowcs returns the value len. 
  20301.  
  20302. If it encounters an invalid multibyte character, mbstowcs returns (size_t)-1. 
  20303. If dest is a null pointer, the value of len is ignored and mbstowcs returns the 
  20304. number of elements required for the converted wide characters. 
  20305.  
  20306.  
  20307. ΓòÉΓòÉΓòÉ <hidden> Example of mbstowcs ΓòÉΓòÉΓòÉ
  20308.  
  20309. /************************************************************************
  20310.  
  20311. This example uses mbstowcs to convert the multibyte character mbs to a a wide 
  20312. character string and store it in wcs. 
  20313.  
  20314. ************************************************************************/
  20315.  
  20316. #include <wchar.h>
  20317. #include <stdio.h>
  20318. #include <stdlib.h>
  20319. #include <locale.h>
  20320.  
  20321. #define SIZE 10
  20322.  
  20323. int main(void)
  20324. {
  20325.    char        mbs[] = "\x81\x41" "m" "\x81\x42";
  20326.    wchar_t     wcs[SIZE];
  20327.  
  20328.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  20329.       printf("setlocale failed.\n");
  20330.       exit(EXIT_FAILURE);
  20331.    }
  20332.    mbstowcs(wcs, mbs, SIZE);
  20333.    printf("The wide character string is %ls.\n", wcs);
  20334.    return 0;
  20335.  
  20336.    /****************************************************************************
  20337.       The output should be similiar to :
  20338.  
  20339.       The wide character string is ΓöÇAmΓöÇB.
  20340.    ****************************************************************************/
  20341. }
  20342.  
  20343.  
  20344. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20345.  
  20346. Example of mbstowcs 
  20347.  
  20348.      mblen - Determine Length of Multibyte Character 
  20349.      mbsrtowcs - Convert Multibyte String to Wide-Character String 
  20350.      mbtowc - Convert Multibyte Character to Wide Character 
  20351.      setlocale - Set Locale 
  20352.      wcslen - Calculate Length of Wide-Character String 
  20353.      wcstombs - Convert Wide-Character String to Multibyte String 
  20354.      <locale.h> 
  20355.      <stdlib.h> 
  20356.  
  20357.  
  20358. ΓòÉΓòÉΓòÉ 4.198. mbtowc - Convert Multibyte Character to Wide Character ΓòÉΓòÉΓòÉ
  20359.  
  20360.  
  20361. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20362.  
  20363. #include <stdlib.h>
  20364. int mbtowc(wchar_t *pwc, const char *string, size_t n);
  20365.  
  20366.  
  20367. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20368.  
  20369. Language Level:  ANSI, SAA, XPG4 
  20370.  
  20371. mbtowc first determines the length of the multibyte character pointed to by 
  20372. string. It then converts the multibyte character to the corresponding wide 
  20373. character, and stores it in the location pointed to by pwc, if pwc is not a 
  20374. null pointer. mbtowc examines a maximum of n bytes from string. 
  20375.  
  20376. If pwc is a null pointer, the multibyte character is not converted. 
  20377.  
  20378. The behavior of mbtowc is affected by the LC_CTYPE category of the current 
  20379. locale. 
  20380.  
  20381. Return Value 
  20382. If string is NULL, mbtowc returns 0. 
  20383.  
  20384. Note:  On platforms that support shift states, mbtowc can also return a nonzero 
  20385. value to indicate that the multibyte encoding is state dependent. Because 
  20386. VisualAge C++ does not support state-dependent encoding, mbtowc always returns 
  20387. 0 when string is NULL. 
  20388.  
  20389. If string is not NULL, mbtowc returns: 
  20390.  
  20391.      The number of bytes comprising the converted multibyte character, if n or 
  20392.       fewer bytes form a valid multibyte character. 
  20393.      0 if string points to the null character. 
  20394.      -1 if string does not point to a valid multibyte character, and the next 
  20395.       n bytes do not form a valid multibyte character. 
  20396.  
  20397.  
  20398. ΓòÉΓòÉΓòÉ <hidden> Example of mbtowc ΓòÉΓòÉΓòÉ
  20399.  
  20400. /************************************************************************
  20401.  
  20402. This example uses mbtowc to convert the second multibyte character in mbs to a 
  20403. wide character. 
  20404.  
  20405. ************************************************************************/
  20406.  
  20407. #include <stdio.h>
  20408. #include <stdlib.h>
  20409. #include <wchar.h>
  20410. #include <locale.h>
  20411.  
  20412. int main(void)
  20413. {
  20414.    char     mb_string[] = "\x81\x41\x81\x42" "c" "\x00";
  20415.    int      length;
  20416.    wchar_t  widechar;
  20417.  
  20418.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  20419.       printf("setlocale failed.\n");
  20420.       exit(EXIT_FAILURE);
  20421.    }
  20422.    length = mblen(mb_string, MB_CUR_MAX);
  20423.    length = mbtowc(&widechar, mb_string + length, MB_CUR_MAX);
  20424.    printf("The wide character %lc has length of %d.\n", widechar, length);
  20425.    return 0;
  20426.  
  20427.    /****************************************************************************
  20428.       The output should be similar to :
  20429.  
  20430.       The wide character ΓöÇB has length of 2.
  20431.    ****************************************************************************/
  20432. }
  20433.  
  20434.  
  20435. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20436.  
  20437. Example of mbtowc 
  20438.  
  20439.      mblen - Determine Length of Multibyte Character 
  20440.      mbrtowc - Convert Multibyte Character to Wide Character 
  20441.      mbstowcs - Convert Multibyte String to Wide-Character String 
  20442.      setlocale - Set Locale 
  20443.      wcslen - Calculate Length of Wide-Character String 
  20444.      wctomb -  Convert Wide Character to Multibyte Character 
  20445.      <locale.h> 
  20446.      <stdlib.h> 
  20447.  
  20448.  
  20449. ΓòÉΓòÉΓòÉ 4.199. memccpy - Copy Bytes ΓòÉΓòÉΓòÉ
  20450.  
  20451.  
  20452. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20453.  
  20454. #include <string.h>     /* also in <memory.h> */
  20455. void *memccpy(void *dest, void *src, int c, unsigned cnt);
  20456.  
  20457.  
  20458. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20459.  
  20460. Language Level:  Extension 
  20461.  
  20462. memccpy copies bytes from src to dest, up to and including the first occurrence 
  20463. of the character c or until cnt bytes have been copied, whichever comes first. 
  20464.  
  20465. Return Value 
  20466. If the character c is copied, memccpy returns a pointer to the byte in dest 
  20467. that immediately follows the character. If c is not copied, memccpy returns 
  20468. NULL. 
  20469.  
  20470.  
  20471. ΓòÉΓòÉΓòÉ <hidden> Example of memccpy ΓòÉΓòÉΓòÉ
  20472.  
  20473. /************************************************************************
  20474.  
  20475. This example copies up to 55 characters, or until it copies the '.' character, 
  20476. from the source to the buffer. 
  20477.  
  20478. ************************************************************************/
  20479.  
  20480. #include <stdio.h>
  20481. #include <stdlib.h>
  20482. #include <string.h>
  20483.  
  20484. char source[60];
  20485. char result[60];
  20486.  
  20487. int main(void)
  20488. {
  20489.    memcpy(source, "This is the string. This part won't be copied.", 55);
  20490.    if (NULL == memccpy(result, source, '.', 55)) {
  20491.       printf("Error in copying source.\n");
  20492.       exit(EXIT_FAILURE);
  20493.    }
  20494.    else
  20495.       printf("%s\n", result);
  20496.    return 0;
  20497.  
  20498.    /****************************************************************************
  20499.       The output should be:
  20500.  
  20501.       This is the string.
  20502.    ****************************************************************************/
  20503. }
  20504.  
  20505.  
  20506. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20507.  
  20508. Example of memccpy 
  20509.  
  20510.      memchr - Search Buffer 
  20511.      memcmp - Compare Buffers 
  20512.      memcpy - Copy Bytes 
  20513.      memmove - Copy Bytes 
  20514.      memset - Set Bytes to Value 
  20515.      <memory.h> 
  20516.      <string.h> 
  20517.  
  20518.  
  20519. ΓòÉΓòÉΓòÉ 4.200. memchr - Search Buffer ΓòÉΓòÉΓòÉ
  20520.  
  20521.  
  20522. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20523.  
  20524. #include <string.h>  /* also in <memory.h> */
  20525. void *memchr(const void *buf, int c, size_t count);
  20526.  
  20527.  
  20528. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20529.  
  20530. Language Level: ANSI, SAA, XPG4, Extension 
  20531.  
  20532. memchr searches the first count bytes of buf for the first occurrence of c 
  20533. converted to an unsigned character. The search continues until it finds c or 
  20534. examines count bytes. 
  20535.  
  20536. Return Value 
  20537. memchr returns a pointer to the location of c in buf. It returns NULL if c is 
  20538. not within the first count bytes of buf. 
  20539.  
  20540.  
  20541. ΓòÉΓòÉΓòÉ <hidden> Example of memchr ΓòÉΓòÉΓòÉ
  20542.  
  20543. /************************************************************************
  20544.  
  20545. This example finds the first occurrence of "x" in the string that you provide. 
  20546. If it is found, the string that starts with that character is printed. 
  20547.  
  20548. ************************************************************************/
  20549.  
  20550. #include <stdio.h>
  20551. #include <string.h>
  20552.  
  20553. int main(int argc,char **argv)
  20554. {
  20555.    char *result;
  20556.  
  20557.    if (argc != 2)
  20558.       printf("Usage: %s string\n", argv[0]);
  20559.    else {
  20560.       if ((result = memchr(argv[1], 'x', strlen(argv[1]))) != NULL)
  20561.          printf("The string starting with x is %s\n", result);
  20562.       else
  20563.          printf("The letter x cannot be found in the string\n");
  20564.    }
  20565.    return 0;
  20566.  
  20567.    /****************************************************************************
  20568.       If the program is passed the argumrnt boxing, the output should be:
  20569.  
  20570.       The string starting with x is xing
  20571.    ****************************************************************************/
  20572. }
  20573.  
  20574.  
  20575. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20576.  
  20577. Example of memchr 
  20578.  
  20579.      memccpy - Copy Bytes 
  20580.      memcmp - Compare Buffers 
  20581.      memcpy - Copy Bytes 
  20582.      memicmp - Compare Bytes 
  20583.      memmove - Copy Bytes 
  20584.      memset - Set Bytes to Value 
  20585.      strchr - Search for Character 
  20586.      <memory.h> 
  20587.      <string.h> 
  20588.  
  20589.  
  20590. ΓòÉΓòÉΓòÉ 4.201. memcmp - Compare Buffers ΓòÉΓòÉΓòÉ
  20591.  
  20592.  
  20593. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20594.  
  20595. #include <string.h>  /* also in <memory.h> */
  20596. int memcmp(const void *buf1, const void *buf2, size_t count);
  20597.  
  20598.  
  20599. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20600.  
  20601. Language Level: ANSI, SAA, XPG4, Extension 
  20602.  
  20603. memcmp compares the first count bytes of buf1 and buf2. 
  20604.  
  20605. Return Value 
  20606. memcmp returns a value indicating the relationship between the two buffers as 
  20607. follows: 
  20608.  
  20609.  Value               Meaning 
  20610.  Less than 0         buf1 less than buf2 
  20611.  0                   buf1 identical to buf2 
  20612.  Greater than 0      buf1 greater than buf2 
  20613.  
  20614.  
  20615. ΓòÉΓòÉΓòÉ <hidden> Example of memcmp ΓòÉΓòÉΓòÉ
  20616.  
  20617. /************************************************************************
  20618.  
  20619. This example compares first and second arguments passed to main to determine 
  20620. which, if either, is greater. 
  20621.  
  20622. ************************************************************************/
  20623.  
  20624. #include <stdio.h>
  20625. #include <string.h>
  20626.  
  20627. int main(int argc,char **argv)
  20628. {
  20629.    int len;
  20630.    int result;
  20631.  
  20632.    if (argc != 3) {
  20633.       printf("Usage: %s string1 string2\n", argv[0]);
  20634.    }
  20635.    else {
  20636.  
  20637.       /* Determine the length to be used for comparison                       */
  20638.  
  20639.       if (strlen(argv[1]) < strlen(argv[2]))
  20640.          len = strlen(argv[1]);
  20641.       else
  20642.          len = strlen(argv[2]);
  20643.       result = memcmp(argv[1], argv[2], len);
  20644.       printf("When the first %i characters are compared,\n", len);
  20645.       if (0 == result)
  20646.          printf("\"%s\" is identical to \"%s\"\n", argv[1], argv[2]);
  20647.       else
  20648.          if (result < 0)
  20649.  
  20650.             printf("\"%s\" is less than \"%s\"\n", argv[1], argv[2]);
  20651.          else
  20652.             printf("\"%s\" is greater than \"%s\"\n", argv[1], argv[2]);
  20653.    }
  20654.    return 0;
  20655.  
  20656.    /****************************************************************************
  20657.       If the program is passed the arguments "firststring secondstring",
  20658.       the output should be:
  20659.  
  20660.       When the first 11 characters are compared,
  20661.       "firststring" is less than "secondstring"
  20662.    ****************************************************************************/
  20663. }
  20664.  
  20665.  
  20666. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20667.  
  20668. Example of memcmp 
  20669.  
  20670.      memccpy - Copy Bytes 
  20671.      memchr - Search Buffer 
  20672.      memcpy - Copy Bytes 
  20673.      memicmp - Compare Bytes 
  20674.      memmove - Copy Bytes 
  20675.      memset - Set Bytes to Value 
  20676.      strcmp - Compare Strings 
  20677.      <memory.h> 
  20678.      <string.h> 
  20679.  
  20680.  
  20681. ΓòÉΓòÉΓòÉ 4.202. memcpy - Copy Bytes ΓòÉΓòÉΓòÉ
  20682.  
  20683.  
  20684. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20685.  
  20686. #include <string.h>  /* also <memory.h> */
  20687. void *memcpy(void *dest, const void *src, size_t count);
  20688.  
  20689.  
  20690. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20691.  
  20692. Language Level: ANSI, SAA, XPG4, Extension 
  20693.  
  20694. memcpy copies count bytes of src to dest. The behavior is undefined if copying 
  20695. takes place between objects that overlap. (The memmove function allows copying 
  20696. between objects that may overlap.) 
  20697.  
  20698. Return Value 
  20699. memcpy returns a pointer to dest. 
  20700.  
  20701.  
  20702. ΓòÉΓòÉΓòÉ <hidden> Example of memcpy ΓòÉΓòÉΓòÉ
  20703.  
  20704. /************************************************************************
  20705.  
  20706. This example copies the contents of source to target. 
  20707.  
  20708. ************************************************************************/
  20709.  
  20710. #include <string.h>
  20711. #include <stdio.h>
  20712.  
  20713. #define  MAX_LEN       80
  20714. char source[MAX_LEN] = "This is the source string";
  20715. char target[MAX_LEN] = "This is the target string";
  20716.  
  20717. int main(void)
  20718. {
  20719.    printf("Before memcpy, target is \"%s\"\n", target);
  20720.    memcpy(target, source, sizeof(source));
  20721.    printf("After memcpy, target becomes \"%s\"\n", target);
  20722.    return 0;
  20723.  
  20724.    /****************************************************************************
  20725.       The output should be:
  20726.  
  20727.       Before memcpy, target is "This is the target string"
  20728.       After memcpy, target becomes "This is the source string"
  20729.    ****************************************************************************/
  20730. }
  20731.  
  20732.  
  20733. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20734.  
  20735. Example of memcpy 
  20736.  
  20737.      memccpy - Copy Bytes 
  20738.      memchr - Search Buffer 
  20739.      memcmp - Compare Buffers 
  20740.      memicmp - Compare Bytes 
  20741.      memmove - Copy Bytes 
  20742.      memset - Set Bytes to Value 
  20743.      strcpy - Copy Strings 
  20744.      <memory.h> 
  20745.      <string.h> 
  20746.  
  20747.  
  20748. ΓòÉΓòÉΓòÉ 4.203. memicmp - Compare Bytes ΓòÉΓòÉΓòÉ
  20749.  
  20750.  
  20751. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20752.  
  20753. #include <string.h>    /* also in <memory.h> */
  20754. int memicmp(void *buf1, void *buf2, unsigned int cnt);
  20755.  
  20756.  
  20757. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20758.  
  20759. Language Level:  Extension 
  20760.  
  20761. memicmp compares the first cnt bytes of buf1 and buf2 without regard to the 
  20762. case of letters in the two buffers.  The function converts all uppercase 
  20763. characters into lowercase and then performs the comparison. 
  20764.  
  20765. Return Value 
  20766. The return value of memicmp indicates the result as follows: 
  20767.  
  20768.  Value               Meaning 
  20769.  Less than 0         buf1 less than buf2 
  20770.  0                   buf1 identical to buf2 
  20771.  Greater than 0      buf1 greater than buf2. 
  20772.  
  20773.  
  20774. ΓòÉΓòÉΓòÉ <hidden> Example of memicmp ΓòÉΓòÉΓòÉ
  20775.  
  20776. /************************************************************************
  20777.  
  20778. This example copies two strings that each contain a substring of 29 characters 
  20779. that are the same except for case. The example then compares the first 29 bytes 
  20780. without regard to case. 
  20781.  
  20782. ************************************************************************/
  20783.  
  20784. #include <stdio.h>
  20785. #include <string.h>
  20786.  
  20787. char first[100],second[100];
  20788.  
  20789. int main(void)
  20790. {
  20791.    int result;
  20792.  
  20793.    strcpy(first, "Those Who Will Not Learn From History");
  20794.    strcpy(second, "THOSE WHO WILL NOT LEARN FROM their mistakes");
  20795.    printf("Comparing the first 29 characters of two strings.\n");
  20796.    result = memicmp(first, second, 29);
  20797.    printf("The first 29 characters of String 1 are ");
  20798.    if (result < 0)
  20799.       printf("less than String 2.\n");
  20800.    else
  20801.       if (0 == result)
  20802.          printf("equal to String 2.\n");
  20803.       else
  20804.          printf("greater than String 2.\n");
  20805.    return 0;
  20806.  
  20807.    /****************************************************************************
  20808.       The output should be:
  20809.  
  20810.       Comparing the first 29 characters of two strings.
  20811.       The first 29 characters of String 1 are equal to String 2
  20812.    ****************************************************************************/
  20813. }
  20814.  
  20815.  
  20816. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20817.  
  20818. Example of memicmp 
  20819.  
  20820.      memchr - Search Buffer 
  20821.      memcmp - Compare Buffers 
  20822.      memcpy - Copy Bytes 
  20823.      memmove - Copy Bytes 
  20824.      memset - Set Bytes to Value 
  20825.      strcmp - Compare Strings 
  20826.      <memory.h> 
  20827.      <string.h> 
  20828.  
  20829.  
  20830. ΓòÉΓòÉΓòÉ 4.204. memmove - Copy Bytes ΓòÉΓòÉΓòÉ
  20831.  
  20832.  
  20833. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20834.  
  20835. #include <string.h>  /* also in <memory.h> */
  20836. void *memmove(void *dest, const void *src, size_t count);
  20837.  
  20838.  
  20839. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20840.  
  20841. Language Level: ANSI, SAA, XPG4, Extension 
  20842.  
  20843. memmove copies count bytes of src to dest. memmove allows copying between 
  20844. objects that may overlap as if src is first copied into a temporary array. 
  20845.  
  20846. Return Value 
  20847. memmove returns a pointer to dest. 
  20848.  
  20849.  
  20850. ΓòÉΓòÉΓòÉ <hidden> Example of memmove ΓòÉΓòÉΓòÉ
  20851.  
  20852. /************************************************************************
  20853.  
  20854. This example copies the word shiny from position target + 2 to position target 
  20855. + 8. 
  20856.  
  20857. ************************************************************************/
  20858.  
  20859. #include <string.h>
  20860. #include <stdio.h>
  20861.  
  20862. #define  SIZE          21
  20863. char target[SIZE] = "a shiny white sphere";
  20864.  
  20865. int main(void)
  20866. {
  20867.    char *p = target+8;                    /* p points at the starting character
  20868.                                              of the word we want to replace   */
  20869.    char *source = target+2;                               /* start of "shiny" */
  20870.  
  20871.    printf("Before memmove, target is \"%s\"\n", target);
  20872.    memmove(p, source, 5);
  20873.    printf("After memmove, target becomes \"%s\"\n", target);
  20874.    return 0;
  20875.  
  20876.    /****************************************************************************
  20877.       The output should be:
  20878.  
  20879.       Before memmove, target is "a shiny white sphere"
  20880.       After memmove, target becomes "a shiny shiny sphere"
  20881.    ****************************************************************************/
  20882. }
  20883.  
  20884.  
  20885. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20886.  
  20887. Example of memmove 
  20888.  
  20889.      memccpy - Copy Bytes 
  20890.      memchr - Search Buffer 
  20891.      memcmp - Compare Buffers 
  20892.      memcpy - Copy Bytes 
  20893.      memicmp - Compare Bytes 
  20894.      memset - Set Bytes to Value 
  20895.      strcpy - Copy Strings 
  20896.      <memory.h> 
  20897.      <string.h> 
  20898.  
  20899.  
  20900. ΓòÉΓòÉΓòÉ 4.205. memset - Set Bytes to Value ΓòÉΓòÉΓòÉ
  20901.  
  20902.  
  20903. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20904.  
  20905. #include <string.h>  /* also in <memory.h> */
  20906. void *memset(void *dest, int c, size_t count);
  20907.  
  20908.  
  20909. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20910.  
  20911. Language Level: ANSI, SAA, XPG4, Extension 
  20912.  
  20913. memset sets the first count bytes of dest to the value c.  The value of c is 
  20914. converted to an unsigned character. 
  20915.  
  20916. Return Value 
  20917.  
  20918. memset returns a pointer to dest. 
  20919.  
  20920.  
  20921. ΓòÉΓòÉΓòÉ <hidden> Example of memset ΓòÉΓòÉΓòÉ
  20922.  
  20923. /************************************************************************
  20924.  
  20925. This example sets 10 bytes of the buffer to A and the next 10 bytes to B. 
  20926.  
  20927. ************************************************************************/
  20928.  
  20929. #include <string.h>
  20930. #include <stdio.h>
  20931.  
  20932. #define  BUF_SIZE      20
  20933.  
  20934. int main(void)
  20935. {
  20936.    char buffer[BUF_SIZE+1];
  20937.    char *string;
  20938.  
  20939.    memset(buffer, 0, sizeof(buffer));
  20940.    string = memset(buffer, 'A', 10);
  20941.    printf("\nBuffer contents: %s\n", string);
  20942.    memset(buffer+10, 'B', 10);
  20943.    printf("\nBuffer contents: %s\n", buffer);
  20944.    return 0;
  20945.  
  20946.    /****************************************************************************
  20947.       The output should be:
  20948.  
  20949.       Buffer contents: AAAAAAAAAA
  20950.       Buffer contents: AAAAAAAAAABBBBBBBBBB
  20951.    ****************************************************************************/
  20952. }
  20953.  
  20954.  
  20955. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  20956.  
  20957. Example of memset 
  20958.  
  20959.      memccpy - Copy Bytes 
  20960.      memchr - Search Buffer 
  20961.      memcmp - Compare Buffers 
  20962.      memcpy - Copy Bytes 
  20963.      memicmp - Compare Bytes 
  20964.      memmove - Copy Bytes 
  20965.      strnset - strset - Set Characters in String 
  20966.      <memory.h> 
  20967.      <string.h> 
  20968.  
  20969.  
  20970. ΓòÉΓòÉΓòÉ 4.206. _mheap - Query Memory Heap for Allocated Object ΓòÉΓòÉΓòÉ
  20971.  
  20972.  
  20973. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  20974.  
  20975. #include <umalloc.h>
  20976. Heap_t _mheap(void *ptr);
  20977.  
  20978.  
  20979. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  20980.  
  20981. Language Level:  Extension 
  20982.  
  20983. _mheap determines from which heap the object specified by ptr was allocated. 
  20984. The ptr must be a valid pointer that was returned from a runtime allocation 
  20985. function (_ucalloc, malloc, realloc, and so on).  If the pointer is not valid, 
  20986. the results of _mheap are undefined. 
  20987.  
  20988. For more information about creating and using heaps, see the chapter on 
  20989. Managing Memory in the Programming Guide. 
  20990.  
  20991. Return Value: 
  20992. _mheap returns the handle of the heap from which the object was allocated.  If 
  20993. the object was allocated from the runtime heap, _mheap returns _RUNTIME_HEAP. 
  20994. If the object passed to _mheap is NULL, _mheap returns NULL. If the object is 
  20995. not valid, _mheap either returns NULL (depending on how closely the storage 
  20996. pointed to resembles a valid object), or an exception occurs. 
  20997.  
  20998.  
  20999. ΓòÉΓòÉΓòÉ <hidden> Example of _mheap ΓòÉΓòÉΓòÉ
  21000.  
  21001. /************************************************************************
  21002.  
  21003. This example allocates a block of memory from the heap, then uses _mheap to 
  21004. determine which heap the block came from. 
  21005.  
  21006. *********************************************************************** /
  21007.  
  21008. #include <stdlib.h>
  21009. #include <stdio.h>
  21010. #include <umalloc.h>
  21011.  
  21012. int main(void)
  21013. {
  21014.    char  *ptr;
  21015.  
  21016.    if (NULL == (ptr = malloc(10))) {
  21017.       puts("Could not allocate memory block.");
  21018.       exit(EXIT_FAILURE);
  21019.    }
  21020.    printf("Handle of heap used is 0x%x\n", _mheap(ptr));
  21021.    return 0;
  21022.  
  21023.    /****************************************************************************
  21024.       The output should be similar to :
  21025.  
  21026.       Handle of heap used is 0x70000
  21027.    ****************************************************************************/
  21028. }
  21029.  
  21030.  
  21031. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21032.  
  21033. Example of _mheap 
  21034.  
  21035.      "Managing Memory" in the Programming Guide 
  21036.      _msize - Return Number of Bytes Allocated 
  21037.      _ucreate - Create a Memory Heap 
  21038.      _ustats - Get Information about Heap 
  21039.      <umalloc.h> 
  21040.  
  21041.  
  21042. ΓòÉΓòÉΓòÉ 4.207. min - Return Lesser of Two Values ΓòÉΓòÉΓòÉ
  21043.  
  21044.  
  21045. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21046.  
  21047. #include <stdlib.h>
  21048. type min(type a, type b);
  21049.  
  21050.  
  21051. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21052.  
  21053. Language Level:  Extension 
  21054.  
  21055. min compares two values and determines the smaller of the two. The data type 
  21056. can be any arithmetic data type, signed or unsigned.  The type must be the same 
  21057. for both arguments to min. 
  21058.  
  21059. Note:  Because min is a macro, if the evaluation of the arguments contains side 
  21060. effects (post-increment operators, for example), the results of both the side 
  21061. effects and the macro will be undefined. 
  21062.  
  21063. Return Value 
  21064. min returns the smaller of the two values. 
  21065.  
  21066.  
  21067. ΓòÉΓòÉΓòÉ <hidden> Example of min ΓòÉΓòÉΓòÉ
  21068.  
  21069. /************************************************************************
  21070.  
  21071. This example prints the smaller of the two values, a and b. 
  21072.  
  21073. ************************************************************************/
  21074.  
  21075. #include <stdlib.h>
  21076. #include <stdio.h>
  21077.  
  21078. int main(void)
  21079. {
  21080.    int a = 10;
  21081.    int b = 21;
  21082.  
  21083.    printf("The smaller of %d and %d is %d\n", a, b, min(a, b));
  21084.    return 0;
  21085.  
  21086.    /****************************************************************************
  21087.       The output should be:
  21088.  
  21089.       The smaller of 10 and 21 is 10
  21090.    ****************************************************************************/
  21091. }
  21092.  
  21093.  
  21094. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21095.  
  21096. Example of min 
  21097.  
  21098.      max - Return Larger of Two Values 
  21099.      <stdlib.h> 
  21100.  
  21101.  
  21102. ΓòÉΓòÉΓòÉ 4.208. mkdir - Create New Directory ΓòÉΓòÉΓòÉ
  21103.  
  21104.  
  21105. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21106.  
  21107. #include <direct.h>
  21108. int mkdir(char *pathname);
  21109.  
  21110.  
  21111. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21112.  
  21113. Language Level:  XPG4, Extension 
  21114.  
  21115. mkdir creates a new directory with the specified pathname.  Because only one 
  21116. directory can be created at a time, only the last component of pathname can 
  21117. name a new directory. 
  21118.  
  21119. Note:  In earlier releases of C Set ++, mkdir began with an underscore 
  21120. (_mkdir). Because it is defined by the X/Open standard, the underscore has been 
  21121. removed. For compatibility, VisualAge C++ will map _mkdir to mkdir for you. 
  21122.  
  21123. Return Value 
  21124. mkdir returns the value 0 if the directory was created.  A return value of -1 
  21125. indicates an error, and errno is set to one of the following values: 
  21126.  
  21127.  Value          Meaning 
  21128.  EACCESS        The directory was not created;  the given name is the name of 
  21129.                 an existing file, directory, or device. 
  21130.  ENOENT         The pathname was not found. 
  21131.  
  21132.  
  21133. ΓòÉΓòÉΓòÉ <hidden> Example of mkdir ΓòÉΓòÉΓòÉ
  21134.  
  21135. /************************************************************************
  21136.  
  21137. This example creates two new directories:  one at the root on drive C:, and one 
  21138. in the tmp subdirectory of the current working directory. 
  21139.  
  21140. ************************************************************************/
  21141.  
  21142. #include <stdio.h>
  21143. #include <direct.h>
  21144. #include <string.h>
  21145.  
  21146. int main(void)
  21147. {
  21148.    char *dir1,*dir2;
  21149.  
  21150.  /*  Create the directory "aleng" in the root directory of the C: drive.      */
  21151.  
  21152.    dir1 = "c:\\aleng";
  21153.    if (0 == (mkdir(dir1)))
  21154.       printf("%s directory was created.\n", dir1);
  21155.    else
  21156.       printf("%s directory was not created.\n", dir1);
  21157.  
  21158.  /*  Create the subdirectory "simon" in the current directory.                */
  21159.  
  21160.    dir2 = "simon";
  21161.    if (0 == (mkdir(dir2)))
  21162.       printf("%s directory was created.\n", dir2);
  21163.    else
  21164.       printf("%s directory was not created.\n", dir2);
  21165.  
  21166.  /*  Remove the directory "aleng" from the root directory of the C: drive.    */
  21167.  
  21168.    printf("Removing directory 'aleng' from the root directory.\n");
  21169.    if (rmdir(dir1))
  21170.       perror(NULL);
  21171.    else
  21172.       printf("%s directory was removed.\n", dir1);
  21173.  
  21174.  /*  Remove the subdirectory "simon" from the current directory.              */
  21175.  
  21176.    printf("Removing subdirectory 'simon' from the current directory.\n");
  21177.    if (rmdir(dir2))
  21178.       perror(NULL);
  21179.    else
  21180.       printf("%s directory was removed.\n", dir2);
  21181.    return 0;
  21182.  
  21183.    /****************************************************************************
  21184.       The output should be:
  21185.  
  21186.       c:\aleng directory was created.
  21187.       simon directory was created.
  21188.       Removing directory 'aleng' from the root directory.
  21189.       c:\aleng directory was removed.
  21190.       Removing subdirectory 'simon' from the current directory.
  21191.       simon directory was removed.
  21192.    ****************************************************************************/
  21193. }
  21194.  
  21195.  
  21196. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21197.  
  21198. Example of mkdir 
  21199.  
  21200.      chdir - Change Current Working Directory 
  21201.      _getcwd - Get Path Name of Current Directory 
  21202.      _getdcwd - Get Full Path Name of Current Directory 
  21203.      rmdir - Remove Directory 
  21204.      <direct.h> 
  21205.  
  21206.  
  21207. ΓòÉΓòÉΓòÉ 4.209. mktime - Convert Local Time ΓòÉΓòÉΓòÉ
  21208.  
  21209.  
  21210. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21211.  
  21212. #include <time.h>
  21213. time_t mktime(struct tm *time);
  21214.  
  21215.  
  21216. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21217.  
  21218. Language Level: ANSI, SAA, POSIX, XPG4 
  21219.  
  21220. mktime converts local time, stored as a tm structure pointed to by time, into a 
  21221. time_t structure suitable for use with other time functions. The values of some 
  21222. structure elements pointed to by time are not restricted to the ranges shown 
  21223. for gmtime. 
  21224.  
  21225. The values of tm_wday and tm_yday passed to mktime are ignored and are assigned 
  21226. their correct values on return. 
  21227.  
  21228. Note:  The time and date functions begin at 00:00:00 Coordinated Universal 
  21229. Time, January 1, 1970. 
  21230.  
  21231. Return Value 
  21232. mktime returns the calendar time having type time_t.  The value (time_t)(-1) is 
  21233. returned if the calendar time cannot be represented. 
  21234.  
  21235.  
  21236. ΓòÉΓòÉΓòÉ <hidden> Example of mktime ΓòÉΓòÉΓòÉ
  21237.  
  21238. /************************************************************************
  21239.  
  21240. This example prints the day of the week that is 40 days and 16 hours from the 
  21241. current date. 
  21242.  
  21243. ************************************************************************/
  21244.  
  21245. #include <stdio.h>
  21246. #include <time.h>
  21247.  
  21248. char *wday[] =  { "Sunday", "Monday", "Tuesday", "Wednesday",
  21249.                   "Thursday", "Friday", "Saturday" } ;
  21250.  
  21251. int main(void)
  21252. {
  21253.    time_t t1,t3;
  21254.    struct tm *t2;
  21255.  
  21256.    t1 = time(NULL);
  21257.    t2 = localtime(&t1);
  21258.    t2->tm_mday += 40;
  21259.    t2->tm_hour += 16;
  21260.    t3 = mktime(t2);
  21261.    printf("40 days and 16 hours from now, it will be a %9s \n", wday[t2->tm_wday
  21262.       ]);
  21263.    return 0;
  21264.  
  21265.    /****************************************************************************
  21266.       The output should be similar to:
  21267.  
  21268.       40 days and 16 hours from now, it will be a Sunday
  21269.    ****************************************************************************/
  21270. }
  21271.  
  21272.  
  21273. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21274.  
  21275. Example of mktime 
  21276.  
  21277.      asctime - Convert Time to Character String 
  21278.      ctime - Convert Time to Character String 
  21279.      gmtime - Convert Time 
  21280.      localtime - Convert Time 
  21281.      time - Determine Current Time 
  21282.      <time.h> 
  21283.  
  21284.  
  21285. ΓòÉΓòÉΓòÉ 4.210. modf - Separate Floating-Point Value ΓòÉΓòÉΓòÉ
  21286.  
  21287.  
  21288. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21289.  
  21290. #include <math.h>
  21291. double modf(double x, double *intptr);
  21292.  
  21293.  
  21294. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21295.  
  21296. Language Level: ANSI, SAA, POSIX, XPG4 
  21297.  
  21298. modf breaks down the floating-point value x into fractional and integral parts. 
  21299. The signed fractional portion of x is returned.  The integer portion is stored 
  21300. as a double value pointed to by intptr.  Both the fractional and integral parts 
  21301. are given the same sign as x. 
  21302.  
  21303. Return Value 
  21304. modf returns the signed fractional portion of x. 
  21305.  
  21306.  
  21307. ΓòÉΓòÉΓòÉ <hidden> Example of modf ΓòÉΓòÉΓòÉ
  21308.  
  21309. /************************************************************************
  21310.  
  21311. This example breaks the floating-point number -14.876 into its fractional and 
  21312. integral components. 
  21313.  
  21314. ************************************************************************/
  21315.  
  21316. #include <math.h>
  21317.  
  21318. int main(void)
  21319. {
  21320.    double x,y,d;
  21321.  
  21322.    x = -14.876;
  21323.    y = modf(x, &d);
  21324.    printf("x = %lf\n", x);
  21325.    printf("Integral part = %lf\n", d);
  21326.    printf("Fractional part = %lf\n", y);
  21327.    return 0;
  21328.  
  21329.    /****************************************************************************
  21330.       The output should be:
  21331.  
  21332.       x = -14.876000
  21333.       Integral part = -14.000000
  21334.       Fractional part = -0.876000
  21335.    ****************************************************************************/
  21336. }
  21337.  
  21338.  
  21339. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21340.  
  21341. Example of modf 
  21342.  
  21343.      fmod - Calculate Floating-Point Remainder 
  21344.      frexp - Separate Floating-Point Value 
  21345.      ldexp - Multiply by a Power of Two 
  21346.      <math.h> 
  21347.  
  21348.  
  21349. ΓòÉΓòÉΓòÉ 4.211. _msize - Return Number of Bytes Allocated ΓòÉΓòÉΓòÉ
  21350.  
  21351.  
  21352. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21353.  
  21354. #include <stdlib.h>  /* also in <malloc.h> */
  21355. size_t _msize(void *ptr)
  21356.  
  21357.  
  21358. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21359.  
  21360. Language Level:  Extension 
  21361.  
  21362. _msize determines the number of bytes that were allocated to the pointer 
  21363. argument ptr. The ptr must have been returned from one of the runtime memory 
  21364. allocation functions (_ucalloc, malloc, _trealloc, and so on). 
  21365.  
  21366. You cannot pass the argument of an object that has been freed. 
  21367.  
  21368. Return Value 
  21369. _msize returns the number of bytes allocated. If the argument is not a valid 
  21370. pointer returned from a memory allocation function, the return value is 
  21371. undefined. If NULL is passed, _msize returns 0. 
  21372.  
  21373.  
  21374. ΓòÉΓòÉΓòÉ <hidden> Example of _msize ΓòÉΓòÉΓòÉ
  21375.  
  21376. /************************************************************************
  21377.  
  21378. This example displays the size of an allocated object from malloc. 
  21379.  
  21380. ************************************************************************/
  21381.  
  21382. #include <stdlib.h>
  21383. #include <stdio.h>
  21384.  
  21385. int main(void)
  21386. {
  21387.    char *ptr;
  21388.  
  21389.    if (NULL == (ptr = malloc(10))) {
  21390.       puts("Could not allocate memory block.");
  21391.       exit(EXIT_FAILURE);
  21392.    }
  21393.    memset(ptr, 'x', 5);
  21394.    printf("The size of the allocated object is %u.\n",_msize(ptr));
  21395.    return 0;
  21396.  
  21397.    /****************************************************************************
  21398.       The output should be similar to :
  21399.  
  21400.       The size of the allocated object is 10.
  21401.    ****************************************************************************/
  21402. }
  21403.  
  21404.  
  21405. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21406.  
  21407. Example of _msize 
  21408.  
  21409.      calloc - Reserve and Initialize Storage 
  21410.      malloc - Reserve Storage Block 
  21411.      realloc - Change Reserved Storage Block Size 
  21412.      _tcalloc - Reserve Tiled Storage Block 
  21413.      _tmalloc - Reserve Tiled Storage Block 
  21414.      _trealloc - Reallocate Tiled Storage Block 
  21415.      <malloc.h> 
  21416.      <stdlib.h> 
  21417.  
  21418.  
  21419. ΓòÉΓòÉΓòÉ 4.212. nl_langinfo - Retrieve Locale Information ΓòÉΓòÉΓòÉ
  21420.  
  21421.  
  21422. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21423.  
  21424. #include <nl_types.h>
  21425. #include <langinfo.h>
  21426. char *nl_langinfo(nl_item item);
  21427.  
  21428.  
  21429. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21430.  
  21431. Language Level:  XPG4 
  21432.  
  21433. nl_langinfo retrieves from the current locale the string that describes the 
  21434. requested information specified by item. 
  21435.  
  21436. The constant names and values for item are defined in <langinfo.h>. For a list 
  21437. of macros that define the constants used to identify the information queried in 
  21438. the current locale, see the table of defined macros under langinfo.h. 
  21439.  
  21440. You cannot retrieve the following information for the current locale: 
  21441.  
  21442.    t_fmt_ampm
  21443.    era
  21444.    era_year
  21445.    era_d_fmt
  21446.    alt_digits
  21447.    t_fmt_ampm
  21448.    alt_digits
  21449.  
  21450. Return Value 
  21451. nl_langinfo returns a pointer to a null-terminated string containing 
  21452. information about the active language or cultural area. The active language or 
  21453. cultural area is determined by the most recent setlocale call. Subsequent calls 
  21454. to the function may modify the array that the return value points to. Your own 
  21455. code cannot modify the array. 
  21456.  
  21457. If item is not valid, nl_langinfo returns a pointer to an empty string. 
  21458.  
  21459.  
  21460. ΓòÉΓòÉΓòÉ <hidden> Example of nl_langinfo ΓòÉΓòÉΓòÉ
  21461.  
  21462. /************************************************************************
  21463.  
  21464. This example uses nl_langinfo to retrieve the current codeset name. 
  21465.  
  21466. ************************************************************************/
  21467.  
  21468. #include <nl_types.h>
  21469. #include <langinfo.h>
  21470. #include <stdio.h>
  21471.  
  21472. int main(void)
  21473. {
  21474.    printf("Current codeset is %s\n", nl_langinfo(CODESET));
  21475.    return 0;
  21476.  
  21477.    /****************************************************************************
  21478.       The output should be similar to :
  21479.  
  21480.       Current codeset is IBM-850
  21481.    ****************************************************************************/
  21482. }
  21483.  
  21484.  
  21485. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21486.  
  21487. Example of nl_langinfo 
  21488.  
  21489.      localdtconv - Return Date and Time Formatting Convention 
  21490.      localeconv - Retrieve Information from the Environment 
  21491.      setlocale - Set Locale 
  21492.      <langinfo.h> 
  21493.      <nl_types.h> 
  21494.  
  21495.  
  21496. ΓòÉΓòÉΓòÉ 4.213. _onexit - Record Termination Function ΓòÉΓòÉΓòÉ
  21497.  
  21498.  
  21499. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21500.  
  21501. #include <stdlib.h>
  21502. onexit_t _onexit(onexit_t func);
  21503.  
  21504.  
  21505. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21506.  
  21507. Language Level:  Extension 
  21508.  
  21509. _onexit records the address of a function func to call when the program ends 
  21510. normally.  Successive calls to _onexit create a stack of functions that run in 
  21511. a last-in, first-out order. The functions passed to _onexit cannot take 
  21512. parameters. 
  21513.  
  21514. You can record up to 32 termination functions with calls to _onexit and atexit. 
  21515. If you exceed 32 functions, _onexit returns the value NULL. 
  21516.  
  21517. Note:  For portability, use the ANSI/ISO standard atexit function, which is 
  21518. equivalent to _onexit. 
  21519.  
  21520. Return Value 
  21521. If successful, _onexit returns a pointer to the function; otherwise, it returns 
  21522. a NULL value. 
  21523.  
  21524.  
  21525. ΓòÉΓòÉΓòÉ <hidden> Example of _onexit ΓòÉΓòÉΓòÉ
  21526.  
  21527. /************************************************************************
  21528.  
  21529. This example specifies and defines four distinct functions that run 
  21530. consecutively at the completion of main. 
  21531.  
  21532. ************************************************************************/
  21533.  
  21534. #include <stdio.h>
  21535. #include <stdlib.h>
  21536.  
  21537. int fn1(void)
  21538. {
  21539.    printf("next.\n");
  21540. }
  21541.  
  21542. int fn2(void)
  21543. {
  21544.    printf("run ");
  21545. }
  21546.  
  21547. int fn3(void)
  21548. {
  21549.    printf("is ");
  21550. }
  21551.  
  21552. int fn4(void)
  21553. {
  21554.    printf("This ");
  21555. }
  21556.  
  21557. int main(void)
  21558. {
  21559.    _onexit(fn1);
  21560.    _onexit(fn2);
  21561.    _onexit(fn3);
  21562.    _onexit(fn4);
  21563.    printf("This is run first.\n");
  21564.    return 0;
  21565.  
  21566.    /****************************************************************************
  21567.       The output should be:
  21568.  
  21569.       This is run first.
  21570.       This is run next.
  21571.    ****************************************************************************/
  21572. }
  21573.  
  21574.  
  21575. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21576.  
  21577. Example of _onexit 
  21578.  
  21579.      abort - Stop a Program 
  21580.      atexit - Record Program Termination Function 
  21581.      exit - End Program 
  21582.      _exit - End Process 
  21583.      <stdlib.h> 
  21584.  
  21585.  
  21586. ΓòÉΓòÉΓòÉ 4.214. open - Open File ΓòÉΓòÉΓòÉ
  21587.  
  21588.  
  21589. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21590.  
  21591. #include <io.h>
  21592. #include <fcntl.h>
  21593. #include <sys\stat.h>
  21594. int open(char *pathname, int oflag, int pmode);
  21595.  
  21596.  
  21597. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21598.  
  21599. Language Level:  XPG4, Extension 
  21600.  
  21601. open opens the file specified by pathname and prepares the file for subsequent 
  21602. reading or writing as defined by oflag. open can also prepare the file for 
  21603. reading and writing. 
  21604.  
  21605. The oflag is an integer expression formed by combining one or more of the 
  21606. following constants, defined in <fcntl.h>. To specify more than one constant, 
  21607. join the constants with the bitwise OR operator (|); for example, O_CREAT | 
  21608. O_TEXT. 
  21609.  
  21610.  Oflag         Meaning 
  21611.  O_APPEND      Reposition the file pointer to the end of the file before every 
  21612.                write operation. 
  21613.  O_CREAT       Create and open a new file.  This flag has no effect if the file 
  21614.                specified by pathname exists. 
  21615.  O_EXCL        Return an error value if the file specified by pathname exists. 
  21616.                This flag applies only when used with O_CREAT. 
  21617.  O_RDONLY      Open the file for reading only.  If this flag is given, neither 
  21618.                O_RDWR nor O_WRONLY can be given. 
  21619.  O_RDWR        Open the file for reading and writing.  If this flag is given, 
  21620.                neither O_RDONLY nor O_WRONLY can be given. 
  21621.  O_TRUNC       Open and truncate an existing file to 0 length. The file must 
  21622.                have write permission. The contents of the file are destroyed, 
  21623.                and O_TRUNC cannot be specified with O_RDONLY. 
  21624.  O_WRONLY      Open the file for writing only.  If this flag is given, neither 
  21625.                O_RDONLY nor O_RDWR can be given. 
  21626.  O_BINARY      Open the file in binary (untranslated) mode. 
  21627.  O_TEXT        Open the file in text (translated) mode. 
  21628.  
  21629.  If neither O_BINARY or O_TEXT is specified, the default will be O_TEXT; it is 
  21630.  an error to specify both O_BINARY and O_TEXT. You must specify one of the 
  21631.  access mode flags, O_RDONLY, O_WRONLY, or O_RDWR.  There is no default. 
  21632.  
  21633.  Warning: Use O_TRUNC with care; it destroys the complete contents of an 
  21634.  existing file. 
  21635.  
  21636.  For more details on text and binary modes and their differences, see "Stream 
  21637.  Processing" in the Programming Guide. 
  21638.  
  21639.  The pmode argument is an integer expression containing one or both of the 
  21640.  constants S_IWRITE and S_IREAD, defined in <sys\stat.h>. The pmode is required 
  21641.  only when O_CREAT is specified. If the file exists, pmode is ignored. 
  21642.  Otherwise, pmode specifies the permission settings for the file. These are set 
  21643.  when the new file is closed for the first time. The meaning of the pmode 
  21644.  argument is as follows: 
  21645.  
  21646.  Value                   Meaning 
  21647.  S_IWRITE                Writing permitted 
  21648.  S_IREAD                 Reading permitted 
  21649.  S_IREAD | S_IWRITE      Reading and writing permitted. 
  21650.  
  21651.  If write permission is not given, the file is read-only. Under the OS/2 
  21652.  operating system, all files are readable; you cannot give write-only 
  21653.  permission. The modes S_IWRITE and S_IREAD | S_IWRITE are equivalent. 
  21654.  
  21655.  open applies the current file permission mask to pmode before setting the 
  21656.  permissions. (See umask - Sets File Mask of Current Process.) 
  21657.  
  21658.  Note:  In earlier releases of C Set ++, open began with an underscore (_open). 
  21659.  Because it is defined by the X/Open standard, the underscore has been removed. 
  21660.  For compatibility, VisualAge C++ will map _open to open for you. 
  21661.  
  21662.  Return Value 
  21663.  open returns a file handle for the opened file. A return value of -1 indicates 
  21664.  an error, and errno is set to one of the following values: 
  21665.  
  21666.  Value          Meaning 
  21667.  EACCESS        The given pathname is a directory; or the file is read-only but 
  21668.                 an open for writing was attempted; or a sharing violation 
  21669.                 occurred. 
  21670.  EEXIST         The O_CREAT and O_EXCL flags are specified, but the named file 
  21671.                 already exists. 
  21672.  EMFILE         No more file handles are available. 
  21673.  EINVAL         An incorrect argument was passed. 
  21674.  ENOENT         The file or pathname were not found. 
  21675.  EOS2ERR        The call to the operating system was not successful. 
  21676.  
  21677.  
  21678. ΓòÉΓòÉΓòÉ <hidden> Example of open ΓòÉΓòÉΓòÉ
  21679.  
  21680. /************************************************************************
  21681.  
  21682. This example opens the file edopen.dat by creating it as a new file, truncating 
  21683. it if it exists, and opening it so it can be read and written to. The open 
  21684. command issued also grants permission to read from and write to the file. 
  21685.  
  21686. ************************************************************************/
  21687.  
  21688. #include <io.h>
  21689. #include <stdio.h>
  21690. #include <fcntl.h>
  21691. #include <sys\stat.h>
  21692. #include <stdlib.h>
  21693.  
  21694. int main(void)
  21695. {
  21696.    int fh;
  21697.  
  21698.    if (-1 == (fh = open("edopen.dat", O_CREAT|O_TRUNC|O_RDWR,
  21699.                          S_IREAD|S_IWRITE))) {
  21700.       perror("Unable to open edopen.dat");
  21701.       return EXIT_FAILURE;
  21702.    }
  21703.    printf("File was successfully opened.\n");
  21704.    if (-1 == close(fh)) {
  21705.       perror("close error");
  21706.       return EXIT_FAILURE;
  21707.    }
  21708.    return 0;
  21709.  
  21710.    /****************************************************************************
  21711.       The output should be:
  21712.  
  21713.       File was successfully opened.
  21714.    ****************************************************************************/
  21715. }
  21716.  
  21717.  
  21718. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21719.  
  21720. Example of open 
  21721.  
  21722.      close - Close File Associated with Handle 
  21723.      creat - Create New File 
  21724.      fdopen - Associates Input Or Output With File 
  21725.      fopen - Open Files 
  21726.      _sopen - Open Shared File 
  21727.      umask - Sets File Mask of Current Process 
  21728.      <fcntl.h> 
  21729.      <io.h> 
  21730.      <sys\stat.h> 
  21731.  
  21732.  
  21733. ΓòÉΓòÉΓòÉ 4.215. _outp - Write Byte to Output Port ΓòÉΓòÉΓòÉ
  21734.  
  21735.  
  21736. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21737.  
  21738. #include <conio.h>  /* also in <builtin.h> */
  21739. int _outp( const unsigned int port, const int value );
  21740.  
  21741.  
  21742. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21743.  
  21744. Language Level:  Extension 
  21745.  
  21746. _outp writes a byte value to the specified port. The port number must be an 
  21747. unsigned integer value within the range 0 to 65 535 inclusive. The byte value 
  21748. must be within the range 0 to 255 inclusive. 
  21749.  
  21750. Note:  _outp is a built-in function, which means it is implemented as an inline 
  21751. instruction and has no backing code in the library.  For this reason: 
  21752.  
  21753.      You cannot take the address of _outp. 
  21754.      You cannot parenthesize a call to _outp. (Parentheses specify a call to 
  21755.       the function's backing code, and _outp has none.) 
  21756.  
  21757.  You can run code containing this function only at ring zero. Otherwise, an 
  21758.  invalid instruction exception is generated. 
  21759.  
  21760.  Return Value 
  21761.  _outp returns the integer value that was output to the specified port. There 
  21762.  is no error return value, and _outp does not set errno. 
  21763.  
  21764.  
  21765. ΓòÉΓòÉΓòÉ <hidden> Example of _outp ΓòÉΓòÉΓòÉ
  21766.  
  21767. /************************************************************************
  21768.  
  21769. This example uses _outp to write a byte to a specified output port and return 
  21770. the data written. 
  21771.  
  21772. ************************************************************************/
  21773.  
  21774. #include <builtin.h>
  21775.  
  21776. #define LOWER  0
  21777. #define UPPER1 255
  21778. #define UPPER2 65535
  21779.  
  21780. int Add1(int j);
  21781.  
  21782. static int g;
  21783. enum fruit {apples=10, bananas, cantaloupes};
  21784. enum fruit f = cantaloupes;
  21785. int arr[] = {cantaloupes, bananas, apples};
  21786. struct
  21787. {
  21788.    int  i;
  21789.    char ch;
  21790. } st;
  21791.  
  21792. int main(void)
  21793. {
  21794.    static int i;
  21795.    volatile const int c = 0;
  21796.  
  21797.    st.i = c - bananas;
  21798.    g = _outp(LOWER,apples);
  21799.    i = _outp(255, 0);
  21800.                                      /* ============================= */
  21801.                                      /* Types of port number passed : */
  21802.                                      /* ----------------------------- */
  21803.    i = _outp(UPPER2,UPPER1);         /* - #define constant            */
  21804.    i = _outp(st.i, bananas);         /* - element of structure        */
  21805.    i = _outp(f,arr[1]);              /* - enumerated variable         */
  21806.    i = _outp(_inp(arr[2]),apples);   /* - return value from a         */
  21807.                                      /*   builtin function call       */
  21808.                                      /* ----------------------------- */
  21809.    i = _outp(_outp(apples,Add1(LOWER)),6);
  21810.    return 0;
  21811. }
  21812.  
  21813. int Add1(int j)
  21814. {
  21815.    j += 1;
  21816.    return j;
  21817. }
  21818.  
  21819.  
  21820. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21821.  
  21822. Example of _outp 
  21823.  
  21824.      _inp - Read Byte from Input Port 
  21825.      _inpw - Read Unsigned Short from Input Port 
  21826.      _inpd - Read Doubleword from Input Port 
  21827.      _outpw - Write Word to Output Port 
  21828.      _outpd - Write Double Word to Output Port 
  21829.      <builtin.h> 
  21830.      <conio.h> 
  21831.  
  21832.  
  21833. ΓòÉΓòÉΓòÉ 4.216. _outpd - Write Double Word to Output Port ΓòÉΓòÉΓòÉ
  21834.  
  21835.  
  21836. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21837.  
  21838. #include <conio.h>  /* also in <builtin.h */
  21839. unsigned long _outpd( const unsigned int port, const unsigned long value );
  21840.  
  21841.  
  21842. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21843.  
  21844. Language Level:  Extension 
  21845.  
  21846. _outpd writes an unsigned long value to the specified port. The port number 
  21847. must be a value within the range 0 to 65 535 inclusive. The unsigned long value 
  21848. must be within the range 0 to 4 294 967 295 inclusive. 
  21849.  
  21850. Note:  _outpd is a built-in function, which means it is implemented as an 
  21851. inline instruction and has no backing code in the library.  For this reason: 
  21852.  
  21853.      You cannot take the address of _outpd. 
  21854.      You cannot parenthesize a call to _outpd. (Parentheses specify a call to 
  21855.       the function's backing code, and _outpd has none.) 
  21856.  
  21857.  You can run code containing this function only at ring zero. Otherwise, an 
  21858.  invalid instruction exception is generated. 
  21859.  
  21860.  Return Value 
  21861.  _outpd returns the unsigned long value that was output to the specified port. 
  21862.  There is no error return value, and _outpd does not set errno. 
  21863.  
  21864.  
  21865. ΓòÉΓòÉΓòÉ <hidden> Example of _outpd ΓòÉΓòÉΓòÉ
  21866.  
  21867. /************************************************************************
  21868.  
  21869. This example uses _outpd to write a doubleword value to a specified output port 
  21870. and return the data written. 
  21871.  
  21872. ************************************************************************/
  21873.  
  21874. #include <builtin.h>
  21875.  
  21876. #define LOWER  0
  21877. #define UPPER1 65535
  21878. #define UPPER2 4294967295
  21879.  
  21880. int Add1(int j);
  21881.  
  21882. volatile long g;
  21883. enum fruit {apples=10, bananas, cantaloupes};
  21884. enum fruit f = cantaloupes;
  21885. int arr[] = {cantaloupes, bananas, apples};
  21886. union
  21887. {
  21888.    volatile int  i;
  21889.    volatile char ch;
  21890. } un;
  21891.  
  21892. int main(void)
  21893. {
  21894.    unsigned long l;
  21895.    volatile const short c = 0;
  21896.  
  21897.    un.i = bananas * f;
  21898.    g = _outpd(0,LOWER);
  21899.                                      /* ============================= */
  21900.                                      /* Types of port number passed : */
  21901.                                      /* ----------------------------- */
  21902.    l = _outpd(UPPER1, UPPER2);       /* - #define constant            */
  21903.    l = _outpd(un.i ,f);              /* - element of union            */
  21904.    l = _outpd(Add1(c), apples);      /* - return value from a         */
  21905.                                      /*   function call               */
  21906.                                      /* ----------------------------- */
  21907.    l = _outpd(_outpw(255,Add1(LOWER)),6);
  21908.    return 0;
  21909. }
  21910.  
  21911. int Add1(int j)
  21912. {
  21913.    j += 1;
  21914.    return j;
  21915. }
  21916.  
  21917.  
  21918. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  21919.  
  21920. Example of _outpd 
  21921.  
  21922.      _inp - Read Byte from Input Port 
  21923.      _inpw - Read Unsigned Short from Input Port 
  21924.      _inpd - Read Doubleword from Input Port 
  21925.      _outp - Write Byte to Output Port 
  21926.      _outpw - Write Word to Output Port 
  21927.      <builtin.h> 
  21928.      <conio.h> 
  21929.  
  21930.  
  21931. ΓòÉΓòÉΓòÉ 4.217. _outpw - Write Word to Output Port ΓòÉΓòÉΓòÉ
  21932.  
  21933.  
  21934. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  21935.  
  21936. #include <conio.h>  /* also in <builtin.h */
  21937. unsigned short _outpw( const unsigned int port, const unsigned short word );
  21938.  
  21939.  
  21940. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  21941.  
  21942. Language Level:  Extension 
  21943.  
  21944. _outpw writes an unsigned short word to the specified port. The port number 
  21945. must be an unsigned integer value within the range 0 to 65 535 inclusive. The 
  21946. unsigned short word must be in the range 0 to 65 535. 
  21947.  
  21948. Note:  _outpw is a built-in function, which means it is implemented as an 
  21949. inline instruction and has no backing code in the library.  For this reason: 
  21950.  
  21951.      You cannot take the address of _outpw. 
  21952.      You cannot parenthesize a call to _outpw. (Parentheses specify a call to 
  21953.       the function's backing code, and _outpw has none.) 
  21954.  
  21955.  You can run code containing this function only at ring zero. Otherwise, an 
  21956.  invalid instruction exception is generated. 
  21957.  
  21958.  Return Value 
  21959.  _outpw returns the value that was output to the specified port. There is no 
  21960.  error return value, and _outpw does not set errno. 
  21961.  
  21962.  
  21963. ΓòÉΓòÉΓòÉ <hidden> Example of _outpw ΓòÉΓòÉΓòÉ
  21964.  
  21965. /************************************************************************
  21966.  
  21967. This example uses _outpw to write an unsigned short value to a specified output 
  21968. port and return the data written. 
  21969.  
  21970. ************************************************************************/
  21971.  
  21972. #include <builtin.h>
  21973.  
  21974. #define LOWER 0
  21975. #define UPPER 65535
  21976.  
  21977. int Add1(int j);
  21978.  
  21979. unsigned int g;
  21980.  
  21981. int main(void)
  21982. {
  21983.    enum fruit {apples = 10, bananas, cantaloupes};
  21984.    enum fruit f = cantaloupes;
  21985.    int arr[] = {cantaloupes, bananas, apples};
  21986.    unsigned short s;
  21987.    static int i = 0;
  21988.    volatile const int c = 255;
  21989.  
  21990.    g = _outpw(cantaloupes, i);
  21991.                                      /* ============================= */
  21992.                                      /* Types of port number passed : */
  21993.                                      /* ----------------------------- */
  21994.    s = _outpw(UPPER, LOWER);         /* - #define constant            */
  21995.    s = _outpw(c, Add1(255));         /* - constant                    */
  21996.    s = _outpw(_inpw(arr[2]),apples); /* - return value from a         */
  21997.                                      /*   builtin function call       */
  21998.                                      /* ----------------------------- */
  21999.    s = _outpw(_outpw(bananas ,UPPER),6);
  22000.    return 0;
  22001. }
  22002.  
  22003. int Add1(int j)
  22004. {
  22005.    j += 1;
  22006.    return j;
  22007. }
  22008.  
  22009.  
  22010. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22011.  
  22012. Example of _outpw 
  22013.  
  22014.      _inp - Read Byte from Input Port 
  22015.      _inpw - Read Unsigned Short from Input Port 
  22016.      _inpd - Read Doubleword from Input Port 
  22017.      _outp - Write Byte to Output Port 
  22018.      _outpd - Write Double Word to Output Port 
  22019.      <builtin.h> 
  22020.      <conio.h> 
  22021.  
  22022.  
  22023. ΓòÉΓòÉΓòÉ 4.218. __parmdwords - Get Number of dwords in Parameter List ΓòÉΓòÉΓòÉ
  22024.  
  22025.  
  22026. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22027.  
  22028. #include <stdlib.h>  /* also in <builtin.h> */
  22029. unsigned char __parmdwords(void);
  22030.  
  22031.  
  22032. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22033.  
  22034. Language Level:  Extension 
  22035.  
  22036. The __parmdwords function returns the hidden parameter passed in the AL 
  22037. register for _System linkage calls. The hidden parameter contains the size of 
  22038. the parameter list that is passed to the function containing the call to 
  22039. __parmdwords.  The size is in doublewords (dwords), and can be between 0 and 
  22040. 255. If the parameter list is larger than 255 dwords, the hidden parameter 
  22041. contains the 8 least significant bits of the value. 
  22042.  
  22043. Note:  To use __parmdwords, you must compile with the /Gp+ option to include 
  22044. the support for it. 
  22045.  
  22046. This function allows the implementer of a function to increase the number of 
  22047. parameters the function takes without changing the name of the function. The 
  22048. new version of the function can call __parmdwords to check the size of the 
  22049. parameter list and determine whether the call was written for the earlier 
  22050. version of the function or for the extended version. 
  22051.  
  22052. Warning: The __parmdwords function has several limitations: 
  22053.  
  22054.    1. Because it is a built-in function and has no backing code in the library: 
  22055.           You cannot take the address of __parmdwords. 
  22056.           You cannot parenthesize a __parmdwords function call because 
  22057.            parentheses specify a call to the backing code for the function. 
  22058.    2. The __parmdwords function can only be used for functions with the _System 
  22059.       linkage type. If you use it with other linkage types, an error message is 
  22060.       generated, and your program will not compile correctly. 
  22061.    3. Not all vendors implement the hidden parameter in the AL register, so 
  22062.       __parmdwords may have incorrect results when you use it in a function 
  22063.       that is called from code compiled by other compilers. 
  22064.  
  22065.  The __parmdwords function returns the size of the parameter list passed to the 
  22066.  function in units of dwords. 
  22067.  
  22068.  This example shows two versions of an API that prints out messages.  The 
  22069.  second version uses __parmdwords to determine whether the call was intended 
  22070.  for the original or the updated version. 
  22071.  
  22072.   ************************************************************************/
  22073.  
  22074.   #include <stdlib.h>
  22075.   #include <stdio.h>
  22076.  
  22077.   #pragma  linkage(ErrorHandler, system)
  22078.  
  22079.   int ErrorHandler(int MessgageNum,int Severity); /* Extended version of API    */
  22080.  
  22081.   /* Old version API prototype --  int ErrorHandler(int MessageNum);            */
  22082.  
  22083.   #define  MESSAGE1      1
  22084.   #define  MESSAGE2      2
  22085.   #define  INFORMATIONAL 3
  22086.   #define  WARNING       2
  22087.   #define  ERROR         1
  22088.   #define  FATAL         0
  22089.  
  22090.   int ErrorHandler(int MessageNum,int Severity)
  22091.   {
  22092.      int rc = 0;
  22093.  
  22094.      switch ((int)__parmdwords()) {
  22095.         case 2 :             /* Extended version with Severity parameter        */
  22096.            switch (Severity) {
  22097.               case  FATAL :
  22098.                  printf("Fatal Error:");
  22099.                  break;
  22100.               case  ERROR :
  22101.                  printf("Error:");
  22102.                  break;
  22103.               case  WARNING :
  22104.                  printf("Warning:");
  22105.                  break;
  22106.               case  INFORMATIONAL :
  22107.                  printf("Informational:");
  22108.                  break;
  22109.               default  :
  22110.                  rc = EXIT_FAILURE;
  22111.                  printf("Bad Severity Number");
  22112.            }
  22113.  
  22114.          /* intentional fall through                                            */
  22115.  
  22116.         case 1 :        /* Old version of API without Severity parameter        */
  22117.            switch (MessageNum) {
  22118.               case  MESSAGE1 :
  22119.                  printf("Some immensely profound message\n");
  22120.                  break;
  22121.               case  MESSAGE2 :
  22122.                  printf("Some other immensely profound message\n");
  22123.                  break;
  22124.               default  :
  22125.                  printf
  22126.                     ("Very trivial message, why not try MESSAGE1 or MESSAGE2?\n");
  22127.                  rc = EXIT_FAILURE;
  22128.            }
  22129.      }
  22130.      return  rc;
  22131.   }
  22132.  
  22133.   int main(void)
  22134.   {
  22135.      return  ErrorHandler(MESSAGE1, FATAL);
  22136.  
  22137.      /****************************************************************************
  22138.         The output should be:
  22139.  
  22140.         Fatal Error:Some immensely profound message
  22141.      ****************************************************************************/
  22142.   }
  22143.  
  22144.  
  22145. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22146.  
  22147.      Calling Conventions in the Programming Guide 
  22148.      /Gp option in the User's Guide 
  22149.      <stdlib.h> 
  22150.  
  22151.  
  22152. ΓòÉΓòÉΓòÉ 4.219. perror - Print Error Message ΓòÉΓòÉΓòÉ
  22153.  
  22154.  
  22155. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22156.  
  22157. #include <stdio.h>
  22158. void perror(const char *string);
  22159.  
  22160.  
  22161. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22162.  
  22163. Language Level:  ANSI, SAA, POSIX, XPG4 
  22164.  
  22165. perror prints an error message to stderr.  If string is not NULL and does not 
  22166. point to a null character, the string pointed to by string is printed to the 
  22167. standard error stream, followed by a colon and a space.  The message associated 
  22168. with the value in errno is then printed followed by a new-line character. 
  22169.  
  22170. To produce accurate results, you should ensure that perror is called 
  22171. immediately after a library function returns with an error;  otherwise, 
  22172. subsequent calls may alter the errno value. 
  22173.  
  22174. Return Value 
  22175. There is no return value. 
  22176.  
  22177.  
  22178. ΓòÉΓòÉΓòÉ <hidden> Example of perror ΓòÉΓòÉΓòÉ
  22179.  
  22180. /************************************************************************
  22181.  
  22182. This example tries to open a stream.  If fopen fails, the example prints a 
  22183. message and ends the program. 
  22184.  
  22185. ************************************************************************/
  22186.  
  22187. #include <stdio.h>
  22188. #include <stdlib.h>
  22189. int main(void)
  22190. {
  22191.    FILE *fh;
  22192.  
  22193.    if (NULL == (fh = fopen("myfile.mjq", "r"))) {
  22194.       perror("Could not open data file");
  22195.       abort();
  22196.    }
  22197.    return 0;
  22198.  
  22199.    /****************************************************************************
  22200.       The output should be:
  22201.  
  22202.       Could not open data file: The file cannot be found.
  22203.    ****************************************************************************/
  22204. }
  22205.  
  22206.  
  22207. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22208.  
  22209. Example of perror 
  22210.  
  22211.      clearerr - Reset Error Indicators. 
  22212.      ferror - Test for Read/Write Errors 
  22213.      strerror - Set Pointer to Runtime Error Message 
  22214.      _strerror - Set Pointer to System Error String 
  22215.      Runtime Return Codes and Messages in the User's Guide 
  22216.      <stdio.h> 
  22217.  
  22218.  
  22219. ΓòÉΓòÉΓòÉ 4.220. pow - Compute Power ΓòÉΓòÉΓòÉ
  22220.  
  22221.  
  22222. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22223.  
  22224. #include <math.h>
  22225. double pow(double x, double y);
  22226.  
  22227.  
  22228. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22229.  
  22230. Language Level: ANSI, SAA, POSIX, XPG4 
  22231.  
  22232. pow calculates the value of x to the power of y. 
  22233.  
  22234. Return Value 
  22235. If y is 0, pow returns the value 1. If x is 0 and y is negative, pow sets errno 
  22236. to EDOM and returns 0. If both x and y are 0, or if x is negative and y is not 
  22237. an integer, pow sets errno to EDOM, and returns 0. 
  22238.  
  22239. If an overflow results, pow sets errno to ERANGE and returns +HUGE_VAL for a 
  22240. large result or -HUGE_VAL for a small result. 
  22241.  
  22242.  
  22243. ΓòÉΓòÉΓòÉ <hidden> Example of pow ΓòÉΓòÉΓòÉ
  22244.  
  22245. /************************************************************************
  22246.  
  22247. This example calculates the value of 2**3. 
  22248.  
  22249. ************************************************************************/
  22250.  
  22251. #include <stdio.h>
  22252. #include <math.h>
  22253.  
  22254. int main(void)
  22255. {
  22256.    double x,y,z;
  22257.  
  22258.    x = 2.0;
  22259.    y = 3.0;
  22260.    z = pow(x, y);
  22261.    printf("%lf to the power of %lf is %lf\n", x, y, z);
  22262.    return 0;
  22263.  
  22264.    /****************************************************************************
  22265.       The output should be:
  22266.  
  22267.       2.000000 to the power of 3.000000 is 8.000000
  22268.    ****************************************************************************/
  22269. }
  22270.  
  22271.  
  22272. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22273.  
  22274. Example of pow 
  22275.  
  22276.      exp - Calculate Exponential Function 
  22277.      _fsqrt -  Calculate Square Root 
  22278.      log - Calculate Natural Logarithm 
  22279.      log10 - Calculate Base 10 Logarithm 
  22280.      sqrt - Calculate Square Root 
  22281.      <math.h> 
  22282.  
  22283.  
  22284. ΓòÉΓòÉΓòÉ 4.221. printf - Print Formatted Characters ΓòÉΓòÉΓòÉ
  22285.  
  22286.  
  22287. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22288.  
  22289. #include <stdio.h>
  22290. int printf(const char *format-string, argument-list);
  22291.  
  22292.  
  22293. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22294.  
  22295. Language Level: ANSI, SAA, POSIX, XPG4, Extension 
  22296.  
  22297. printf formats and prints a series of characters and values to the standard 
  22298. output stream stdout.  The format-string consists of ordinary characters, 
  22299. escape sequences, and format specifications.  The ordinary characters are 
  22300. copied in order of their appearance to stdout.  Format specifications, 
  22301. beginning with a percent sign (%), determine the output format for any 
  22302. argument-list following the format-string. 
  22303.  
  22304. The format-string is read left to right.  When the first format specification 
  22305. is found, the value of the first argument after the format-string is converted 
  22306. and output according to the format specification.  The second format 
  22307. specification causes the second argument after the format-string to be 
  22308. converted and output, and so on through the end of the format-string.  If there 
  22309. are more arguments than there are format specifications, the extra arguments 
  22310. are evaluated and ignored.  The results are undefined if there are not enough 
  22311. arguments for all the format specifications. A format specification has the 
  22312. following form: 
  22313.  
  22314. >>ΓöÇΓöÇ%ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇtypeΓöÇΓöÇ><
  22315.     ΓööΓöÇflagsΓöÇΓöÿ  ΓööΓöÇwidthΓöÇΓöÿ  ΓööΓöÇ.ΓöÇΓöÇprecisionΓöÇΓöÿ  Γö£ΓöÇhΓöÇΓöñ
  22316.                         Γö£ΓöÇlΓöÇΓöñ
  22317.                         ΓööΓöÇLΓöÇΓöÿ
  22318. Each field of the format specification is a single character or number 
  22319. signifying a particular format option.  The type character, which appears after 
  22320. the last optional format field, determines whether the associated argument is 
  22321. interpreted as a character, a string, a number, or pointer.  The simplest 
  22322. format specification contains only the percent sign and a type character (for 
  22323. example, %s). 
  22324.  
  22325. The following optional fields control other aspects of the formatting: 
  22326.  
  22327.  Field       Description 
  22328.  
  22329.  flags       Justification of output and printing of signs, blanks, decimal 
  22330.              points, octal, and hexadecimal prefixes, and the semantics for 
  22331.              wchar_t precision unit. 
  22332.  
  22333.  width       Minimum number of characters (bytes) output. 
  22334.  
  22335.  precision   Maximum number of characters (bytes) printed for all or part of 
  22336.              the output field, or minimum number of digits printed for integer 
  22337.              values. 
  22338.  
  22339.  h,l,L       Size of argument expected. 
  22340.  
  22341.  If a percent sign (%) is followed by a character that has no meaning as a 
  22342.  format field, the character is simply copied to stdout.  For example, to print 
  22343.  a percent sign character, use %%. 
  22344.  
  22345.  In extended mode, printf also converts floating-point values of NaN and 
  22346.  infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  22347.  and sign of the string is determined by the format specifiers.  See Infinity 
  22348.  and NaN Support for more information on infinity and NaN values. 
  22349.  
  22350.  If you specify a null string for the %s or %ls format specifier, printf prints 
  22351.  (null). (In previous releases of C Set ++, printf produced no output for a 
  22352.  null string.) 
  22353.  
  22354.  Return Value 
  22355.  printf returns the number of bytes printed. 
  22356.  
  22357.  
  22358. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22359.  
  22360. Example of printf 
  22361.  
  22362.      Format Specification - Types 
  22363.      Format Specification - Flags 
  22364.      Format Specification - Width 
  22365.      Format Specification - Precision 
  22366.      Format Specification - h,l,L 
  22367.      fprintf - Write Formatted Data to a Stream 
  22368.      fscanf - Read Formatted Data 
  22369.      scanf - Read Data 
  22370.      sprintf - Print Formatted Data to Buffer 
  22371.      sscanf - Read Data 
  22372.      Infinity and NaN Support 
  22373.      <stdio.h> 
  22374.  
  22375.  
  22376. ΓòÉΓòÉΓòÉ 4.221.1. Format Specification - Types ΓòÉΓòÉΓòÉ
  22377.  
  22378. The type characters and their meanings are given in the following table: 
  22379.  
  22380. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  22381. Γöé CHAR-   Γöé ARGUMENT  Γöé OUTPUT FORMAT                     Γöé
  22382. Γöé ACTER   Γöé       Γöé                            Γöé
  22383. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22384. Γöé d, i   Γöé Integer   Γöé Signed decimal integer.                Γöé
  22385. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22386. Γöé u     Γöé Integer   Γöé Unsigned decimal integer.               Γöé
  22387. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22388. Γöé o     Γöé Integer   Γöé Unsigned octal integer.                Γöé
  22389. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22390. Γöé x     Γöé Integer   Γöé Unsigned hexadecimal integer, using abcdef.      Γöé
  22391. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22392. Γöé X     Γöé Integer   Γöé Unsigned hexadecimal integer, using ABCDEF.      Γöé
  22393. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22394. Γöé f     Γöé Double   Γöé Signed value having the form [-]dddd.dddd, where   Γöé
  22395. Γöé      Γöé       Γöé dddd is one or more decimal digits.  The number of  Γöé
  22396. Γöé      Γöé       Γöé digits before the decimal point depends on the mag-  Γöé
  22397. Γöé      Γöé       Γöé nitude of the number.  The number of digits after   Γöé
  22398. Γöé      Γöé       Γöé the decimal point is equal to the requested preci-  Γöé
  22399. Γöé      Γöé       Γöé sion.  NaN and infinity values are printed in lower- Γöé
  22400. Γöé      Γöé       Γöé case ("nan" and "infinity").             Γöé
  22401. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22402. Γöé F     Γöé Double   Γöé In extended mode ("/Se" option), identical to the   Γöé
  22403. Γöé      Γöé       Γöé "f" format except that NaN and infinity values are  Γöé
  22404. Γöé      Γöé       Γöé printed in uppercase ("NAN" and "INFINITY").  In   Γöé
  22405. Γöé      Γöé       Γöé modes other than extended, "F" is treated like any  Γöé
  22406. Γöé      Γöé       Γöé other character not included in this table.      Γöé
  22407. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22408. Γöé e     Γöé Double   Γöé Signed value having the form [-]d.dddd"e"[sign]ddd,  Γöé
  22409. Γöé      Γöé       Γöé where d is a single-decimal digit, dddd is one or   Γöé
  22410. Γöé      Γöé       Γöé more decimal digits, ddd is 2 or 3 decimal digits,  Γöé
  22411. Γöé      Γöé       Γöé and sign is + or -.                  Γöé
  22412. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22413. Γöé E     Γöé Double   Γöé Identical to the "e" format except that "E" intro-  Γöé
  22414. Γöé      Γöé       Γöé duces the exponent instead of "e".          Γöé
  22415. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22416. Γöé g     Γöé Double   Γöé Signed value printed in "f" or "e" format.  The "e"  Γöé
  22417. Γöé      Γöé       Γöé format is used only when the exponent of the value  Γöé
  22418. Γöé      Γöé       Γöé is less than -4 or greater than precision.  Trailing Γöé
  22419. Γöé      Γöé       Γöé zeros are truncated, and the decimal point appears  Γöé
  22420. Γöé      Γöé       Γöé only if one or more digits follow it.         Γöé
  22421. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22422. Γöé G     Γöé Double   Γöé Identical to the "g" format except that "E" intro-  Γöé
  22423. Γöé      Γöé       Γöé duces the exponent (where appropriate) instead of   Γöé
  22424. Γöé      Γöé       Γöé "e".                         Γöé
  22425. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22426. Γöé c     Γöé Character  Γöé Single character.                   Γöé
  22427. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22428. Γöé lc    Γöé Wide char- Γöé Multibyte character (converted as if by a call to   Γöé
  22429. Γöé      Γöé acter    Γöé wcrtomb).                       Γöé
  22430. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22431. Γöé s     Γöé String   Γöé Characters printed up to the first null character   Γöé
  22432. Γöé      Γöé       Γöé (\"0") or until precision is reached.  If you     Γöé
  22433. Γöé      Γöé       Γöé specify a null string, "(null)" is printed.      Γöé
  22434. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22435. Γöé ls    Γöé Wide-    Γöé Multibyte characters, printed up to the first     Γöé
  22436. Γöé      Γöé character  Γöé "wchar_t" null character ("L\0") is encountered in  Γöé
  22437. Γöé      Γöé string.   Γöé the wide-character string, or until the specified   Γöé
  22438. Γöé      Γöé       Γöé precision is reached.  Conversion takes place as if  Γöé
  22439. Γöé      Γöé       Γöé by a call to wcrtomb.  The displayed result does not Γöé
  22440. Γöé      Γöé       Γöé include the terminating null character.  If you do  Γöé
  22441. Γöé      Γöé       Γöé not specify the precision, you must end the wide-   Γöé
  22442. Γöé      Γöé       Γöé character string with a null character.  A partial  Γöé
  22443. Γöé      Γöé       Γöé multibyte character cannot be written.  If you    Γöé
  22444. Γöé      Γöé       Γöé specify a null string, "(null)" is printed.      Γöé
  22445. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22446. Γöé n     Γöé Pointer to Γöé Number of characters successfully written so far to  Γöé
  22447. Γöé      Γöé integer   Γöé the stream or buffer; this value is stored in the   Γöé
  22448. Γöé      Γöé       Γöé integer whose address is given as the argument.    Γöé
  22449. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22450. Γöé p     Γöé Pointer   Γöé Pointer to void converted to a sequence of printable Γöé
  22451. Γöé      Γöé       Γöé characters.                      Γöé
  22452. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  22453.  
  22454.  
  22455. ΓòÉΓòÉΓòÉ 4.221.2. Format Specification - Flags ΓòÉΓòÉΓòÉ
  22456.  
  22457. The flag characters and their meanings are as follows (notice that more than 
  22458. one flag can appear in a format specification): 
  22459.  
  22460. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  22461. Γöé Table 3. Flag Characters                           Γöé
  22462. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22463. Γöé FLAG    Γöé MEANING                  Γöé DEFAULT        Γöé
  22464. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22465. Γöé -     Γöé Left-justify the result within the field  Γöé Right-justify.    Γöé
  22466. Γöé      Γöé width.                   Γöé            Γöé
  22467. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22468. Γöé +     Γöé Prefix the output value with a sign (+ or Γöé Sign appears only   Γöé
  22469. Γöé      Γöé -) if the output value is of a signed   Γöé for negative signed  Γöé
  22470. Γöé      Γöé type.                   Γöé values (-).      Γöé
  22471. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22472. Γöé blank(' ')Γöé Prefix the output value with a blank if  Γöé No blank.       Γöé
  22473. Γöé      Γöé the output value is signed and positive.  Γöé            Γöé
  22474. Γöé      Γöé The "+" flag overrides the blank flag if  Γöé            Γöé
  22475. Γöé      Γöé both appear, and a positive signed value  Γöé            Γöé
  22476. Γöé      Γöé will be output with a sign.        Γöé            Γöé
  22477. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22478. Γöé #     Γöé When used with the "o", "x", or "X"    Γöé No prefix.      Γöé
  22479. Γöé      Γöé formats, the "#" flag prefixes any     Γöé            Γöé
  22480. Γöé      Γöé nonzero output value with "0", "0"x, or  Γöé            Γöé
  22481. Γöé      Γöé "0"X, respectively.            Γöé            Γöé
  22482. Γöé      Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22483. Γöé      Γöé When used with the "f", "F", "e", or "E"  Γöé Decimal point     Γöé
  22484. Γöé      Γöé formats, the "#" flag forces the output  Γöé appears only if    Γöé
  22485. Γöé      Γöé value to contain a decimal point in all  Γöé digits follow it.   Γöé
  22486. Γöé      Γöé cases.                   Γöé            Γöé
  22487. Γöé      Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22488. Γöé      Γöé When used with the "g" or "G" formats,   Γöé Decimal point     Γöé
  22489. Γöé      Γöé the "#" flag forces the output value to  Γöé appears only if    Γöé
  22490. Γöé      Γöé contain a decimal point in all cases and  Γöé digits follow it;   Γöé
  22491. Γöé      Γöé prevents the truncation of trailing    Γöé trailing zeros are  Γöé
  22492. Γöé      Γöé zeros.                   Γöé truncated.      Γöé
  22493. Γöé      Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22494. Γöé      Γöé When used with the "ls" format, the "#"  Γöé Precision indicates  Γöé
  22495. Γöé      Γöé flag causes precision to be measured in  Γöé the maximum number  Γöé
  22496. Γöé      Γöé "wchar_t" characters.           Γöé of bytes to be    Γöé
  22497. Γöé      Γöé                      Γöé output.        Γöé
  22498. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22499. Γöé "0"    Γöé When used with the "d", "i", "o", "u",   Γöé Space padding.    Γöé
  22500. Γöé      Γöé "x", "X", "e", "E", "f", "F"" g", or "G"  Γöé            Γöé
  22501. Γöé      Γöé formats, the "0" flag causes leading    Γöé            Γöé
  22502. Γöé      Γöé "0"'s to pad the output to the field    Γöé            Γöé
  22503. Γöé      Γöé width.  The "0" flag is ignored if preci- Γöé            Γöé
  22504. Γöé      Γöé sion is specified for an integer or if   Γöé            Γöé
  22505. Γöé      Γöé the "-" flag is specified.         Γöé            Γöé
  22506. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  22507.  
  22508. The # flag should not be used with c, lc, d, i, u, s, or p types. 
  22509.  
  22510.  
  22511. ΓòÉΓòÉΓòÉ 4.221.3. Format Specification - Width ΓòÉΓòÉΓòÉ
  22512.  
  22513. Width is a nonnegative decimal integer controlling the minimum number of 
  22514. characters printed.  If the number of characters in the output value is less 
  22515. than the specified width, blanks are added on the left or the right (depending 
  22516. on whether the - flag is specified) until the minimum width is reached. 
  22517.  
  22518. Width never causes a value to be truncated;  if the number of characters in the 
  22519. output value is greater than the specified width, or width is not given, all 
  22520. characters of the value are printed (subject to the precision specification). 
  22521.  
  22522. For the ls type, width is specified in bytes. If the number of bytes in the 
  22523. output value is less than the specified width, single-byte blanks are added on 
  22524. the left or the right (depending on whether the - flag is specified) until the 
  22525. minimum width is reached. 
  22526.  
  22527. The width specification can be an asterisk (*), in which case an argument from 
  22528. the argument list supplies the value.  The width argument must precede the 
  22529. value being formatted in the argument list. 
  22530.  
  22531.  
  22532. ΓòÉΓòÉΓòÉ 4.221.4. Format Specification - Precision ΓòÉΓòÉΓòÉ
  22533.  
  22534. Precision is a nonnegative decimal integer preceded by a period, which 
  22535. specifies the number of characters to be printed or the number of decimal 
  22536. places. Unlike the width specification, the precision can cause truncation of 
  22537. the output value or rounding of a floating-point value. 
  22538.  
  22539. The precision specification can be an asterisk (*), in which case an argument 
  22540. from the argument list supplies the value. The precision argument must precede 
  22541. the value being formatted in the argument list. 
  22542.  
  22543. The interpretation of the precision value and the default when the precision is 
  22544. omitted depend upon the type, as shown in the following table: 
  22545.  
  22546. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  22547. Γöé TYPE  Γöé MEANING                   Γöé DEFAULT         Γöé
  22548. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22549. Γöé   i  Γöé Precision specifies the minimum number of  Γöé If precision is "0" or Γöé
  22550. Γöé   d  Γöé digits to be printed.  If the number of   Γöé omitted entirely, or  Γöé
  22551. Γöé   u  Γöé digits in the argument is less than preci- Γöé if the period (.)    Γöé
  22552. Γöé   o  Γöé sion, the output value is padded on the   Γöé appears without a    Γöé
  22553. Γöé   x  Γöé left with zeros.  The value is not trun-  Γöé number following it,  Γöé
  22554. Γöé   X  Γöé cated when the number of digits exceeds   Γöé the precision is set  Γöé
  22555. Γöé     Γöé precision.                 Γöé to 1.          Γöé
  22556. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22557. Γöé   f  Γöé Precision specifies the number of digits  Γöé Default precision is  Γöé
  22558. Γöé   F  Γöé to be printed after the decimal point.   Γöé six.  If precision is  Γöé
  22559. Γöé   e  Γöé The last digit printed is rounded.     Γöé "0" or the period    Γöé
  22560. Γöé   E  Γöé                       Γöé appears without a    Γöé
  22561. Γöé     Γöé                       Γöé number following it,  Γöé
  22562. Γöé     Γöé                       Γöé no decimal point is   Γöé
  22563. Γöé     Γöé                       Γöé printed.        Γöé
  22564. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22565. Γöé   g  Γöé Precision specifies the maximum number of  Γöé All significant digits Γöé
  22566. Γöé   G  Γöé significant digits printed.         Γöé are printed.      Γöé
  22567. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22568. Γöé   c  Γöé No effect.                 Γöé The character is    Γöé
  22569. Γöé     Γöé                       Γöé printed.        Γöé
  22570. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22571. Γöé   lc  Γöé No effect.                 Γöé The "wchar_t" char-   Γöé
  22572. Γöé     Γöé                       Γöé acter is printed.    Γöé
  22573. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22574. Γöé   s  Γöé Precision specifies the maximum number of  Γöé Characters are printed Γöé
  22575. Γöé     Γöé characters to be printed.  Characters in  Γöé until a null character Γöé
  22576. Γöé     Γöé excess of precision are not printed.    Γöé is encountered.     Γöé
  22577. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  22578. Γöé   ls  Γöé Precision specifies the maximum number of  Γöé "wchar_t" characters  Γöé
  22579. Γöé     Γöé bytes to be printed.  Bytes in excess of  Γöé are printed until a   Γöé
  22580. Γöé     Γöé precision are not printed; however, multi- Γöé null character is    Γöé
  22581. Γöé     Γöé byte integrity is always preserved.     Γöé encountered.      Γöé
  22582. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  22583.  
  22584.  
  22585. ΓòÉΓòÉΓòÉ 4.221.5. Format Specification - h, l, L ΓòÉΓòÉΓòÉ
  22586.  
  22587. The h, l, and L characters specify the size of the expected argument.  Their 
  22588. meanings are as follows: 
  22589.  
  22590.  h    A prefix with the integer types d, i, o, u, x, X, and n that specifies 
  22591.       that the argument is short int or unsigned short int. 
  22592.  
  22593.  l    A prefix with d, i, o, u, x, X, and n types that specifies that the 
  22594.       argument is a long int or unsigned long int. 
  22595.  
  22596.  L    A prefix with e, E, f, g, or G types that specifies that the argument is 
  22597.       long double. 
  22598.  
  22599.  
  22600. ΓòÉΓòÉΓòÉ <hidden> Example of printf ΓòÉΓòÉΓòÉ
  22601.  
  22602. /************************************************************************
  22603.  
  22604. This example prints data in a variety of formats. 
  22605.  
  22606. ************************************************************************/
  22607.  
  22608. #include <stdio.h>
  22609.  
  22610. int main(void)
  22611. {
  22612.    char ch = 'h',*string = "computer";
  22613.    int count = 234,hex = 0x10,oct = 010,dec = 10;
  22614.    double fp = 251.7366;
  22615.  
  22616.    printf("%d   %+d    %06d     %X    %x     %o\n\n", count, count, count, count
  22617.       , count, count);
  22618.    printf("1234567890123%n4567890123456789\n\n", &count);
  22619.    printf("Value of count should be 13; count = %d\n\n", count);
  22620.    printf("%10c%5c\n\n", ch, ch);
  22621.    printf("%25s\n%25.4s\n\n", string, string);
  22622.    printf("%f    %.2f    %e    %E\n\n", fp, fp, fp, fp);
  22623.    printf("%i    %i     %i\n\n", hex, oct, dec);
  22624.    return 0;
  22625.  
  22626.    /****************************************************************************
  22627.       The output should be:
  22628.  
  22629.       234   +234    000234     EA    ea     352
  22630.  
  22631.       12345678901234567890123456789
  22632.  
  22633.       Value of count should be 13; count = 13
  22634.  
  22635.                h    h
  22636.  
  22637.                        computer
  22638.                            comp
  22639.  
  22640.       251.736600    251.74    2.517366e+02    2.517366E+02
  22641.  
  22642.       16    8     10
  22643.    ****************************************************************************/
  22644. }
  22645.  
  22646.  
  22647. ΓòÉΓòÉΓòÉ 4.222. putc - putchar - Write a Character ΓòÉΓòÉΓòÉ
  22648.  
  22649.  
  22650. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22651.  
  22652. #include <stdio.h>
  22653. int putc(int c, FILE *stream);
  22654. int putchar(int c);
  22655.  
  22656.  
  22657. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22658.  
  22659. Language Level: ANSI, SAA, POSIX, XPG4 
  22660.  
  22661. putc converts c to unsigned char and then writes c to the output stream at the 
  22662. current position. putchar is equivalent to putc(c, stdout). 
  22663.  
  22664. putc is equivalent to fputc except that, if it is implemented as a macro, putc 
  22665. can evaluate stream more than once. Therefore, the stream argument to putc 
  22666. should not be an expression with side effects. 
  22667.  
  22668. Return Value 
  22669. putc and putchar return the character written.  A return value of EOF indicates 
  22670. an error. 
  22671.  
  22672.  
  22673. ΓòÉΓòÉΓòÉ <hidden> Example of putc - putchar ΓòÉΓòÉΓòÉ
  22674.  
  22675. /************************************************************************
  22676.  
  22677. This example writes the contents of a buffer to a data stream. In this example, 
  22678. the body of the for statement is null because the example carries out the 
  22679. writing operation in the test expression. 
  22680.  
  22681. ************************************************************************/
  22682.  
  22683. #include <stdio.h>
  22684.  
  22685. #define  LENGTH        80
  22686.  
  22687. int main(void)
  22688. {
  22689.    FILE *stream = stdout;
  22690.    int i,ch;
  22691.    char buffer[LENGTH+1] = "Hello world";
  22692.  
  22693.     /* This could be replaced by using the fwrite routine                     */
  22694.  
  22695.    for (i = 0; (i < sizeof(buffer)) && ((ch = putc(buffer[i], stream)) != EOF);
  22696.       ++i)
  22697.       ;
  22698.    return 0;
  22699.  
  22700.    /****************************************************************************
  22701.       The output should be:
  22702.  
  22703.       Hello world
  22704.    ****************************************************************************/
  22705. }
  22706.  
  22707.  
  22708. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22709.  
  22710. Example of putc - putchar 
  22711.  
  22712.      fputc - Write Character 
  22713.      _fputchar - Write Character 
  22714.      fwrite - Write Items 
  22715.      getc - getchar - Read a Character 
  22716.      _putch - Write Character to Screen 
  22717.      puts - Write a String 
  22718.      write - Writes from Buffer to File 
  22719.      <stdio.h> 
  22720.  
  22721.  
  22722. ΓòÉΓòÉΓòÉ 4.223. _putch - Write Character to Screen ΓòÉΓòÉΓòÉ
  22723.  
  22724.  
  22725. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22726.  
  22727. #include <conio.h>
  22728. int _putch(int c);
  22729.  
  22730.  
  22731. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22732.  
  22733. Language Level:  Extension 
  22734.  
  22735. _putch writes the character c directly to the screen. 
  22736.  
  22737. Return Value 
  22738. If successful, _putch returns c. If an error occurs, _putch returns EOF. 
  22739.  
  22740.  
  22741. ΓòÉΓòÉΓòÉ <hidden> Example of _putch ΓòÉΓòÉΓòÉ
  22742.  
  22743. /************************************************************************
  22744.  
  22745. This example defines a function gchar that is similar to _getche using the 
  22746. _putch and _getch functions: 
  22747.  
  22748. ************************************************************************/
  22749.  
  22750. #include <conio.h>
  22751.  
  22752. int gchar(void)
  22753. {
  22754.    int ch;
  22755.  
  22756.    ch = _getch();
  22757.    _putch(ch);
  22758.    return (ch);
  22759. }
  22760.  
  22761.  
  22762. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22763.  
  22764. Example of _putch 
  22765.  
  22766.      _cputs - Write String to Screen 
  22767.      _cprintf - Print Characters to Screen 
  22768.      fputc - Write Character 
  22769.      _getch - _getche - Read Character from Keyboard 
  22770.      putc - putchar - Write a Character 
  22771.      puts - Write a String 
  22772.      write - Writes from Buffer to File 
  22773.      <conio.h> 
  22774.  
  22775.  
  22776. ΓòÉΓòÉΓòÉ 4.224. putenv - Modify Environment Variables ΓòÉΓòÉΓòÉ
  22777.  
  22778.  
  22779. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22780.  
  22781. #include <stdlib.h>
  22782. int putenv(char *envstring);
  22783.  
  22784.  
  22785. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22786.  
  22787. Language Level:  XPG4, Extension 
  22788.  
  22789. putenv adds new environment variables or modifies the values of existing 
  22790. environment variables. Environment variables define the environment in which a 
  22791. process runs (for example, the default search path for libraries to be linked 
  22792. with a program). 
  22793.  
  22794. The envstring argument must be a pointer to a string with the form: 
  22795.  
  22796.    varname=string
  22797.  
  22798. where varname is the name of the environment variable to be added or modified 
  22799. and string is the value of the variable. See the Notes below. 
  22800.  
  22801. If varname is already part of the environment, string replaces its current 
  22802. value; if not, the new varname is added to the environment with the value 
  22803. string. To set a variable to an empty value, specify an empty string. A 
  22804. variable can be removed from the environment by specifying varname only, for 
  22805. example: 
  22806.  
  22807.    putenv("PATH");
  22808.  
  22809. Do not free the envstring pointer while the entry it points to is in use, or 
  22810. the environment variable will point into freed space. A similar problem can 
  22811. occur if you pass a pointer to a local variable to putenv and then exit from 
  22812. the function in which the variable is declared. Once you have added the 
  22813. envstring with putenv, any change to the entry it points to changes the 
  22814. environment used by your program. 
  22815.  
  22816. The environment manipulated by putenv is local to the process currently 
  22817. running. You cannot enter new items in your command-level environment using 
  22818. putenv.  When the program ends, the environment reverts to the parent process 
  22819. environment. This environment is passed on to some child processes created by 
  22820. the _spawn, exec, or system functions, and they get any new environment 
  22821. variables added using putenv. 
  22822.  
  22823. DosScanEnv will not reflect any changes made using putenv, but getenv will 
  22824. reflect the changes. 
  22825.  
  22826. Notes 
  22827.  
  22828.    1. putenv can change the value of _environ, thus invalidating the envp 
  22829.       argument to the main function. 
  22830.  
  22831.    2. You cannot use %envvar%, where envvar is any OS/2 environment variable, 
  22832.       with putenv to concatenate new envstring and old envstring. 
  22833.  
  22834.    3. In earlier releases of C Set ++, putenv began with an underscore 
  22835.       (_putenv). Because it is defined by the X/Open standard, the underscore 
  22836.       has been removed. For compatibility, VisualAge C++ will map _putenv to 
  22837.       putenv for you. 
  22838.  
  22839.  Return Value 
  22840.  putenv returns 0 if it is successful. A return value of -1 indicates an error. 
  22841.  
  22842.  
  22843. ΓòÉΓòÉΓòÉ <hidden> Example of putenv ΓòÉΓòÉΓòÉ
  22844.  
  22845. /************************************************************************
  22846.  
  22847. This example tries to change the environment variable PATH, and then uses 
  22848. getenv to get the current path. If the call to putenv fails, the example writes 
  22849. an error message. 
  22850.  
  22851. ************************************************************************/
  22852.  
  22853. #include <stdlib.h>
  22854. #include <stdio.h>
  22855.  
  22856. int main(void)
  22857. {
  22858.    char *pathvar;
  22859.  
  22860.    if (-1 == putenv("PATH=a:\\bin;b:\\andy")) {
  22861.       printf("putenv failed - out of memory\n");
  22862.       return EXIT_FAILURE;
  22863.    }
  22864.  
  22865.    /* getting and printing the current environment path                       */
  22866.  
  22867.    pathvar = getenv("PATH");
  22868.    printf("The current path is: %s\n", pathvar);
  22869.    return 0;
  22870.  
  22871.    /****************************************************************************
  22872.       The output should be:
  22873.  
  22874.       The current path is: a:\bin;b:\andy
  22875.    ****************************************************************************/
  22876. }
  22877.  
  22878.  
  22879. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22880.  
  22881. Example of putenv 
  22882.  
  22883.      execl - _execvpe - Load and Run Child Process 
  22884.      getenv - Search for Environment Variables 
  22885.      _spawnl - _spawnvpe - Start and Run Child Processes 
  22886.      system - Invoke the Command Processor 
  22887.      "envp Parameter to main" in the Programming Guide 
  22888.      <stdlib.h> 
  22889.  
  22890.  
  22891. ΓòÉΓòÉΓòÉ 4.225. puts - Write a String ΓòÉΓòÉΓòÉ
  22892.  
  22893.  
  22894. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22895.  
  22896. #include <stdio.h>
  22897. int puts(const char *string);
  22898.  
  22899.  
  22900. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22901.  
  22902. Language Level: ANSI, SAA, POSIX, XPG4 
  22903.  
  22904. puts writes the given string to the standard output stream stdout;  it also 
  22905. appends a new-line character to the output.  The terminating null character is 
  22906. not written. 
  22907.  
  22908. Return Value 
  22909. puts returns EOF if an error occurs.  A nonnegative return value indicates that 
  22910. no error has occurred. 
  22911.  
  22912.  
  22913. ΓòÉΓòÉΓòÉ <hidden> Example of puts ΓòÉΓòÉΓòÉ
  22914.  
  22915. /************************************************************************
  22916.  
  22917. This example writes Hello World to stdout. 
  22918.  
  22919. ************************************************************************/
  22920.  
  22921. #include <stdio.h>
  22922.  
  22923. int main(void)
  22924. {
  22925.    if (EOF == puts("Hello World"))
  22926.       printf("Error in puts\n");
  22927.    return 0;
  22928.  
  22929.    /****************************************************************************
  22930.       The output should be:
  22931.  
  22932.       Hello World
  22933.    ****************************************************************************/
  22934. }
  22935.  
  22936.  
  22937. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  22938.  
  22939. Example of puts 
  22940.  
  22941.      _cputs - Write String to Screen 
  22942.      fputs - Write String 
  22943.      gets - Read a Line 
  22944.      putc - putchar - Write a Character 
  22945.      <stdio.h> 
  22946.  
  22947.  
  22948. ΓòÉΓòÉΓòÉ 4.226. putwc - Write Wide Character ΓòÉΓòÉΓòÉ
  22949.  
  22950.  
  22951. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  22952.  
  22953. #include <stdio.h>
  22954. #include <wchar.h>
  22955. wint_t putwc(wint_t wc, FILE *stream);
  22956.  
  22957.  
  22958. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  22959.  
  22960. Language Level: ANSI 93, XPG4 
  22961.  
  22962. putwc converts the wide character wc to a multibyte character, and writes it to 
  22963. the stream at the current position. It also advances the file position 
  22964. indicator for the stream appropriately. 
  22965.  
  22966. putwc function is equivalent to fputwc except that, if it is implemented as a 
  22967. macro, putwc can evaluate stream more than once. Therefore, the stream argument 
  22968. to putwc should not be an expression with side effects. 
  22969.  
  22970. The behavior of putwc is affected by the LC_CTYPE category of the current 
  22971. locale. Using a non-wide-character function with putwc on the same stream 
  22972. results in undefined behavior. 
  22973.  
  22974. After calling putwc, flush the buffer or reposition the stream pointer before 
  22975. calling a write function for the stream, unless EOF has been reached. After a 
  22976. write operation on the stream, flush the buffer or reposition the stream 
  22977. pointer before calling putwc. 
  22978.  
  22979. Return Value 
  22980. putwc returns the wide character written. If a write error occurs, putwc sets 
  22981. the error indicator for the stream and returns WEOF. If an encoding error 
  22982. occurs when a wide character is converted to a multibyte character, putwc sets 
  22983. errno to EILSEQ and returns WEOF. 
  22984.  
  22985.  
  22986. ΓòÉΓòÉΓòÉ <hidden> Example of putwc ΓòÉΓòÉΓòÉ
  22987.  
  22988. /************************************************************************
  22989.  
  22990. The following example uses putwc to convert the wide characters in wcs to 
  22991. multibyte characters and write them to the file putwc.out. 
  22992.  
  22993. ************************************************************************/
  22994.  
  22995. #include <stdio.h>
  22996. #include <wchar.h>
  22997. #include <stdlib.h>
  22998. #include <errno.h>
  22999.  
  23000. int main(void)
  23001. {
  23002.    FILE    *stream;
  23003.    wchar_t *wcs = L"A character string.";
  23004.    int     i;
  23005.  
  23006.    if (NULL == (stream = fopen("putwc.out", "w"))) {
  23007.       printf("Unable to open: \"putwc.out\".\n");
  23008.       exit(EXIT_FAILURE);
  23009.    }
  23010.  
  23011.    for (i = 0; wcs[i] != L'\0'; i++) {
  23012.       errno = 0;
  23013.       if (WEOF == putwc(wcs[i], stream)) {
  23014.          printf("Unable to putwc() the wide character.\n"
  23015.                 "wcs[%d] = 0x%lx\n", i, wcs[i]);
  23016.          if (EILSEQ == errno)
  23017.             printf("An invalid wide character was encountered.\n");
  23018.          exit(EXIT_FAILURE);
  23019.       }
  23020.    }
  23021.    fclose(stream);
  23022.    return 0;
  23023.  
  23024.    /****************************************************************************
  23025.       The output file putwc.out should contain :
  23026.  
  23027.       A character string.
  23028.    ****************************************************************************/
  23029. }
  23030.  
  23031.  
  23032. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23033.  
  23034. Example of putwc 
  23035.  
  23036.      fputc - Write Character 
  23037.      _fputchar - Write Character 
  23038.      fputwc - Write Wide Character 
  23039.      getwc - Read Wide Character from Stream 
  23040.      putc - putchar - Write a Character 
  23041.      _putch - Write Character to Screen 
  23042.      putwchar - Write Wide Character to stdout 
  23043.      <stdio.h> 
  23044.      <wchar.h> 
  23045.  
  23046.  
  23047. ΓòÉΓòÉΓòÉ 4.227. putwchar - Write Wide Character to stdout ΓòÉΓòÉΓòÉ
  23048.  
  23049.  
  23050. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23051.  
  23052. #include <wchar.h>
  23053. wint_t putwchar(wint_t wc);
  23054.  
  23055.  
  23056. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23057.  
  23058. Language Level:  ANSI 93, XPG4 
  23059.  
  23060. putwchar converts the wide character wc to a multibyte character and writes it 
  23061. to stdout. A call to putwchar is equivalent to putwc(wc, stdout). 
  23062.  
  23063. The behavior of putwchar is affected by the LC_CTYPE category of the current 
  23064. locale. Using a non-wide-character function with putwchar on the same stream 
  23065. results in undefined behavior. 
  23066.  
  23067. After calling putwchar, flush the buffer or reposition the stream pointer 
  23068. before calling a write function for the stream, unless EOF has been reached. 
  23069. After a write operation on the stream, flush the buffer or reposition the 
  23070. stream pointer before calling putwchar. 
  23071.  
  23072. Return Value 
  23073. putwchar returns the wide character written. If a write error occurs, putwchar 
  23074. sets the error indicator for the stream and returns WEOF. If an encoding error 
  23075. occurs when a wide character is converted to a multibyte character, putwchar 
  23076. sets errno to EILSEQ and returns WEOF. 
  23077.  
  23078.  
  23079. ΓòÉΓòÉΓòÉ <hidden> Example of putwchar ΓòÉΓòÉΓòÉ
  23080.  
  23081. /************************************************************************
  23082.  
  23083. This example uses putwchar to write the string in wcs. 
  23084.  
  23085. ************************************************************************/
  23086.  
  23087. #include <stdio.h>
  23088. #include <wchar.h>
  23089. #include <errno.h>
  23090. #include <stdlib.h>
  23091.  
  23092. int main(void)
  23093. {
  23094.    wchar_t *wcs = L"A character string.";
  23095.    int     i;
  23096.  
  23097.    for (i = 0; wcs[i] != L'\0'; i++) {
  23098.       errno = 0;
  23099.       if (WEOF == putwchar(wcs[i])) {
  23100.          printf("Unable to putwchar() the wide character.\n");
  23101.          printf("wcs[%d] = 0x%lx\n", i, wcs[i]);
  23102.          if (EILSEQ == errno)
  23103.             printf("An invalid wide character was encountered.\n");
  23104.          exit(EXIT_FAILURE);
  23105.       }
  23106.    }
  23107.    return 0;
  23108.  
  23109.    /****************************************************************************
  23110.       The output should be similar to :
  23111.  
  23112.       A character string.
  23113.    ****************************************************************************/
  23114. }
  23115.  
  23116.  
  23117. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23118.  
  23119. Example of putwchar 
  23120.  
  23121.      fputc - Write Character 
  23122.      _fputchar - Write Character 
  23123.      fputwc - Write Wide Character 
  23124.      getwchar - Get Wide Character from stdin 
  23125.      putc - putchar - Write a Character 
  23126.      _putch - Write Character to Screen 
  23127.      <wchar.h> 
  23128.  
  23129.  
  23130. ΓòÉΓòÉΓòÉ 4.228. qsort - Sort Array ΓòÉΓòÉΓòÉ
  23131.  
  23132.  
  23133. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23134.  
  23135. #include <stdlib.h>
  23136. void qsort(void *base, size_t num, size_t width,
  23137.            int(*compare)(const void *key, const void *element));
  23138.  
  23139.  
  23140. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23141.  
  23142. Language Level:  ANSI, SAA, POSIX, XPG4 
  23143.  
  23144. qsort sorts an array of num elements, each of width bytes in size.  The base 
  23145. pointer is a pointer to the array to be sorted. qsort overwrites this array 
  23146. with the sorted elements. 
  23147.  
  23148. The compare argument is a pointer to a function you must supply that takes a 
  23149. pointer to the key argument and to an array element, in that order. qsort calls 
  23150. this function one or more times during the search. The function must compare 
  23151. the key and the element and return one of the following values: 
  23152.  
  23153.  Value              Meaning 
  23154.  Less than 0        key less than element 
  23155.  0                  key equal to element 
  23156.  Greater than 0     key greater than element 
  23157.  
  23158.  The sorted array elements are stored in ascending order, as defined by your 
  23159.  compare function.  You can sort in reverse order by reversing the sense of 
  23160.  "greater than" and "less than" in compare.  The order of the elements is 
  23161.  unspecified when two elements compare equally. 
  23162.  
  23163.  Return Value 
  23164.  There is no return value. 
  23165.  
  23166.  
  23167. ΓòÉΓòÉΓòÉ <hidden> Example of qsort ΓòÉΓòÉΓòÉ
  23168.  
  23169. /************************************************************************
  23170.  
  23171. This example sorts the arguments (argv) in ascending lexical sequence, using 
  23172. the comparison function compare() supplied in the example. 
  23173.  
  23174. ************************************************************************/
  23175.  
  23176. #include <stdio.h>
  23177. #include <stdlib.h>
  23178. #include <string.h>
  23179.  
  23180. /* --------------------------------------------------------------             */
  23181. /* compare() routine called internally by qsort()                             */
  23182. /*                                                                            */
  23183. /* Assert: Library always calls functions internally with                     */
  23184. /*         _Optlink linkage convention. Ensure that compare() is              */
  23185. /*         always _Optlink.                                                   */
  23186. /* --------------------------------------------------------------             */
  23187.  
  23188. int _Optlink compare(const void *arg1,const void *arg2)
  23189. {
  23190.    return (strcmp(*(char **)arg1, *(char **)arg2));
  23191. }
  23192.  
  23193. int main(int argc,char *argv[])
  23194. {
  23195.    int i;
  23196.    argv++;
  23197.    argc--;
  23198.  
  23199.    qsort((char *)argv, argc, sizeof(char *), compare);
  23200.    for (i = 0; i < argc; ++i)
  23201.       printf("%s\n", argv[i]);
  23202.    return 0;
  23203.  
  23204.    /****************************************************************************
  23205.       Assuming command line of: qsort kent theresa andrea laura brenden
  23206.       Output should be:
  23207.  
  23208.         andrea
  23209.         brenden
  23210.         kent
  23211.         laura
  23212.         theresa
  23213.    ****************************************************************************/
  23214. }
  23215.  
  23216.  
  23217. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23218.  
  23219. Example of qsort 
  23220.  
  23221.      bsearch - Search Arrays 
  23222.      lfind - lsearch - Find Key in Array 
  23223.      <search.h> 
  23224.      <stdlib.h> 
  23225.  
  23226.  
  23227. ΓòÉΓòÉΓòÉ 4.229. raise - Send Signal ΓòÉΓòÉΓòÉ
  23228.  
  23229.  
  23230. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23231.  
  23232. #include <signal.h>
  23233. int raise(int sig);
  23234.  
  23235.  
  23236. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23237.  
  23238. Language Level: ANSI, SAA, XPG4 
  23239.  
  23240. raise sends the signal sig to the running program. You can then use signal to 
  23241. handle sig. 
  23242.  
  23243. Signals and signal handling are described in signal - Handle Interrupt Signals, 
  23244. and in the Programming Guide under Signal and Exception Handling. 
  23245.  
  23246. Return Value 
  23247. raise returns 0 if successful, nonzero if unsuccessful. 
  23248.  
  23249.  
  23250. ΓòÉΓòÉΓòÉ <hidden> Example of raise ΓòÉΓòÉΓòÉ
  23251.  
  23252. /************************************************************************
  23253.  
  23254. This example establishes a signal handler called sig_hand for the signal 
  23255. SIGUSR1. The signal handler is called whenever the SIGUSR1 signal is raised and 
  23256. will ignore the first nine occurrences of the signal.  On the tenth raised 
  23257. signal, it exits the program with an error code of 10.  Note that the signal 
  23258. handler must be reestablished each time it is called. 
  23259.  
  23260. ************************************************************************/
  23261.  
  23262. #include <signal.h>
  23263. #include <stdio.h>
  23264.  
  23265. void sig_hand(int);        /* declaration of sig_hand() as a function         */
  23266. int main(void)
  23267. {
  23268.    signal(SIGUSR1, sig_hand);              /* set up handler for SIGUSR1      */
  23269.  
  23270.    raise(SIGUSR1);                      /* signal SIGUSR1 is raised           */
  23271.                       /* sig_hand() is called                                 */
  23272.    return 0;
  23273. }
  23274.  
  23275. void sig_hand(int sig)
  23276. {
  23277.    static int count = 0;                 /* initialized only once             */
  23278.    count++;
  23279.  
  23280.    if (10 == count)     /* ignore the first 9 occurrences of this signal      */
  23281.       exit(10);
  23282.    else
  23283.       signal(SIGUSR1, sig_hand);               /* set up the handler again    */
  23284.    raise(SIGUSR1);
  23285. }
  23286.  
  23287.  
  23288. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23289.  
  23290. Example of raise 
  23291.  
  23292.      signal - Handle Interrupt Signals 
  23293.      Signal and Exception Handling in the Programming Guide 
  23294.      <signal.h> 
  23295.  
  23296.  
  23297. ΓòÉΓòÉΓòÉ 4.230. rand - Generate Random Number ΓòÉΓòÉΓòÉ
  23298.  
  23299.  
  23300. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23301.  
  23302. #include <stdlib.h>
  23303. int rand(void);
  23304.  
  23305.  
  23306. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23307.  
  23308. Language Level: ANSI, SAA, POSIX, XPG4 
  23309.  
  23310. rand generates a pseudo-random integer in the range 0 to RAND_MAX (macro 
  23311. defined in <stdlib.h>). Use srand before calling rand to set a starting point 
  23312. for the random number generator. If you do not call srand first, the default 
  23313. seed is 1. 
  23314.  
  23315. Return Value 
  23316. rand returns a pseudo-random number. 
  23317.  
  23318.  
  23319. ΓòÉΓòÉΓòÉ <hidden> Example of rand ΓòÉΓòÉΓòÉ
  23320.  
  23321. /************************************************************************
  23322.  
  23323. This example prints the first 10 random numbers generated. 
  23324.  
  23325. ************************************************************************/
  23326.  
  23327. #include <stdlib.h>
  23328. #include <stdio.h>
  23329.  
  23330. int main(void)
  23331. {
  23332.    int x;
  23333.  
  23334.    for (x = 1; x <= 10; x++)
  23335.       printf("iteration %d, rand=%d\n", x, rand());
  23336.    return 0;
  23337.  
  23338.    /****************************************************************************
  23339.       The output should be:
  23340.  
  23341.       iteration 1, rand=16838
  23342.       iteration 2, rand=5758
  23343.       iteration 3, rand=10113
  23344.       iteration 4, rand=17515
  23345.       iteration 5, rand=31051
  23346.       iteration 6, rand=5627
  23347.       iteration 7, rand=23010
  23348.       iteration 8, rand=7419
  23349.       iteration 9, rand=16212
  23350.       iteration 10, rand=4086
  23351.    ****************************************************************************/
  23352. }
  23353.  
  23354.  
  23355. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23356.  
  23357. Example of rand 
  23358.  
  23359.      srand - Set Seed for rand Function 
  23360.      <stdlib.h> 
  23361.  
  23362.  
  23363. ΓòÉΓòÉΓòÉ 4.231. read - Read Into Buffer ΓòÉΓòÉΓòÉ
  23364.  
  23365.  
  23366. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23367.  
  23368. #include <io.h>
  23369. int read(int handle, char *buffer, unsigned int count);
  23370.  
  23371.  
  23372. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23373.  
  23374. Language Level:  XPG4, Extension 
  23375.  
  23376. read reads count bytes from the file associated with handle into buffer. The 
  23377. read operation begins at the current position of the file pointer associated 
  23378. with the given file. After the read operation, the file pointer points to the 
  23379. next unread character. 
  23380.  
  23381. Note:  In earlier releases of C Set ++, read began with an underscore (_read). 
  23382. Because it is defined by the X/Open standard, the underscore has been removed. 
  23383. For compatibility, VisualAge C++ will map _read to read for you. 
  23384.  
  23385. Return Value 
  23386. read returns the number of bytes placed in buffer.  This number can be less 
  23387. than count if there are fewer than count  bytes left in the file or if the file 
  23388. was opened in text mode.  (See the note below.) The return value 0 indicates an 
  23389. attempt to read at end-of-file. A return value -1 indicates an error. If -1 is 
  23390. returned, the current file position is undefined, and errno is set to one of 
  23391. the following values: 
  23392.  
  23393.  Value        Meaning 
  23394.  EBADF        The given handle is incorrect, or the file is not open for 
  23395.               reading, or the file is locked. 
  23396.  EOS2ERR      The call to the operating system was not successful. 
  23397.  
  23398.  Note:  If the file was opened in text mode, the return value might not 
  23399.  correspond to the number of bytes actually read.  When text mode is in effect, 
  23400.  carriage return characters are deleted from the input stream without affecting 
  23401.  the file pointer. 
  23402.  
  23403.  
  23404. ΓòÉΓòÉΓòÉ <hidden> Example of read ΓòÉΓòÉΓòÉ
  23405.  
  23406. /************************************************************************
  23407.  
  23408. This example opens the file sample.dat and attempts to read from it. 
  23409.  
  23410. ************************************************************************/
  23411.  
  23412. #include <io.h>
  23413. #include <stdio.h>
  23414. #include <stdlib.h>
  23415. #include <fcntl.h>
  23416. #include <string.h>
  23417.  
  23418. int main(void)
  23419. {
  23420.    int fh;
  23421.    char buffer[20];
  23422.  
  23423.    memset(buffer, '\0', 20);
  23424.    printf("\nCreating sample.dat.\n");
  23425.    system("echo Sample Program > sample.dat");
  23426.    if (-1 == (fh = open("sample.dat", O_RDWR|O_APPEND))) {
  23427.       perror("Unable to open sample.dat.");
  23428.       return EXIT_FAILURE;
  23429.    }
  23430.    if (7 != read(fh, buffer, 7)) {
  23431.       perror("Unable to read from sample.dat.");
  23432.       close(fh);
  23433.       return EXIT_FAILURE;
  23434.    }
  23435.    printf("Successfully read in the following:\n%s\n ", buffer);
  23436.    close(fh);
  23437.    return 0;
  23438.  
  23439.    /****************************************************************************
  23440.       The output should be:
  23441.  
  23442.       Creating sample.dat.
  23443.       Successfully read in the following:
  23444.       Sample
  23445.    ****************************************************************************/
  23446. }
  23447.  
  23448.  
  23449. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23450.  
  23451. Example of read 
  23452.  
  23453.      creat - Create New File 
  23454.      fread - Read Items 
  23455.      open - Open File 
  23456.      _sopen - Open Shared File 
  23457.      write - Writes from Buffer to File 
  23458.      <io.h> 
  23459.  
  23460.  
  23461. ΓòÉΓòÉΓòÉ 4.232. realloc - Change Reserved Storage Block Size ΓòÉΓòÉΓòÉ
  23462.  
  23463.  
  23464. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23465.  
  23466. #include <stdlib.h>  /* also in <malloc.h> */
  23467. void *realloc(void *ptr, size_t size);
  23468.  
  23469.  
  23470. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23471.  
  23472. Language Level:  ANSI, SAA, POSIX, XPG4, Extension 
  23473.  
  23474. realloc changes the size of a previously reserved storage block.  The ptr 
  23475. argument points to the beginning of the block.  The size argument gives the new 
  23476. size of the block, in bytes.  The contents of the block are unchanged up to the 
  23477. shorter of the new and old sizes. realloc allocates the new block from the same 
  23478. heap the original block was in. 
  23479.  
  23480. If ptr is NULL, realloc reserves a block of storage of size bytes from the 
  23481. current thread's default heap (equivalent to calling malloc(size)). 
  23482.  
  23483. If size is 0 and the ptr is not NULL, realloc frees the storage allocated to 
  23484. ptr and returns NULL 
  23485.  
  23486. Return Value 
  23487. realloc returns a pointer to the reallocated storage block.  The storage 
  23488. location of the block may be moved by the realloc function.  Thus, the ptr 
  23489. argument to realloc is not necessarily the same as the return value. 
  23490.  
  23491. If size is 0, realloc returns NULL. If there is not enough storage to expand 
  23492. the block to the given size, the original block is unchanged and realloc 
  23493. returns NULL. 
  23494.  
  23495. The storage to which the return value points is aligned for storage of any type 
  23496. of object. 
  23497.  
  23498.  
  23499. ΓòÉΓòÉΓòÉ <hidden> Example of realloc ΓòÉΓòÉΓòÉ
  23500.  
  23501. /************************************************************************
  23502.  
  23503. This example allocates storage for the prompted size of array and then uses 
  23504. realloc to reallocate the block to hold the new size of the array. The contents 
  23505. of the array are printed after each allocation. 
  23506.  
  23507. ************************************************************************/
  23508.  
  23509. #include <stdio.h>
  23510. #include <stdlib.h>
  23511.  
  23512. int main(void)
  23513. {
  23514.    long *array;                         /* start of the array            */
  23515.    long *ptr;                           /* pointer to array */
  23516.    int i;                               /* index variable   */
  23517.    int num1,num2;                       /* number of entries of the array     */
  23518.    void print_array(long *ptr_array, int size);
  23519.  
  23520.    printf("Enter the size of the array\n");
  23521.    scanf("%i", &num1);
  23522.  
  23523.    /* allocate num1 entries using malloc()                                    */
  23524.  
  23525.    if ((array = malloc(num1 *sizeof(long))) != NULL) {
  23526.       for (ptr = array, i = 0; i < num1; ++i)             /* assign values    */
  23527.          *ptr++ = i;
  23528.       print_array(array, num1);
  23529.       printf("\n");
  23530.    }
  23531.    else {                                                 /* malloc error     */
  23532.       perror("Out of storage");
  23533.       abort();
  23534.    }
  23535.  
  23536.    /* Change the size of the array ...                                        */
  23537.  
  23538.    printf("Enter the size of the new array\n");
  23539.    scanf("%i", &num2);
  23540.    if ((array = realloc(array, num2 *sizeof(long))) != NULL) {
  23541.       for (ptr = array+num1, i = num1; i <= num2; ++i)
  23542.          *ptr++ = i+2000;                /* assign values to new elements     */
  23543.       print_array(array, num2);
  23544.    }
  23545.    else {                                                 /* realloc error    */
  23546.       perror("Out of storage");
  23547.       abort();
  23548.    }
  23549.    return 0;
  23550.  
  23551.    /****************************************************************************
  23552.       The output should be similar to:
  23553.  
  23554.       Enter the size of the array
  23555.       2
  23556.       The array of size 2 is:
  23557.         array[ 0 ] = 0
  23558.         array[ 1 ] = 1
  23559.       Enter the size of the new array
  23560.       4
  23561.       The array of size 4 is:
  23562.         array[ 0 ] = 0
  23563.         array[ 1 ] = 1
  23564.         array[ 2 ] = 2002
  23565.         array[ 3 ] = 2003
  23566.    ****************************************************************************/
  23567. }
  23568.  
  23569. void print_array(long *ptr_array,int size)
  23570. {
  23571.    int i;
  23572.    long *index = ptr_array;
  23573.  
  23574.    printf("The array of size %d is:\n", size);
  23575.    for (i = 0; i < size; ++i)                             /* print the array
  23576.                                                              out              */
  23577.       printf("  array[ %i ] = %li\n", i, ptr_array[i]);
  23578. }
  23579.  
  23580.  
  23581. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23582.  
  23583. Example of realloc 
  23584.  
  23585.      calloc - Reserve and Initialize Storage 
  23586.      _debug_realloc - Reallocate Memory Block 
  23587.      _debug_trealloc - Reallocate Tiled Memory Block 
  23588.      free - Release Storage Blocks 
  23589.      malloc - Reserve Storage Block 
  23590.      _msize - Return Number of Bytes Allocated 
  23591.      _trealloc - Reallocate Tiled Storage Block 
  23592.      <malloc.h> 
  23593.      <stdlib.h> 
  23594.  
  23595.  
  23596. ΓòÉΓòÉΓòÉ 4.233. regcomp - Compile Regular Expression ΓòÉΓòÉΓòÉ
  23597.  
  23598.  
  23599. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23600.  
  23601. #include <regex.h>
  23602. int regcomp(regex_t *preg, const char *pattern, int cflags);
  23603.  
  23604.  
  23605. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23606.  
  23607. Language Level:  POSIX, XPG4 
  23608.  
  23609. regcomp compiles the source regular expression pointed to by pattern into an 
  23610. executable version and stores it in the location pointed to by preg. You can 
  23611. then use regexec to compare the regular expression to other strings. 
  23612.  
  23613. The cflags flag defines the attributes of the compilation process: 
  23614.  
  23615.  REG_EXTENDED Support extended regular expressions. 
  23616.  
  23617.  REG_NEWLINE Treat new-line character as a special end-of-line character; it 
  23618.       then establishes the line boundaries matched by the ^ and $ patterns, and 
  23619.       can only be matched within a string explicitly using \n. (If you omit 
  23620.       this flag, the new-line character is treated like any other character.) 
  23621.  
  23622.  REG_ICASE Ignore case in match. 
  23623.  
  23624.  REG_NOSUB Ignore the number of subexpressions specified in pattern. When you 
  23625.       compare a string to the compiled pattern (using regexec), the string must 
  23626.       match the entire pattern. regexec then returns a value that indicates 
  23627.       only if a match was found; it does not indicate at what point in the 
  23628.       string the match begins, or what the matching string is. 
  23629.  
  23630.  Regular expressions are a context-independent syntax that can represent a wide 
  23631.  variety of character sets and character set orderings, which can be 
  23632.  interpreted differently depending on the current locale. The functions 
  23633.  regcomp, regerror, regexec, and regfree use regular expressions in a similar 
  23634.  way to the UNIX awk, ed, grep, and egrep commands. Regular expressions are 
  23635.  described in more detail under "Regular Expressions" in the Programming Guide. 
  23636.  
  23637.  Return Value 
  23638.  If regcomp is successful, it returns 0. Otherwise, it returns an error code 
  23639.  that you can use in a call to regerror, and the content of preg is undefined. 
  23640.  
  23641.  
  23642. ΓòÉΓòÉΓòÉ <hidden> Example of regcomp ΓòÉΓòÉΓòÉ
  23643.  
  23644. /************************************************************************
  23645.  
  23646. This example compiles an extended regular expression. 
  23647.  
  23648. ************************************************************************/
  23649.  
  23650. #include <regex.h>
  23651. #include <stdio.h>
  23652. #include <stdlib.h>
  23653.  
  23654. int main(void)
  23655. {
  23656.    regex_t preg;
  23657.    char    *pattern = ".*(simple).*";
  23658.    int     rc;
  23659.  
  23660.    if (0 != (rc = regcomp(&preg, pattern, REG_EXTENDED))) {
  23661.       printf("regcomp() failed, returning nonzero (%d)\n", rc);
  23662.       exit(EXIT_FAILURE);
  23663.    }
  23664.    printf("regcomp() is sucessful.\n");
  23665.    return 0;
  23666.  
  23667.    /****************************************************************************
  23668.       The output should be similar to :
  23669.  
  23670.       regcomp() is sucessful.
  23671.    ****************************************************************************/
  23672. }
  23673.  
  23674.  
  23675. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23676.  
  23677. Example of regcomp 
  23678.  
  23679.      regerror - Return Error Message for Regular Expression 
  23680.      regexec - Execute Compiled Regular Expression 
  23681.      regfree - Free Memory for Regular Expression 
  23682.      "Regular Expressions" in the Programming Guide 
  23683.      <regex.h> 
  23684.  
  23685.  
  23686. ΓòÉΓòÉΓòÉ 4.234. regerror - Return Error Message for Regular Expression ΓòÉΓòÉΓòÉ
  23687.  
  23688.  
  23689. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23690.  
  23691. #include <regex.h>
  23692. size_t regerror(int errcode,  const regex_t *preg,
  23693.                 char *errbuf, size_t errbuf_size);
  23694.  
  23695.  
  23696. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23697.  
  23698. Language Level:  POSIX, XPG4 
  23699.  
  23700. regerror finds the description for the error code errcode for the regular 
  23701. expression preg. The description for errcode is assigned to errbuf. errbuf_size 
  23702. is a value that you provide that specifies the maximum message size that can be 
  23703. stored (the size of errbuf). 
  23704.  
  23705. Regular expressions are described in detail under "Regular Expressions" in the 
  23706. Programming Guide. 
  23707.  
  23708. The description strings for errcode are: 
  23709.  
  23710.  errcode             Description String 
  23711.  REG_NOMATCH         RE pattern not found 
  23712.  REG_BADPAT          Invalid regular expression 
  23713.  REG_ECOLLATE        Invalid collating element 
  23714.  REG_ECTYPE          Invalid character class 
  23715.  REG_EESCAPE         Last character is \ 
  23716.  REG_ESUBREG         Invalid number in \digit 
  23717.  REG_EBRACK          [] imbalance 
  23718.  REG_EPAREN          \( \) or () imbalance 
  23719.  REG_EBRACE          \{ \} or { } imbalance 
  23720.  REG_BADBR           Invalid \{ \} range exp 
  23721.  REG_ERANGE          Invalid range exp endpoint 
  23722.  REG_ESPACE          Out of memory 
  23723.  REG_BADRPT          ?*+ not preceded by valid RE 
  23724.  REG_ECHAR           Invalid multibyte character 
  23725.  REG_EBOL            ^ anchor and not BOL 
  23726.  REG_EEOL            $ anchor and not EOL 
  23727.  
  23728.  The error descriptions are in the IBMCRERR.MSG message file. The directory for 
  23729.  this file must be in your DPATH environment variable for the messages to be 
  23730.  found. 
  23731.  
  23732.  Return Value 
  23733.  regerror returns the size of the buffer needed to hold the string that 
  23734.  describes the error condition. 
  23735.  
  23736.  
  23737. ΓòÉΓòÉΓòÉ <hidden> Example of regerror ΓòÉΓòÉΓòÉ
  23738.  
  23739. /************************************************************************
  23740.  
  23741. This example compiles an invalid regular expression, and prints an error 
  23742. message using regerror. 
  23743.  
  23744. ************************************************************************/
  23745.  
  23746. #include <regex.h>
  23747. #include <stdio.h>
  23748. #include <stdlib.h>
  23749.  
  23750. int main(void)
  23751. {
  23752.    regex_t preg;
  23753.    char    *pattern = "a[missing.bracket";
  23754.    int     rc;
  23755.    char    buffer[100];
  23756.  
  23757.    if (0 != (rc = regcomp(&preg, pattern, REG_EXTENDED))) {
  23758.       regerror(rc, &preg, buffer, 100);
  23759.       printf("regcomp() failed with '%s'\n", buffer);
  23760.       exit(EXIT_FAILURE);
  23761.    }
  23762.    return 0;
  23763.  
  23764.    /****************************************************************************
  23765.       The output should be similar to :
  23766.  
  23767.       regcomp() failed with '[] imbalance'
  23768.    ****************************************************************************/
  23769. }
  23770.  
  23771.  
  23772. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23773.  
  23774. Example of regerror 
  23775.  
  23776.      regcomp - Compile Regular Expression 
  23777.      regexec - Execute Compiled Regular Expression 
  23778.      regfree - Free Memory for Regular Expression 
  23779.      "Regular Expressions" in the Programming Guide 
  23780.      <regex.h> 
  23781.  
  23782.  
  23783. ΓòÉΓòÉΓòÉ 4.235. regexec - Execute Compiled Regular Expression ΓòÉΓòÉΓòÉ
  23784.  
  23785.  
  23786. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23787.  
  23788. #include <regex.h>
  23789. int regexec(const regex_t *preg, const char *string,
  23790.             size_t nmatch, regmatch_t *pmatch, int eflags);
  23791.  
  23792.  
  23793. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23794.  
  23795. Language Level:  POSIX, XPG4 
  23796.  
  23797. regexec compares the null-terminated string against the compiled regular 
  23798. expression preg to find a match between the two. (Regular expressions are 
  23799. described in "Regular Expressions" in the Programming Guide.) 
  23800.  
  23801. nmatch is the number of substrings in string that regexec should try to match 
  23802. with subexpressions in preg. The array you supply for pmatch must have at least 
  23803. nmatch elements. 
  23804.  
  23805. regexec fills in the elements of the array pmatch with offsets of the 
  23806. substrings in string that correspond to the parenthesized subexpressions of the 
  23807. original pattern given to regcomp to create preg. The zeroth element of the 
  23808. array corresponds to the entire pattern.  If there are more than nmatch 
  23809. subexpressions, only the first nmatch - 1 are stored. If nmatch is 0, or if the 
  23810. REG_NOSUB flag was set when preg was created with regcomp, regexec ignores the 
  23811. pmatch argument. 
  23812.  
  23813. The eflags flag defines customizable behavior of regexec: 
  23814.  
  23815.  REG_NOTBOL 
  23816.       Indicates that the first character of string is not the beginning of 
  23817.       line. 
  23818.  
  23819.  REG_NOTEOL 
  23820.       Indicates that the first character of string is not the end of line. 
  23821.  
  23822.  When a basic or extended regular expression is matched, any given 
  23823.  parenthesized subexpression of the original pattern could participate in the 
  23824.  match of several different substrings of string. The following rules determine 
  23825.  which substrings are reported in pmatch.: 
  23826.  
  23827.    1. If a subexpression participated in a match several times, regexec stores 
  23828.       the offset of the last matching substring in pmatch. 
  23829.  
  23830.    2. If a subexpression did not match in the source string, regexec sets the 
  23831.       offset shown in pmatch to -1. 
  23832.  
  23833.    3. If a subexpression contains subexpressions, the data in pmatch refers to 
  23834.       the last such subexpression. 
  23835.  
  23836.    4. If a subexpression matches a zero-length string, the offsets in pmatch 
  23837.       refer to the byte immediately following the matching string. 
  23838.  
  23839.  If the REG_NOSUB flag was set when preg was created by regcomp, the contents 
  23840.  of pmatch are unspecified. If the REG_NEWLINE flag was not set when preg was 
  23841.  created, new-line characters are allowed in string. 
  23842.  
  23843.  Note:  If MB_CUR_MAX is specified as 2, the charmap file does not specify the 
  23844.  DBCS characters, and a collating element (for example, [:a:]) is specified in 
  23845.  the pattern, the DBCS characters will not match against the collating-element 
  23846.  even if they have an equivalent weight to the collating-element. 
  23847.  
  23848.  Return Value 
  23849.  If a match is found, regexec returns 0. Otherwise, it returns a nonzero value 
  23850.  indicating either no match or an error. 
  23851.  
  23852.  
  23853. ΓòÉΓòÉΓòÉ <hidden> Example of regexec ΓòÉΓòÉΓòÉ
  23854.  
  23855. /************************************************************************
  23856.  
  23857. This example compiles an expression and matches a string against it. The first 
  23858. substring uses the full pattern. The second substring uses the sub-expression 
  23859. inside the full pattern. 
  23860.  
  23861. ************************************************************************/
  23862.  
  23863. #include <regex.h>
  23864. #include <stdio.h>
  23865. #include <stdlib.h>
  23866.  
  23867. int main(void)
  23868. {
  23869.    regex_t    preg;
  23870.    char       *string = "a very simple simple simple string";
  23871.    char       *pattern = "\\(sim[a-z]le\\) \\1";
  23872.    int        rc;
  23873.    size_t     nmatch = 2;
  23874.    regmatch_t pmatch[2];
  23875.  
  23876.    if (0 != (rc = regcomp(&preg, pattern, 0))) {
  23877.       printf("regcomp() failed, returning nonzero (%d)\n", rc);
  23878.       exit(EXIT_FAILURE);
  23879.    }
  23880.  
  23881.    if (0 != (rc = regexec(&preg, string, nmatch, pmatch, 0))) {
  23882.       printf("Failed to match '%s' with '%s',returning %d.\n",
  23883.       string, pattern, rc);
  23884.    }
  23885.    else {
  23886.       printf("With the whole expression, "
  23887.              "a matched substring \"%.*s\" is found at position %d to %d.\n",
  23888.              pmatch[0].rm_eo - pmatch[0].rm_so, &string[pmatch[0].rm_so],
  23889.              pmatch[0].rm_so, pmatch[0].rm_eo - 1);
  23890.       printf("With the sub-expression, "
  23891.              "a matched substring \"%.*s\" is found at position %d to %d.\n",
  23892.              pmatch[1].rm_eo - pmatch[1].rm_so, &string[pmatch[1].rm_so],
  23893.              pmatch[1].rm_so, pmatch[1].rm_eo - 1);
  23894.    }
  23895.    regfree(&preg);
  23896.    return 0;
  23897.  
  23898.    /****************************************************************************
  23899.       The output should be similar to :
  23900.  
  23901.       With the whole expression, a matched substring "simple simple" is found
  23902.       at position 7 to 19.
  23903.       With the sub-expression, a matched substring "simple" is found
  23904.       at position 7 to 12.
  23905.    ****************************************************************************/
  23906. }
  23907.  
  23908.  
  23909. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23910.  
  23911. Example of regexec 
  23912.  
  23913.      regcomp - Compile Regular Expression 
  23914.      regerror - Return Error Message for Regular Expression 
  23915.      regfree - Free Memory for Regular Expression 
  23916.      "Regular Expressions" in the Programming Guide 
  23917.      <regex.h> 
  23918.  
  23919.  
  23920. ΓòÉΓòÉΓòÉ 4.236. regfree - Free Memory for Regular Expression ΓòÉΓòÉΓòÉ
  23921.  
  23922.  
  23923. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23924.  
  23925. #include <regex.h>
  23926. void regfree(regex_t *preg);
  23927.  
  23928.  
  23929. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23930.  
  23931. Language Level:  POSIX, XPG4 
  23932.  
  23933. regfree frees any memory that was allocated by regcomp to implement the regular 
  23934. expression preg. After the call to regfree, the expression defined by preg is 
  23935. no longer a compiled regular or extended expression. 
  23936.  
  23937. Regular expressions are described in "Regular Expressions" in the Programming 
  23938. Guide. 
  23939.  
  23940. Return Value 
  23941. There is no return value. 
  23942.  
  23943.  
  23944. ΓòÉΓòÉΓòÉ <hidden> Example of regfree ΓòÉΓòÉΓòÉ
  23945.  
  23946. /************************************************************************
  23947.  
  23948. This example compiles an extended regular expression and frees it. 
  23949.  
  23950. ************************************************************************/
  23951.  
  23952. #include <regex.h>
  23953. #include <stdio.h>
  23954. #include <stdlib.h>
  23955.  
  23956. int main(void)
  23957. {
  23958.    regex_t    preg;
  23959.    char       *pattern = ".*(simple).*";
  23960.    int        rc;
  23961.  
  23962.    if (0 != (rc = regcomp(&preg, pattern, REG_EXTENDED))) {
  23963.       printf("regcomp() failed, returning nonzero (%d)\n", rc);
  23964.       exit(EXIT_FAILURE);
  23965.    }
  23966.    regfree(&preg);
  23967.    printf("Memory allocated for reg is freed.\n");
  23968.    return 0;
  23969.  
  23970.    /****************************************************************************
  23971.       The output should be similar to :
  23972.  
  23973.       Memory allocated for reg is freed.
  23974.    ****************************************************************************/
  23975. }
  23976.  
  23977.  
  23978. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  23979.  
  23980. Example of regfree 
  23981.  
  23982.      regcomp - Compile Regular Expression 
  23983.      regerror - Return Error Message for Regular Expression 
  23984.      regexec - Execute Compiled Regular Expression 
  23985.      "Regular Expressions" in the Programming Guide 
  23986.      <regex.h> 
  23987.  
  23988.  
  23989. ΓòÉΓòÉΓòÉ 4.237. remove - Delete File ΓòÉΓòÉΓòÉ
  23990.  
  23991.  
  23992. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  23993.  
  23994. #include <stdio.h>
  23995. int remove(const char *filename);
  23996.  
  23997.  
  23998. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  23999.  
  24000. Language Level: ANSI, SAA, POSIX, XPG4 
  24001.  
  24002. remove deletes the file specified by filename. 
  24003.  
  24004. Note:  You cannot remove a nonexistent file or a file that is open. 
  24005.  
  24006. Return Value 
  24007. remove returns 0 if it successfully deletes the file. A nonzero return value 
  24008. idicates an error. 
  24009.  
  24010.  
  24011. ΓòÉΓòÉΓòÉ <hidden> Example of remove ΓòÉΓòÉΓòÉ
  24012.  
  24013. /************************************************************************
  24014.  
  24015. This example uses remove to remove a file. It issues a message if an error 
  24016. occurs. 
  24017.  
  24018. ************************************************************************/
  24019.  
  24020. #include <stdio.h>
  24021.  
  24022. int main(void)
  24023. {
  24024.    char *FileName = "file2rm.mjq";
  24025.    FILE *fp;
  24026.  
  24027.    fp = fopen(FileName, "w");
  24028.    fprintf(fp, "Hello world\n");
  24029.    fclose(fp);
  24030.    if (remove(FileName) != 0)
  24031.       perror("Could not remove file");
  24032.    else
  24033.       printf("File \"%s\" removed successfully.\n", FileName);
  24034.    return 0;
  24035.  
  24036.    /****************************************************************************
  24037.       The output should be:
  24038.  
  24039.       File "file2rm.mjq" removed successfully.
  24040.    ****************************************************************************/
  24041. }
  24042.  
  24043.  
  24044. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  24045.  
  24046. Example of remove 
  24047.  
  24048.      fopen - Open Files 
  24049.      rename - Rename File 
  24050.      _rmtmp - Remove Temporary Files 
  24051.      unlink - Delete File 
  24052.      <stdio.h> 
  24053.  
  24054.  
  24055. ΓòÉΓòÉΓòÉ 4.238. rename - Rename File ΓòÉΓòÉΓòÉ
  24056.  
  24057.  
  24058. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  24059.  
  24060. #include <stdio.h>  /* also in <io.h> */
  24061. int rename(const char *oldname, const char *newname);
  24062.  
  24063.  
  24064. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  24065.  
  24066. Language Level: ANSI, SAA, POSIX, XPG4 
  24067.  
  24068. rename renames the file specified by oldname to the name given by newname. The 
  24069. oldname pointer must specify the name of an existing file. The newname pointer 
  24070. must not specify the name of an existing file. Both oldname and newname must be 
  24071. on the same drive; you cannot rename files across drives. You cannot rename a 
  24072. file with the name of an existing file. You also cannot rename an open file. 
  24073.  
  24074. Return Value 
  24075. rename returns 0 if successful. On an error, it returns a nonzero value. 
  24076.  
  24077.  
  24078. ΓòÉΓòÉΓòÉ <hidden> Example of rename ΓòÉΓòÉΓòÉ
  24079.  
  24080. /************************************************************************
  24081.  
  24082. This example uses rename to rename a file. It issues a message if errors occur. 
  24083.  
  24084. ************************************************************************/
  24085.  
  24086. #include <stdio.h>
  24087.  
  24088. int main(void)
  24089. {
  24090.    char *OldName = "oldfile.mjq";
  24091.    char *NewName = "newfile.mjq";
  24092.    FILE *fp;
  24093.  
  24094.    fp = fopen(OldName, "w");
  24095.    fprintf(fp, "Hello world\n");
  24096.    fclose(fp);
  24097.    if (rename(OldName, NewName) != 0)
  24098.       perror("Could not rename file");
  24099.    else
  24100.       printf("File \"%s\" is renamed to \"%s\".\n", OldName, NewName);
  24101.    return 0;
  24102.  
  24103.    /****************************************************************************
  24104.       The output should be:
  24105.  
  24106.       File "oldfile.mjq" is renamed to "newfile.mjq".
  24107.    ****************************************************************************/
  24108. }
  24109.  
  24110.  
  24111. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  24112.  
  24113. Example of rename 
  24114.  
  24115.      fopen - Open Files 
  24116.      remove - Delete File 
  24117.      <stdio.h> 
  24118.  
  24119.  
  24120. ΓòÉΓòÉΓòÉ 4.239. rewind - Adjust Current File Position ΓòÉΓòÉΓòÉ
  24121.  
  24122.  
  24123. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  24124.  
  24125. #include <stdio.h>
  24126. void rewind(FILE *stream);
  24127.  
  24128.  
  24129. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  24130.  
  24131. Language Level: ANSI, SAA, POSIX, XPG4 
  24132.  
  24133. rewind repositions the file pointer associated with stream to the beginning of 
  24134. the file. A call to rewind is the same as: 
  24135.  
  24136.    (void)fseek(stream, 0L, SEEK_SET);
  24137.  
  24138. except that rewind also clears the error indicator for the stream. 
  24139.  
  24140. Return Value 
  24141. There is no return value. 
  24142.  
  24143.  
  24144. ΓòÉΓòÉΓòÉ <hidden> Example of rewind ΓòÉΓòÉΓòÉ
  24145.  
  24146. /************************************************************************
  24147.  
  24148. This example first opens a file myfile.dat for input and output.  It writes 
  24149. integers to the file, uses rewind to reposition the file pointer to the 
  24150. beginning of the file, and then reads the data back in. 
  24151.  
  24152. ************************************************************************/
  24153.  
  24154. #include <stdio.h>
  24155.  
  24156. FILE *stream;
  24157. int data1,data2,data3,data4;
  24158.  
  24159. int main(void)
  24160. {
  24161.    data1 = 1;
  24162.    data2 = -37;
  24163.  
  24164.        /* Place data in the file                                              */
  24165.  
  24166.    stream = fopen("myfile.dat", "w+");
  24167.    fprintf(stream, "%d %d\n", data1, data2);
  24168.  
  24169.        /* Now read the data file                                              */
  24170.  
  24171.    rewind(stream);
  24172.    fscanf(stream, "%d", &data3);
  24173.    fscanf(stream, "%d", &data4);
  24174.    printf("The values read back in are: %d and %d\n", data3, data4);
  24175.    return 0;
  24176.  
  24177.    /****************************************************************************
  24178.       The output should be:
  24179.  
  24180.       The values read back in are: 1 and -37
  24181.    ****************************************************************************/
  24182. }
  24183.  
  24184.  
  24185. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  24186.  
  24187. Example of rewind 
  24188.  
  24189.      fgetpos - Get File Position 
  24190.      fseek - Reposition File Position 
  24191.      fsetpos - Set File Position 
  24192.      ftell - Get Current Position 
  24193.      lseek - Move File Pointer 
  24194.      _tell - Get Pointer Position 
  24195.      <stdio.h> 
  24196.  
  24197.  
  24198. ΓòÉΓòÉΓòÉ 4.240. rmdir - Remove Directory ΓòÉΓòÉΓòÉ
  24199.  
  24200.  
  24201. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  24202.  
  24203. #include <direct.h>
  24204. int rmdir(char *pathname);
  24205.  
  24206.  
  24207. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  24208.  
  24209. Language Level:  XPG4, Extension 
  24210.  
  24211. rmdir deletes the directory specified by pathname.  The directory must be 
  24212. empty, and it must not be the current working directory or the root directory. 
  24213.  
  24214. Note:  In earlier releases of C Set ++, rmdir began with an underscore 
  24215. (_rmdir). Because it is defined by the X/Open standard, the underscore has been 
  24216. removed. For compatibility, VisualAge C++ will map _rmdir to rmdir for you. 
  24217.  
  24218. Return Value 
  24219. rmdir returns the value 0 if the directory is successfully deleted. A return 
  24220. value of -1 indicates an error, and errno is set to one of the following 
  24221. values: 
  24222.  
  24223.  Value          Meaning 
  24224.  
  24225.  EACCESS        One of the following has occurred: 
  24226.  
  24227.                     The given path name is not a directory. 
  24228.                     The directory is not empty. 
  24229.                     The directory is read only. 
  24230.                     The directory is the current working directory or root 
  24231.                      directory being used by a process. 
  24232.  
  24233.  ENOENT         The path name was not found. 
  24234.  
  24235.  
  24236. ΓòÉΓòÉΓòÉ <hidden> Example of rmdir ΓòÉΓòÉΓòÉ
  24237.  
  24238. /************************************************************************
  24239.  
  24240. This example deletes two directories: one in the root directory, and the other 
  24241. in the current working directory. 
  24242.  
  24243. ************************************************************************/
  24244.  
  24245. #include <stdio.h>
  24246. #include <direct.h>
  24247. #include <string.h>
  24248.  
  24249. int main(void)
  24250. {
  24251.    char *dir1,*dir2;
  24252.  
  24253.  /*  Create the directory "aleng" in the root directory of the C: drive.      */
  24254.  
  24255.    dir1 = "c:\\aleng";
  24256.    if (0 == (mkdir(dir1)))
  24257.       printf("%s directory was created.\n", dir1);
  24258.    else
  24259.       printf("%s directory was not created.\n", dir1);
  24260.  
  24261.  /*  Create the subdirectory "simon" in the current directory.                */
  24262.  
  24263.    dir2 = "simon";
  24264.    if (0 == (mkdir(dir2)))
  24265.       printf("%s directory was created.\n", dir2);
  24266.    else
  24267.       printf("%s directory was not created.\n", dir2);
  24268.  
  24269.  /*  Remove the directory "aleng" from the root directory of the C: drive.    */
  24270.  
  24271.    printf("Removing directory 'aleng' from the root directory.\n");
  24272.    if (rmdir(dir1))
  24273.       perror(NULL);
  24274.    else
  24275.       printf("%s directory was removed.\n", dir1);
  24276.  
  24277.  /*  Remove the subdirectory "simon" from the current directory.              */
  24278.  
  24279.    printf("Removing subdirectory 'simon' from the current directory.\n");
  24280.    if (rmdir(dir2))
  24281.       perror(NULL);
  24282.    else
  24283.       printf("%s directory was removed.\n", dir2);
  24284.    return 0;
  24285.  
  24286.    /****************************************************************************
  24287.       The output should be:
  24288.  
  24289.       c:\aleng directory was created.
  24290.       simon directory was created.
  24291.       Removing directory 'aleng' from the root directory.
  24292.       c:\aleng directory was removed.
  24293.       Removing subdirectory 'simon' from the current directory.
  24294.       simon directory was removed.
  24295.    ****************************************************************************/
  24296. }
  24297.  
  24298.  
  24299. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  24300.  
  24301. Example of rmdir 
  24302.  
  24303.      chdir - Change Current Working Directory 
  24304.      _getdcwd - Get Full Path Name of Current Directory 
  24305.      _getcwd - Get Path Name of Current Directory 
  24306.      mkdir - Create New Directory 
  24307.      <direct.h> 
  24308.  
  24309.  
  24310. ΓòÉΓòÉΓòÉ 4.241. _rmem_init - Initialize Memory Functions for Subsystem DLL ΓòÉΓòÉΓòÉ
  24311.  
  24312.  
  24313. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  24314.  
  24315. int _rmem_init(void);
  24316. /* no header file - defined in runtime startup code */
  24317.  
  24318.  
  24319. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  24320.  
  24321. Language Level:  Extension 
  24322.  
  24323. _rmem_init initializes the memory functions for subsystem DLLs.  Although 
  24324. subsystems do not require a runtime environment (and therefore do not call 
  24325. _CRT_init), they do require the library memory functions. For DLLs that do use 
  24326. a runtime environment, the memory functions are initialized with the 
  24327. environment by _CRT_init. 
  24328.  
  24329. By default, all DLLs call the VisualAge C++ _DLL_InitTerm function, which in 
  24330. turn calls _rmem_init for you. However, if you are writing your own subsystem 
  24331. _DLL_InitTerm function (for example, to perform actions other than memory 
  24332. initialization and termination), you must call _rmem_init from your version of 
  24333. _DLL_InitTerm before you can call any other library functions. 
  24334.  
  24335. If your DLL contains C++ code, you must also call __ctordtorInit after 
  24336. _rmem_init to ensure that static constructors and destructors are initialized 
  24337. properly.  __ctordtorInit is defined in the runtime startup code as: 
  24338.  
  24339.    void __ctordtorInit(void);
  24340.  
  24341. Return Value 
  24342. If the memory functions were successfully initialized, _rmem_init returns 0. A 
  24343. return code of -1 indicates an error. If an error occurs, an error message is 
  24344. written to file handle 2, which is the usual destination of stderr. 
  24345.  
  24346.  
  24347. ΓòÉΓòÉΓòÉ <hidden> Example of _rmem_init ΓòÉΓòÉΓòÉ
  24348.  
  24349. /************************************************************************
  24350.  
  24351. This example shows the _DLL_InitTerm function from the VisualAge C++ sample 
  24352. program for building subsystem DLLs, which calls _rmem_init to initialize the 
  24353. memory functions. 
  24354.  
  24355. ************************************************************************/
  24356.  
  24357. #pragma strings( readonly )
  24358. /******************************************************************************/
  24359. /*                                                                            */
  24360. /* _DLL_InitTerm - Initialization/Termination function for the DLL that is    */
  24361. /*                 invoked by the loader.  When the /Ge- compile option is    */
  24362. /*                 used the linker is told that this is the function to       */
  24363. /*                 execute when the DLL is first loaded and last freed for    */
  24364. /*                 each process.                                              */
  24365. /*                                                                            */
  24366. /* DLLREGISTER  - Called by _DLL_InitTerm for each process that loads the     */
  24367. /*                DLL.                                                        */
  24368. /*                                                                            */
  24369. /* DLLDEREGISTER- Called by _DLL_InitTerm for each process that frees the     */
  24370. /*                DLL.                                                        */
  24371. /*                                                                            */
  24372. /******************************************************************************/
  24373.  
  24374. #define  INCL_DOS
  24375. #define  INCL_DOSERRORS
  24376. #define  INCL_NOPMAPI
  24377. #include <os2.h>
  24378. #include <stdio.h>
  24379.  
  24380. unsigned long _System _DLL_InitTerm( unsigned long hModule, unsigned long ulFlag );
  24381.  
  24382. static unsigned long DLLREGISTER( void );
  24383. static unsigned long DLLDEREGISTER( void );
  24384.  
  24385. #define SHARED_SEMAPHORE_NAME "\\SEM32\\SAMPLE05\\DLL.LCK"
  24386.  
  24387. /* The following data will be per-process data.  It will not be shared among  */
  24388. /* different processes.                                                       */
  24389.  
  24390. static HMTX  hmtxSharedSem;    /* Shared semaphore                            */
  24391. static ULONG ulProcessTotal;   /* Total of increments for a process           */
  24392. static PID   pidProcess;       /* Process identifier                          */
  24393.  
  24394. /* This is the global data segment that is shared by every process.           */
  24395.  
  24396. #pragma data_seg( GLOBAL_SEG )
  24397.  
  24398. static ULONG ulProcessCount;                /* total number of processes      */
  24399.  
  24400. /* _DLL_InitTerm() - called by the loader for DLL initialization/termination  */
  24401. /* This function must return a non-zero value if successful and a zero value  */
  24402. /* if unsuccessful.                                                           */
  24403.  
  24404. unsigned long _DLL_InitTerm( unsigned long hModule, unsigned long ulFlag )
  24405.    {
  24406.    APIRET rc;
  24407.  
  24408.    /* If ulFlag is zero then initialization is required:                      */
  24409.    /*    If the shared memory pointer is NULL then the DLL is being loaded    */
  24410.    /*    for the first time so acquire the named shared storage for the       */
  24411.    /*    process control structures.  A linked list of process control        */
  24412.    /*    structures will be maintained.  Each time a new process loads this   */
  24413.    /*    DLL, a new process control structure is created and it is inserted   */
  24414.    /*    at the end of the list by calling DLLREGISTER.                       */
  24415.    /*                                                                         */
  24416.    /* If ulFlag is 1 then termination is required:                            */
  24417.    /*    Call DLLDEREGISTER which will remove the process control structure   */
  24418.    /*    and free the shared memory block from its virtual address space.     */
  24419.  
  24420.    switch( ulFlag )
  24421.       {
  24422.    case 0:
  24423.          if ( !ulProcessCount )
  24424.             {
  24425.             _rmem_init();
  24426.             /* Create the shared mutex semaphore.                             */
  24427.             if ( ( rc = DosCreateMutexSem( SHARED_SEMAPHORE_NAME,
  24428.                                            &hmtxSharedSem,
  24429.                                            0,
  24430.                                            FALSE ) ) != NO_ERROR )
  24431.                {
  24432.                printf( "DosCreateMutexSem rc = %lu\n", rc );
  24433.                return 0;
  24434.                }
  24435.             }
  24436.  
  24437.          /* Register the current process.                                     */
  24438.          if ( DLLREGISTER( ) )
  24439.             return 0;
  24440.          break;
  24441.  
  24442.       case 1:
  24443.          /* De-register the current process.                                  */
  24444.          if ( DLLDEREGISTER( ) )
  24445.             return 0;
  24446.  
  24447.          _rmem_term();
  24448.          break;
  24449.  
  24450.       default:
  24451.          return 0;
  24452.       }
  24453.  
  24454.    /* Indicate success.  Non-zero means success!!!                            */
  24455.  
  24456.    return 1;
  24457.    }
  24458.  
  24459. /* DLLREGISTER - Registers the current process so that it can use this        */
  24460. /*               subsystem.  Called by _DLL_InitTerm when the DLL is first    */
  24461. /*               loaded for the current process.                              */
  24462.  
  24463. static unsigned long DLLREGISTER( void )
  24464.    {
  24465.    APIRET rc;
  24466.    PTIB ptib;
  24467.    PPIB ppib;
  24468.  
  24469.    /* Get the address of the process and thread information blocks.           */
  24470.    if ( ( rc = DosGetInfoBlocks( &ptib, &ppib ) ) != NO_ERROR )
  24471.       {
  24472.       printf( "DosGetInfoBlocks rc = %lu\n", rc );
  24473.       return rc;
  24474.       }
  24475.  
  24476.    /* Open the shared mutex semaphore for this process.                       */
  24477.    if ( ( rc = DosOpenMutexSem( SHARED_SEMAPHORE_NAME,
  24478.                                 &hmtxSharedSem ) ) != NO_ERROR )
  24479.       {
  24480.       printf( "DosOpenMutexSem rc = %lu\n", rc );
  24481.       return rc;
  24482.       }
  24483.  
  24484.    /* Acquire the shared mutex semaphore.                                     */
  24485.    if ( ( rc = DosRequestMutexSem( hmtxSharedSem,
  24486.                                    SEM_INDEFINITE_WAIT ) ) != NO_ERROR )
  24487.       {
  24488.       printf( "DosRequestMutexSem rc = %lu\n", rc );
  24489.       DosCloseMutexSem( hmtxSharedSem );
  24490.       return rc;
  24491.       }
  24492.  
  24493.    /* Increment the count of processes registered.                            */
  24494.    ++ulProcessCount;
  24495.  
  24496.    /* Initialize the per-process data.                                        */
  24497.    ulProcessTotal = 0;
  24498.    pidProcess = ppib->pib_ulpid;
  24499.  
  24500.    /* Tell the user that the current process has been registered.             */
  24501.    printf( "\nProcess %lu has been registered.\n\n", pidProcess );
  24502.  
  24503.    /* Release the shared mutex semaphore.                                     */
  24504.    if ( ( rc = DosReleaseMutexSem( hmtxSharedSem ) ) != NO_ERROR )
  24505.       {
  24506.       printf( "DosReleaseMutexSem rc = %lu\n", rc );
  24507.       return rc;
  24508.       }
  24509.  
  24510.    return 0;
  24511.    }
  24512.  
  24513. /* DLLDEREGISTER - Deregisters the current process from this subsystem.       */
  24514. /*                 Called by _DLL_InitTerm when the DLL is freed for the      */
  24515. /*                 last time by the current process.                          */
  24516.  
  24517. static unsigned long DLLDEREGISTER( void )
  24518.    {
  24519.    APIRET rc;
  24520.  
  24521.    /* Acquire the shared mutex semaphore.                                     */
  24522.    if ( ( rc = DosRequestMutexSem( hmtxSharedSem,
  24523.                                    SEM_INDEFINITE_WAIT ) ) != NO_ERROR )
  24524.       {
  24525.       printf( "DosRequestMutexSem rc = %lu\n", rc );
  24526.       return rc;
  24527.       }
  24528.  
  24529.    /* Decrement the count of processes registered.                            */
  24530.    --ulProcessCount;
  24531.  
  24532.    /* Tell the user that the current process has been deregistered.           */
  24533.    printf( "\nProcess %lu has been deregistered.\n\n", pidProcess );
  24534.  
  24535.    /* Release the shared mutex semaphore.                                     */
  24536.    if ( ( rc = DosReleaseMutexSem( hmtxSharedSem ) ) != NO_ERROR )
  24537.       {
  24538.       printf( "DosReleaseMutexSem rc = %lu\n", rc );
  24539.       return rc;
  24540.       }
  24541.  
  24542.    /* Close the shared mutex semaphore for this process.                      */
  24543.    if ( ( rc = DosCloseMutexSem( hmtxSharedSem ) ) != NO_ERROR )
  24544.       {
  24545.       printf( "DosCloseMutexSem rc = %lu\n", rc );
  24546.       return rc;
  24547.       }
  24548.  
  24549.    return 0;
  24550.    }
  24551.  
  24552.  
  24553. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  24554.  
  24555. Example of _rmem_init 
  24556.  
  24557.      Building Subsystem DLLs in the Programming Guide 
  24558.      _CRT_init - Initialize DLL Runtime Environment 
  24559.      _CRT_term - Terminate DLL Runtime Environment 
  24560.      _DLL_InitTerm - Initialize and Terminate DLL Environment 
  24561.      _rmem_term - Terminate Memory Functions for Subsystem DLL 
  24562.      _tmem_init - Initialize Memory Functions for Subsystem DLL 
  24563.      _tmem_term - Terminate Memory Functions for Subsystem DLL 
  24564.  
  24565.  
  24566. ΓòÉΓòÉΓòÉ 4.242. _rmem_term - Terminate Memory Functions for Subsystem DLL ΓòÉΓòÉΓòÉ
  24567.  
  24568.  
  24569. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  24570.  
  24571. int _rmem_term(void);
  24572. /* no header file - defined in runtime startup code */
  24573.  
  24574.  
  24575. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  24576.  
  24577. Language Level:  Extension 
  24578.  
  24579. _rmem_term terminates the memory functions for subsystem DLLs.  It is only 
  24580. needed for DLLs where the runtime library is statically linked. 
  24581.  
  24582. By default, all DLLs call the VisualAge C++ _DLL_InitTerm function, which in 
  24583. turn calls _rmem_term for you. However, if you are writing your own 
  24584. _DLL_InitTerm function (for example, to perform actions other than memory 
  24585. initialization and termination), and your DLL statically links to the C runtime 
  24586. libraries, you need to call _rmem_term from your subsystem _DLL_InitTerm 
  24587. function. (For DLLs with a runtime environment, this termination is done by 
  24588. _CRT_term.) 
  24589.  
  24590. If your DLL contains C++ code, you must also call __ctordtorTerm before you 
  24591. call _rmem_term to ensure that static constructors and destructors are 
  24592. terminated correctly. __ctordtorTerm is defined in the runtime startup code as: 
  24593.  
  24594.    void __ctordtorTerm(void);
  24595.  
  24596. Once you have called _rmem_term, you cannot call any other library functions. 
  24597.  
  24598. If your DLL is dynamically linked, you cannot call library functions in the 
  24599. termination section of your _DLL_InitTerm function. If your termination routine 
  24600. requires calling library functions, you must register the termination routine 
  24601. with DosExitList. Note that all DosExitList routines are called before DLL 
  24602. termination routines. 
  24603.  
  24604. Return Value 
  24605. _rmem_term returns 0 if the memory functions were successfully terminated. A 
  24606. return value of -1 indicates an error. 
  24607.  
  24608.  
  24609. ΓòÉΓòÉΓòÉ <hidden> Example of _rmem_term ΓòÉΓòÉΓòÉ
  24610.  
  24611. /************************************************************************
  24612.  
  24613. This example shows the _DLL_InitTerm function from the VisualAge C++ sample 
  24614. program for building subsystem DLLs, which calls _rmem_term to terminate the 
  24615. library memory functions. 
  24616.  
  24617. ************************************************************************/
  24618.  
  24619. #pragma strings( readonly )
  24620. /******************************************************************************/
  24621. /*                                                                            */
  24622. /* _DLL_InitTerm - Initialization/Termination function for the DLL that is    */
  24623. /*                 invoked by the loader.  When the /Ge- compile option is    */
  24624. /*                 used the linker is told that this is the function to       */
  24625. /*                 execute when the DLL is first loaded and last freed for    */
  24626. /*                 each process.                                              */
  24627. /*                                                                            */
  24628. /* DLLREGISTER  - Called by _DLL_InitTerm for each process that loads the     */
  24629. /*                DLL.                                                        */
  24630. /*                                                                            */
  24631. /* DLLDEREGISTER- Called by _DLL_InitTerm for each process that frees the     */
  24632. /*                DLL.                                                        */
  24633. /*                                                                            */
  24634. /******************************************************************************/
  24635.  
  24636. #define  INCL_DOS
  24637. #define  INCL_DOSERRORS
  24638. #define  INCL_NOPMAPI
  24639. #include <os2.h>
  24640. #include <stdio.h>
  24641.  
  24642. unsigned long _System _DLL_InitTerm( unsigned long hModule, unsigned long ulFlag );
  24643.  
  24644. static unsigned long DLLREGISTER( void );
  24645. static unsigned long DLLDEREGISTER( void );
  24646.  
  24647. #define SHARED_SEMAPHORE_NAME "\\SEM32\\SAMPLE05\\DLL.LCK"
  24648.  
  24649. /* The following data will be per-process data.  It will not be shared among  */
  24650. /* different processes.                                                       */
  24651.  
  24652. static HMTX  hmtxSharedSem;    /* Shared semaphore                            */
  24653. static ULONG ulProcessTotal;   /* Total of increments for a process           */
  24654. static PID   pidProcess;       /* Process identifier                          */
  24655.  
  24656. /* This is the global data segment that is shared by every process.           */
  24657.  
  24658. #pragma data_seg( GLOBAL_SEG )
  24659.  
  24660. static ULONG ulProcessCount;                /* total number of processes      */
  24661.  
  24662. /* _DLL_InitTerm() - called by the loader for DLL initialization/termination  */
  24663. /* This function must return a non-zero value if successful and a zero value  */
  24664. /* if unsuccessful.                                                           */
  24665.  
  24666. unsigned long _DLL_InitTerm( unsigned long hModule, unsigned long ulFlag )
  24667.    {
  24668.    APIRET rc;
  24669.  
  24670.    /* If ulFlag is zero then initialization is required:                      */
  24671.    /*    If the shared memory pointer is NULL then the DLL is being loaded    */
  24672.    /*    for the first time so acquire the named shared storage for the       */
  24673.    /*    process control structures.  A linked list of process control        */
  24674.    /*    structures will be maintained.  Each time a new process loads this   */
  24675.    /*    DLL, a new process control structure is created and it is inserted   */
  24676.    /*    at the end of the list by calling DLLREGISTER.                       */
  24677.    /*                                                                         */
  24678.    /* If ulFlag is 1 then termination is required:                            */
  24679.    /*    Call DLLDEREGISTER which will remove the process control structure   */
  24680.    /*    and free the shared memory block from its virtual address space.     */
  24681.  
  24682.    switch( ulFlag )
  24683.       {
  24684.    case 0:
  24685.          if ( !ulProcessCount )
  24686.             {
  24687.             _rmem_init();
  24688.             /* Create the shared mutex semaphore.                             */
  24689.             if ( ( rc = DosCreateMutexSem( SHARED_SEMAPHORE_NAME,
  24690.                                            &hmtxSharedSem,
  24691.                                            0,
  24692.                                            FALSE ) ) != NO_ERROR )
  24693.                {
  24694.                printf( "DosCreateMutexSem rc = %lu\n", rc );
  24695.                return 0;
  24696.                }
  24697.             }
  24698.  
  24699.          /* Register the current process.                                     */
  24700.          if ( DLLREGISTER( ) )
  24701.             return 0;
  24702.          break;
  24703.  
  24704.       case 1:
  24705.          /* De-register the current process.                                  */
  24706.          if ( DLLDEREGISTER( ) )
  24707.             return 0;
  24708.  
  24709.          _rmem_term();
  24710.          break;
  24711.  
  24712.       default:
  24713.          return 0;
  24714.       }
  24715.  
  24716.    /* Indicate success.  Non-zero means success!!!                            */
  24717.  
  24718.    return 1;
  24719.    }
  24720.  
  24721. /* DLLREGISTER - Registers the current process so that it can use this        */
  24722. /*               subsystem.  Called by _DLL_InitTerm when the DLL is first    */
  24723. /*               loaded for the current process.                              */
  24724.  
  24725. static unsigned long DLLREGISTER( void )
  24726.    {
  24727.    APIRET rc;
  24728.    PTIB ptib;
  24729.    PPIB ppib;
  24730.  
  24731.    /* Get the address of the process and thread information blocks.           */
  24732.    if ( ( rc = DosGetInfoBlocks( &ptib, &ppib ) ) != NO_ERROR )
  24733.       {
  24734.       printf( "DosGetInfoBlocks rc = %lu\n", rc );
  24735.       return rc;
  24736.       }
  24737.  
  24738.    /* Open the shared mutex semaphore for this process.                       */
  24739.    if ( ( rc = DosOpenMutexSem( SHARED_SEMAPHORE_NAME,
  24740.                                 &hmtxSharedSem ) ) != NO_ERROR )
  24741.       {
  24742.       printf( "DosOpenMutexSem rc = %lu\n", rc );
  24743.       return rc;
  24744.       }
  24745.  
  24746.    /* Acquire the shared mutex semaphore.                                     */
  24747.    if ( ( rc = DosRequestMutexSem( hmtxSharedSem,
  24748.                                    SEM_INDEFINITE_WAIT ) ) != NO_ERROR )
  24749.       {
  24750.       printf( "DosRequestMutexSem rc = %lu\n", rc );
  24751.       DosCloseMutexSem( hmtxSharedSem );
  24752.       return rc;
  24753.       }
  24754.  
  24755.    /* Increment the count of processes registered.                            */
  24756.    ++ulProcessCount;
  24757.  
  24758.    /* Initialize the per-process data.                                        */
  24759.    ulProcessTotal = 0;
  24760.    pidProcess = ppib->pib_ulpid;
  24761.  
  24762.    /* Tell the user that the current process has been registered.             */
  24763.    printf( "\nProcess %lu has been registered.\n\n", pidProcess );
  24764.  
  24765.    /* Release the shared mutex semaphore.                                     */
  24766.    if ( ( rc = DosReleaseMutexSem( hmtxSharedSem ) ) != NO_ERROR )
  24767.       {
  24768.       printf( "DosReleaseMutexSem rc = %lu\n", rc );
  24769.       return rc;
  24770.       }
  24771.  
  24772.    return 0;
  24773.    }
  24774.  
  24775. /* DLLDEREGISTER - Deregisters the current process from this subsystem.       */
  24776. /*                 Called by _DLL_InitTerm when the DLL is freed for the      */
  24777. /*                 last time by the current process.                          */
  24778.  
  24779. static unsigned long DLLDEREGISTER( void )
  24780.    {
  24781.    APIRET rc;
  24782.  
  24783.    /* Acquire the shared mutex semaphore.                                     */
  24784.    if ( ( rc = DosRequestMutexSem( hmtxSharedSem,
  24785.                                    SEM_INDEFINITE_WAIT ) ) != NO_ERROR )
  24786.       {
  24787.       printf( "DosRequestMutexSem rc = %lu\n", rc );
  24788.       return rc;
  24789.       }
  24790.  
  24791.    /* Decrement the count of processes registered.                            */
  24792.    --ulProcessCount;
  24793.  
  24794.    /* Tell the user that the current process has been deregistered.           */
  24795.    printf( "\nProcess %lu has been deregistered.\n\n", pidProcess );
  24796.  
  24797.    /* Release the shared mutex semaphore.                                     */
  24798.    if ( ( rc = DosReleaseMutexSem( hmtxSharedSem ) ) != NO_ERROR )
  24799.       {
  24800.       printf( "DosReleaseMutexSem rc = %lu\n", rc );
  24801.       return rc;
  24802.       }
  24803.  
  24804.    /* Close the shared mutex semaphore for this process.                      */
  24805.    if ( ( rc = DosCloseMutexSem( hmtxSharedSem ) ) != NO_ERROR )
  24806.       {
  24807.       printf( "DosCloseMutexSem rc = %lu\n", rc );
  24808.       return rc;
  24809.       }
  24810.  
  24811.    return 0;
  24812.    }
  24813.  
  24814.  
  24815. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  24816.  
  24817. Example of _rmem_term 
  24818.  
  24819.      Building Subsystem DLLs in the Programming Guide 
  24820.      _CRT_init - Initialize DLL Runtime Environment 
  24821.      _CRT_term - Terminate DLL Runtime Environment 
  24822.      _DLL_InitTerm - Initialize and Terminate DLL Environment 
  24823.      _rmem_init - Initialize Memory Functions for Subsystem DLL 
  24824.      _tmem_init - Initialize Memory Functions for Subsystem DLL 
  24825.      _tmem_term - Terminate Memory Functions for Subsystem DLL 
  24826.  
  24827.  
  24828. ΓòÉΓòÉΓòÉ 4.243. _rmtmp - Remove Temporary Files ΓòÉΓòÉΓòÉ
  24829.  
  24830.  
  24831. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  24832.  
  24833. #include <stdio.h>
  24834. int _rmtmp(void);
  24835.  
  24836.  
  24837. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  24838.  
  24839. Language Level:  Extension 
  24840.  
  24841. _rmtmp closes and deletes all temporary files in all directories that are held 
  24842. open by the calling process. 
  24843.  
  24844. Return Value 
  24845. _rmtmp returns the number of temporary files deleted. 
  24846.  
  24847.  
  24848. ΓòÉΓòÉΓòÉ <hidden> Example of _rmtmp ΓòÉΓòÉΓòÉ
  24849.  
  24850. /************************************************************************
  24851.  
  24852. This example uses _rmtmp to remove a number of temporary files. 
  24853.  
  24854. ************************************************************************/
  24855.  
  24856. #include <stdio.h>
  24857.  
  24858. int main(void)
  24859. {
  24860.    int num;
  24861.    FILE *stream;
  24862.  
  24863.    if (NULL == (stream = tmpfile()))
  24864.       printf("Could not open new temporary file\n");
  24865.    else {
  24866.       num = _rmtmp();
  24867.       printf("Number of temporary files removed = %d\n", num);
  24868.    }
  24869.    return 0;
  24870.  
  24871.    /****************************************************************************
  24872.       The output should be:
  24873.  
  24874.       Number of temporary files removed = 1
  24875.    ****************************************************************************/
  24876. }
  24877.  
  24878.  
  24879. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  24880.  
  24881. Example of _rmtmp 
  24882.  
  24883.      _flushall - Write Buffers to Files 
  24884.      remove - Delete File 
  24885.      tmpfile - Create Temporary File 
  24886.      tmpnam - Produce Temporary File Name 
  24887.      unlink - Delete File 
  24888.      <stdio.h> 
  24889.  
  24890.  
  24891. ΓòÉΓòÉΓòÉ 4.244. _rotl - _rotr - Rotate Bits of Unsigned Integer ΓòÉΓòÉΓòÉ
  24892.  
  24893.  
  24894. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  24895.  
  24896. #include <stdlib.h>   /* also in <builtin.h> */
  24897. unsigned int _rotl(unsigned int value, int shift);
  24898. unsigned int _rotr(unsigned int value, int shift);
  24899.  
  24900.  
  24901. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  24902.  
  24903. Language Level:  Extension 
  24904.  
  24905. These functions take a 4-byte integer value and rotate it by shift bits. _rotl 
  24906. rotates to the left, and _rotr to the right. 
  24907.  
  24908. Note:  Both _rotl and _rotr are built-in functions, which means they are 
  24909.        implemented as inline instructions and have no backing code in the 
  24910.        library. For this reason: 
  24911.  
  24912.      You cannot take the address of these functions. 
  24913.      You cannot parenthesize a call to either function. (Parentheses specify a 
  24914.       call to the backing code for the function in the runtime library.) 
  24915.  
  24916.  Portability Consideration  Because the size of an int is only 2 bytes in 
  24917.  16-bit compilers, if you are migrating 16-bit programs, some parts of your 
  24918.  programs may have to be rewritten if they use this function. 
  24919.  
  24920.  Return Value 
  24921.  Both functions return the rotated value.  There is no error return. 
  24922.  
  24923.  
  24924. ΓòÉΓòÉΓòÉ <hidden> Example of _rotl - _rotr ΓòÉΓòÉΓòÉ
  24925.  
  24926. /************************************************************************
  24927.  
  24928. This example uses _rotr and _rotl with different shift values to rotate the 
  24929. integer value 0x01234567: 
  24930.  
  24931. ************************************************************************/
  24932.  
  24933. #include <stdio.h>
  24934. #include <stdlib.h>
  24935.  
  24936. int main(void)
  24937. {
  24938.    unsigned int val = 0X01234567;
  24939.  
  24940.    printf("The value of 0x%8.8lx rotated 4 bits to the left is 0x%8.8lx\n", val,
  24941.       _rotl(val, 4));
  24942.    printf("The value of 0x%8.8lx rotated 16 bits to the right is 0x%8.8lx\n",
  24943.       val, _rotr(val, 16));
  24944.    return 0;
  24945.  
  24946.    /****************************************************************************
  24947.       The output should be:
  24948.  
  24949.       The value of 0x01234567 rotated 4 bits to the left is 0x12345670
  24950.       The value of 0x01234567 rotated 16 bits to the right is 0x45670123
  24951.    ****************************************************************************/
  24952. }
  24953.  
  24954.  
  24955. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  24956.  
  24957. Example of _rotl - _rotr 
  24958.  
  24959.      _crotl - _crotr - Rotate Bits of Character Value 
  24960.      _lrotl - _lrotr - Rotate Bits of Unsigned Long Value 
  24961.      _srotl - _srotr - Rotate Bits of Unsigned Short Value 
  24962.      swab - Swap Adjacent Bytes 
  24963.      <builtin.h> 
  24964.      <stdlib.h> 
  24965.  
  24966.  
  24967. ΓòÉΓòÉΓòÉ 4.245. rpmatch - Test for Yes/No Response Match ΓòÉΓòÉΓòÉ
  24968.  
  24969.  
  24970. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  24971.  
  24972. #include <stdlib.h>
  24973. int rpmatch(const char *response);
  24974.  
  24975.  
  24976. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  24977.  
  24978. Language Level:  POSIX, Extension 
  24979.  
  24980. rpmatch tests whether the string pointed to by response matches either the 
  24981. affirmative or the negative response set by LC_MESSAGES category in the current 
  24982. locale. 
  24983.  
  24984. Return Value 
  24985. rpmatch returns: 
  24986.  
  24987.  1    If the response string matches the affirmative expression. 
  24988.  0    If the response string matches the negative expression. 
  24989.  -1   If the response string does not match either the affirmative or the 
  24990.       negative expression. 
  24991.  
  24992.  
  24993. ΓòÉΓòÉΓòÉ <hidden> Example of rpmatch ΓòÉΓòÉΓòÉ
  24994.  
  24995. /************************************************************************
  24996.  
  24997. This example asks for a reply, and checks the response. 
  24998.  
  24999. ************************************************************************/
  25000.  
  25001. #include <stdlib.h>
  25002. #include <stdio.h>
  25003.  
  25004. int main(void)
  25005. {
  25006.    char  *response;
  25007.    char  buffer[100];
  25008.    int   rc;
  25009.  
  25010.    printf("Enter reply:\n");
  25011.    response = fgets(buffer, 100, stdin);
  25012.    rc = rpmatch(response);
  25013.    if (rc > 0)
  25014.       printf("Response was affirmative\n");
  25015.    else if (rc == 0)
  25016.            printf("Response was negative\n");
  25017.         else
  25018.            printf("Response was neither negative or affirmative\n");
  25019.    return 0;
  25020.  
  25021.    /****************************************************************************
  25022.       Assuming you enter : No
  25023.  
  25024.       The output should be :
  25025.  
  25026.       Response was negative
  25027.    ****************************************************************************/
  25028. }
  25029.  
  25030.  
  25031. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  25032.  
  25033. Example of rpmatch 
  25034.  
  25035.      setlocale - Set Locale 
  25036.      <stdlib.h> 
  25037.  
  25038.  
  25039. ΓòÉΓòÉΓòÉ 4.246. scanf - Read Data ΓòÉΓòÉΓòÉ
  25040.  
  25041.  
  25042. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  25043.  
  25044. #include <stdio.h>
  25045. int scanf(const char *format-string, argument-list);
  25046.  
  25047.  
  25048. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  25049.  
  25050. Language Level: ANSI, ANSI 93, SAA, POSIX, XPG4, Extension 
  25051.  
  25052. scanf reads data from the standard input stream stdin into the locations given 
  25053. by each entry in argument-list.  Each argument must be a pointer to a variable 
  25054. with a type that corresponds to a type specifier in format-string. The 
  25055. format-string controls the interpretation of the input fields. 
  25056.  
  25057. The format-string can contain one or more of the following: 
  25058.  
  25059.      White-space characters, as specified by isspace (such as blanks and 
  25060.       new-line characters). A white-space character causes scanf to read, but 
  25061.       not to store, all consecutive white-space characters in the input up to 
  25062.       the next character that is not white space.  One white-space character in 
  25063.       format-string matches any combination of white-space characters in the 
  25064.       input. 
  25065.  
  25066.      Characters that are not white space, except for the percent sign 
  25067.       character (%).  A non-white-space character causes scanf to read, but not 
  25068.       to store, a matching non-white-space character.  If the next character in 
  25069.       stdin does not match, scanf ends. 
  25070.  
  25071.      Format specifications, introduced by the percent sign (%).  A format 
  25072.       specification causes scanf to read and convert characters in the input 
  25073.       into values of a specified type.  The value is assigned to an argument in 
  25074.       the argument list. 
  25075.  
  25076.  scanf reads format-string from left to right.  Characters outside of format 
  25077.  specifications are expected to match the sequence of characters in stdin;  the 
  25078.  matched characters in stdin are scanned but not stored.  If a character in 
  25079.  stdin conflicts with format-string, scanf ends.  The conflicting character is 
  25080.  left in stdin as if it had not been read. 
  25081.  
  25082.  When the first format specification is found, the value of the first input 
  25083.  field is converted according to the format specification and stored in the 
  25084.  location specified by the first entry in argument-list.  The second format 
  25085.  specification converts the second input field and stores it in the second 
  25086.  entry in argument-list, and so on through the end of format-string. 
  25087.  
  25088.  An input field is defined as all characters up to the first white-space 
  25089.  character (space, tab, or new line), up to the first character that cannot be 
  25090.  converted according to the format specification, or until the field width is 
  25091.  reached, whichever comes first.  If there are too many arguments for the 
  25092.  format specifications, the extra arguments are ignored.  The results are 
  25093.  undefined if there are not enough arguments for the format specifications. 
  25094.  
  25095.  A format specification has the following form: 
  25096.  
  25097.   ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  25098.   Γöé                                        Γöé
  25099.   Γöé >>ΓöÇΓöÇ%ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇtypeΓöÇΓöÇ><                   Γöé
  25100.   Γöé     ΓööΓöÇ*ΓöÇΓöÿ  ΓööΓöÇwidthΓöÇΓöÿ  Γö£ΓöÇhΓöÇΓöñ                        Γöé
  25101.   Γöé              Γö£ΓöÇlΓöÇΓöñ                        Γöé
  25102.   Γöé              ΓööΓöÇLΓöÇΓöÿ                        Γöé
  25103.   Γöé                                        Γöé
  25104.   ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  25105.  
  25106.  Each field of the format specification is a single character or a number 
  25107.  signifying a particular format option.  The type character, which appears 
  25108.  after the last optional format field, determines whether the input field is 
  25109.  interpreted as a character, a string, or a number.  The simplest format 
  25110.  specification contains only the percent sign and a type character (for 
  25111.  example, %s). 
  25112.  
  25113.  The fields of the format specification are discussed in scanf Format 
  25114.  Specification Fields and scanf Format Specification - Types. If a percent sign 
  25115.  (%) is followed by a character that has no meaning as a format control 
  25116.  character, that character and following characters up to the next percent sign 
  25117.  are treated as an ordinary sequence of characters;  that is, a sequence of 
  25118.  characters that must match the input.  For example, to specify a percent-sign 
  25119.  character, use %%. 
  25120.  
  25121.  scanf scans each input field character by character.  It might stop reading a 
  25122.  particular input field either before it reaches a space character, when the 
  25123.  specified width is reached, or when the next character cannot be converted as 
  25124.  specified.  When a conflict occurs between the specification and the input 
  25125.  character, the next input field begins at the first unread character.  The 
  25126.  conflicting character, if there was one, is considered unread and is the first 
  25127.  character of the next input field or the first character in subsequent read 
  25128.  operations on stdin. 
  25129.  
  25130.  In extended mode, scanf also reads in the strings the strings "INFINITY", 
  25131.  "INF", and "NAN" (in upper or lowercase) and converts them to the 
  25132.  corresponding floating-point value.  The sign of the value is determined by 
  25133.  the format specification. See Infinity and NaN Support for more information on 
  25134.  infinity and NaN values. 
  25135.  
  25136.  Return Value 
  25137.  scanf returns the number of fields that were successfully converted and 
  25138.  assigned. The return value does not include fields that were read but not 
  25139.  assigned. 
  25140.  
  25141.  The return value is EOF for an attempt to read at end-of-file if no conversion 
  25142.  was performed. A return value of 0 means that no fields were assigned. 
  25143.  
  25144.  
  25145. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  25146.  
  25147. scanf Example 1 
  25148.  
  25149. scanf Example 2 
  25150.  
  25151.      scanf Format Specification Fields 
  25152.      scanf Format Specification - Types 
  25153.      fscanf - Read Formatted Data 
  25154.      printf - Print Formatted Characters 
  25155.      sscanf - Read Data 
  25156.      Infinity and NaN Support 
  25157.      <stdio.h> 
  25158.  
  25159.  
  25160. ΓòÉΓòÉΓòÉ 4.246.1. scanf Format Specification Fields ΓòÉΓòÉΓòÉ
  25161.  
  25162. The scanf format specification fields are described below. The type field is 
  25163. described in scan Format Specification - Types. 
  25164.  
  25165.  * 
  25166.     An asterisk (*) following the percent sign suppresses assignment of the 
  25167.     next input field, which is interpreted as a field of the specified type. 
  25168.     The field is scanned but not stored. 
  25169.  
  25170.  width 
  25171.     The width is a positive decimal integer controlling the maximum number of 
  25172.     characters to be read from stdin.  No more than width characters are 
  25173.     converted and stored at the corresponding argument.  Fewer than width 
  25174.     characters are read if a white-space character (space, tab, or new line), 
  25175.     or a character that cannot be converted according to the given format 
  25176.     occurs before width is reached. 
  25177.  
  25178.  h, l, L 
  25179.     The optional prefix l shows that you use the long version of the following 
  25180.     type, while the prefix h indicates that the short version is to be used. 
  25181.     The corresponding argument should point to a long or double object (for the 
  25182.     l character), a long double object (for the L character), or a short object 
  25183.     (with the h character).  The l and h modifiers can be used with the d, i, 
  25184.     o, x, and u type characters. The l modifier can also be used with the e, f, 
  25185.     and g type characters.  The L modifier can be used with the e, f and g type 
  25186.     characters. The l and h modifiers are ignored if specified for any other 
  25187.     type. Note that the l modifier is also used with the c and s characters to 
  25188.     indicate a multibyte character or string. 
  25189.  
  25190.  
  25191. ΓòÉΓòÉΓòÉ 4.246.2. scan Format Specification - Types ΓòÉΓòÉΓòÉ
  25192.  
  25193. The type characters and their meanings are in the following table: 
  25194.  
  25195. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  25196. Γöé CHAR- Γöé TYPE OF INPUT EXPECTED       Γöé TYPE OF ARGUMENT         Γöé
  25197. Γöé ACTER Γöé                  Γöé                  Γöé
  25198. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25199. Γöé "d"  Γöé Decimal integer          Γöé Pointer to INT          Γöé
  25200. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25201. Γöé "o"  Γöé Octal integer           Γöé Pointer to UNSIGNED INT      Γöé
  25202. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25203. Γöé "x",  Γöé Hexadecimal integer        Γöé Pointer to UNSIGNED INT      Γöé
  25204. Γöé "X"  Γöé                  Γöé                  Γöé
  25205. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25206. Γöé "i"  Γöé Decimal, hexadecimal, or octal   Γöé Pointer to INT          Γöé
  25207. Γöé    Γöé integer              Γöé                  Γöé
  25208. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25209. Γöé "u"  Γöé Unsigned decimal integer      Γöé Pointer to UNSIGNED INT      Γöé
  25210. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25211. Γöé "e,  Γöé Floating-point value consisting  Γöé Pointer to FLOAT         Γöé
  25212. Γöé f, g" Γöé of an optional sign (+ or -);  a  Γöé                  Γöé
  25213. Γöé    Γöé series of one or more decimal   Γöé                  Γöé
  25214. Γöé "E,  Γöé digits possibly containing a    Γöé                  Γöé
  25215. Γöé G"   Γöé decimal point;  and an optional  Γöé                  Γöé
  25216. Γöé    Γöé exponent (e or E) followed by a  Γöé                  Γöé
  25217. Γöé    Γöé possibly signed integer value.   Γöé                  Γöé
  25218. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25219. Γöé "c"  Γöé Character;  white-space charac-  Γöé Pointer to CHAR large enough for Γöé
  25220. Γöé    Γöé ters that are ordinarily skipped  Γöé input field            Γöé
  25221. Γöé    Γöé are read when "c" is specified   Γöé                  Γöé
  25222. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25223. Γöé "lc"  Γöé Multibyte characters.  The multi- Γöé Pointer to WCHAR_T large enough  Γöé
  25224. Γöé    Γöé byte characters are converted to  Γöé for input field          Γöé
  25225. Γöé    Γöé wide characters as if by a call  Γöé                  Γöé
  25226. Γöé    Γöé to mbrtowc.  The field width    Γöé                  Γöé
  25227. Γöé    Γöé specifies the number of wide    Γöé                  Γöé
  25228. Γöé    Γöé characters matched; if no width  Γöé                  Γöé
  25229. Γöé    Γöé is specified, one character is   Γöé                  Γöé
  25230. Γöé    Γöé matched.              Γöé                  Γöé
  25231. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25232. Γöé "s"  Γöé String               Γöé Pointer to character array large Γöé
  25233. Γöé    Γöé                  Γöé enough for input field plus a   Γöé
  25234. Γöé    Γöé                  Γöé terminating null character    Γöé
  25235. Γöé    Γöé                  Γöé ("\0"), which is automatically  Γöé
  25236. Γöé    Γöé                  Γöé appended             Γöé
  25237. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25238. Γöé "ls"  Γöé Multibyte string.  None of the   Γöé Pointer to WCHAR_T array large  Γöé
  25239. Γöé    Γöé characters can be single-byte   Γöé enough for the input field and  Γöé
  25240. Γöé    Γöé white-space characters (as speci- Γöé the terminating null wide char-  Γöé
  25241. Γöé    Γöé fied by the isspace function).   Γöé acter ("L\0"), which is added   Γöé
  25242. Γöé    Γöé Each multibyte character in the  Γöé automatically.          Γöé
  25243. Γöé    Γöé sequence is converted to a wide  Γöé                  Γöé
  25244. Γöé    Γöé character as if by a call to    Γöé                  Γöé
  25245. Γöé    Γöé mbrtowc.              Γöé                  Γöé
  25246. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25247. Γöé "n"  Γöé No input read from stream or    Γöé Pointer to INT, into which is   Γöé
  25248. Γöé    Γöé buffer               Γöé stored the number of characters  Γöé
  25249. Γöé    Γöé                  Γöé successfully read from the    Γöé
  25250. Γöé    Γöé                  Γöé stream or buffer up to that    Γöé
  25251. Γöé    Γöé                  Γöé point in the call to scanf    Γöé
  25252. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  25253. Γöé "p"  Γöé Pointer to "void" converted to   Γöé Pointer to "void"         Γöé
  25254. Γöé    Γöé series of characters        Γöé                  Γöé
  25255. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  25256.  
  25257. To read strings not delimited by space characters, substitute a set of 
  25258. characters in brackets ([ ]) for the s (string) type character.  The 
  25259. corresponding input field is read up to the first character that does not 
  25260. appear in the bracketed character set.  If the first character in the set is a 
  25261. caret (^), the effect is reversed:  the input field is read up to the first 
  25262. character that does appear in the rest of the character set. 
  25263.  
  25264. To store a string without storing an ending null character (\0), use the 
  25265. specification %ac, where a is a decimal integer.  In this instance, the c type 
  25266. character means that the argument is a pointer to a character array.  The next 
  25267. a characters are read from the input stream into the specified location, and no 
  25268. null character is added. 
  25269.  
  25270. The input for a %x format specifier is interpreted as a hexadecimal number. 
  25271.  
  25272.  
  25273. ΓòÉΓòÉΓòÉ <hidden> scanf Example 1 ΓòÉΓòÉΓòÉ
  25274.  
  25275. /************************************************************************
  25276.  
  25277. This example scans various types of data. 
  25278.  
  25279. ************************************************************************/
  25280.  
  25281. #include <stdio.h>
  25282.  
  25283. int main(void)
  25284. {
  25285.    int i;
  25286.    float fp;
  25287.    char c,s[81];
  25288.  
  25289.    printf("Enter an integer, a real number, a character and a string : \n");
  25290.    if (scanf("%d %f %c %s", &i, &fp, &c, s) != 4)
  25291.       printf("Not all of the fields were assigned\n");
  25292.    else {
  25293.       printf("integer = %d\n", i);
  25294.       printf("real number = %f\n", fp);
  25295.       printf("character = %c\n", c);
  25296.       printf("string = %s\n", s);
  25297.    }
  25298.    return 0;
  25299.  
  25300.    /****************************************************************************
  25301.       The output should be similar to:
  25302.  
  25303.       Enter an integer, a real number, a character and a string :
  25304.       12 2.5 a yes
  25305.       integer = 12
  25306.       real number = 2.500000
  25307.       character = a
  25308.       string = yes
  25309.    ****************************************************************************/
  25310. }
  25311.  
  25312.  
  25313. ΓòÉΓòÉΓòÉ <hidden> scanf Example 2 ΓòÉΓòÉΓòÉ
  25314.  
  25315. /************************************************************************
  25316. This example converts a hexadecimal integer to a decimal integer.  The while 
  25317. loop ends if the input value is not a hexadecimal integer. 
  25318.  
  25319. ************************************************************************/
  25320.  
  25321. #include <stdio.h>
  25322.  
  25323. int main(void)
  25324. {
  25325.    int number;
  25326.  
  25327.    printf("Enter a hexadecimal number or anything else to quit:\n");
  25328.    while (scanf("%x", &number)) {
  25329.       printf("Hexadecimal Number = %x\n", number);
  25330.       printf("Decimal Number     = %d\n", number);
  25331.    }
  25332.    return 0;
  25333.  
  25334.    /****************************************************************************
  25335.       The output should be similar to:
  25336.  
  25337.       Enter a hexadecimal number or anything else to quit:
  25338.       0x231
  25339.       Hexadecimal Number = 231
  25340.       Decimal Number     = 561
  25341.       0xf5e
  25342.       Hexadecimal Number = f5e
  25343.       Decimal Number     = 3934
  25344.       0x1
  25345.       Hexadecimal Number = 1
  25346.       Decimal Number     = 1
  25347.       q
  25348.    ****************************************************************************/
  25349. }
  25350.  
  25351.  
  25352. ΓòÉΓòÉΓòÉ 4.247. _searchenv - Search for File ΓòÉΓòÉΓòÉ
  25353.  
  25354.  
  25355. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  25356.  
  25357. #include <stdlib.h>
  25358. void _searchenv(char *name, char *env_var, char *path);
  25359.  
  25360.  
  25361. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  25362.  
  25363. Language Level:  Extension 
  25364.  
  25365. _searchenv searches for the target file in the specified domain.  The env_var 
  25366. variable can be any environment variable that specifies a list of directory 
  25367. paths, such as PATH, LIB, INCLUDE, or other user-defined variables.  Most 
  25368. often, it is PATH, causing a search for name in all directories specified in 
  25369. the PATH variable. 
  25370.  
  25371. The routine first searches for the file in the current working directory.  If 
  25372. it does not find the file, it next looks through the directories specified by 
  25373. the environment variable. 
  25374.  
  25375. If the target file is found in one of the directories, the fully-qualified file 
  25376. name is copied into the buffer that path points to. You must ensure sufficient 
  25377. space for the constructed file name. If the target file is not found, path 
  25378. contains an empty null-terminated string. 
  25379.  
  25380. Return Value 
  25381. There is no return value. 
  25382.  
  25383.  
  25384. ΓòÉΓòÉΓòÉ <hidden> Example of _searchenv ΓòÉΓòÉΓòÉ
  25385.  
  25386. /************************************************************************
  25387.  
  25388. This example searches for the files searchen.c and cmd.exe. 
  25389.  
  25390. ************************************************************************/
  25391.  
  25392. #include <stdio.h>
  25393. #include <stdlib.h>
  25394.  
  25395. int main(void)
  25396. {
  25397.    char path_buffer[_MAX_PATH];
  25398.  
  25399.    _searchenv("cmd.exe", "PATH", path_buffer);
  25400.    printf("path: %s\n", path_buffer);
  25401.    _searchenv("_searche.c", "DPATH", path_buffer);
  25402.    printf("path: %s\n", path_buffer);
  25403.    return 0;
  25404.  
  25405.    /****************************************************************************
  25406.       The output should be similar to:
  25407.  
  25408.       path: C:\OS2\cmd.exe
  25409.       path: C:\src\_searche.c
  25410.    ****************************************************************************/
  25411. }
  25412.  
  25413.  
  25414. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  25415.  
  25416. Example of _searchenv 
  25417.  
  25418.      getenv - Search for Environment Variables 
  25419.      putenv - Modify Environment Variables 
  25420.      <stdlib.h> 
  25421.  
  25422.  
  25423. ΓòÉΓòÉΓòÉ 4.248. setbuf - Control Buffering ΓòÉΓòÉΓòÉ
  25424.  
  25425.  
  25426. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  25427.  
  25428. #include <stdio.h>
  25429. void setbuf(FILE *stream, char *buffer);
  25430.  
  25431.  
  25432. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  25433.  
  25434. Language Level: ANSI, SAA, POSIX, XPG4 
  25435.  
  25436. setbuf controls buffering for the specified stream. The stream pointer must 
  25437. refer to an open file before any I/O or repositioning has been done. 
  25438.  
  25439. If the buffer argument is NULL, the stream is unbuffered. If not, the buffer 
  25440. must point to a character array of length BUFSIZ, which is the buffer size 
  25441. defined in the <stdio.h> include file. The system uses the buffer, which you 
  25442. specify, for input/output buffering instead of the default system-allocated 
  25443. buffer for the given stream. 
  25444.  
  25445. setvbuf is more flexible than setbuf. 
  25446.  
  25447. Note:  Under VisualAge C++, streams are fully buffered by default, with the 
  25448. exceptions of stderr, which is line-buffered, and memory files, which are 
  25449. unbuffered. 
  25450.  
  25451. Return Value 
  25452. There is no return value. 
  25453.  
  25454.  
  25455. ΓòÉΓòÉΓòÉ <hidden> Example of setbuf ΓòÉΓòÉΓòÉ
  25456.  
  25457. /************************************************************************
  25458.  
  25459. This example opens the file setbuf.dat for writing. It then calls setbuf to 
  25460. establish a buffer of length BUFSIZ. When string is written to the stream, the 
  25461. buffer buf is used and contains the string before it is flushed to the file. 
  25462.  
  25463. ************************************************************************/
  25464.  
  25465. #include <stdio.h>
  25466.  
  25467. #define FILENAME  "setbuf.dat"
  25468.  
  25469. int main(void)
  25470. {
  25471.    char buf[BUFSIZ];
  25472.    char string[] = "hello world";
  25473.    FILE *stream;
  25474.  
  25475.    memset(buf, '\0', BUFSIZ);           /* initialize buf to null characters  */
  25476.    stream = fopen(FILENAME, "wb");
  25477.    setbuf(stream, buf);                                   /* set up buffer    */
  25478.    fwrite(string, sizeof(string), 1, stream);
  25479.    printf("%s\n", buf);                   /* string is found in buf now       */
  25480.    fclose(stream);                  /* buffer is flushed out to output stream */
  25481.    return 0;
  25482.  
  25483.    /****************************************************************************
  25484.       The output file should contain:
  25485.  
  25486.       hello world
  25487.  
  25488.       The output should be:
  25489.  
  25490.       hello world
  25491.    ****************************************************************************/
  25492. }
  25493.  
  25494.  
  25495. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  25496.  
  25497. Example of setbuf 
  25498.  
  25499.      fclose - Close Stream 
  25500.      fflush - Write Buffer to File 
  25501.      _flushall - Write Buffers to Files 
  25502.      fopen - Open Files 
  25503.      setvbuf - Control Buffering 
  25504.      <stdio.h> 
  25505.  
  25506.  
  25507. ΓòÉΓòÉΓòÉ 4.249. _set_crt_msg_handle - Change Runtime Message Output Destination ΓòÉΓòÉΓòÉ
  25508.  
  25509.  
  25510. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  25511.  
  25512. #include <stdio.h>
  25513. int _set_crt_msg_handle(int fh);
  25514.  
  25515.  
  25516. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  25517.  
  25518. Language Level:  Extension 
  25519.  
  25520. _set_crt_msg_handle changes the file handle to which runtime messages are sent, 
  25521. which is usually file handle 2, to fh. Runtime messages include exception 
  25522. handling messages and output from debug memory management routines. 
  25523.  
  25524. Use _set_crt_msg_handle to trap runtime message output in applications where 
  25525. handle 2 is not defined, such as Presentation Manager applications. 
  25526.  
  25527. The file handle fh must be a writable file or pipe handle. Set fh only for the 
  25528. current library environment. 
  25529.  
  25530. Return Value 
  25531. _set_crt_msg_handle returns the handle to be used for runtime message output. 
  25532. If an handle that is not valid is passed as an argument, it is ignored and no 
  25533. change takes place. 
  25534.  
  25535.  
  25536. ΓòÉΓòÉΓòÉ <hidden> Example of _set_crt_msg_handle ΓòÉΓòÉΓòÉ
  25537.  
  25538. /************************************************************************
  25539.  
  25540. This example causes an exception by dereferencing a null pointer and uses 
  25541. _set_crt_msg_handle to send the exception messages to the file _scmhdl.out. 
  25542.  
  25543. ************************************************************************/
  25544.  
  25545. #include <sys\stat.h>
  25546. #include <io.h>
  25547. #include <fcntl.h>
  25548. #include <stdio.h>
  25549. #include <stdlib.h>
  25550.  
  25551. int main(void)
  25552. {
  25553.    int   fh;
  25554.    char  *p = NULL;
  25555.  
  25556.    if (-1 == (fh = open("_scmhdl.out", O_CREAT|O_TRUNC|O_RDWR,
  25557.                         S_IREAD|S_IWRITE))) {
  25558.       perror("Unable to open the file _scmhdl.out.");
  25559.       exit(EXIT_FAILURE);
  25560.    }
  25561.    /* change file handle where messages are sent */
  25562.    if (fh != _set_crt_msg_handle(fh)) {
  25563.       perror("Could not change massage output handle.");
  25564.       exit(EXIT_FAILURE);
  25565.    }
  25566.    *p = 'x';          /* cause an exception, output should be in _scmhdl.out */
  25567.    if (-1 == close(fh)) {
  25568.       perror("Unable to close _scmhdl.out.");
  25569.       exit(EXIT_FAILURE);
  25570.    }
  25571.    return 0;
  25572.  
  25573.    /****************************************************************************
  25574.       Running this program would cause an exception to occur,
  25575.       the file _scmhdl.out should contain the exception messages similar to :
  25576.  
  25577.       Exception = c0000005 occurred at EIP = 10068.
  25578.    ****************************************************************************/
  25579. }
  25580.  
  25581.  
  25582. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  25583.  
  25584. Example of _set_crt_msg_handle 
  25585.  
  25586.      open - Open File 
  25587.      fileno - Determine File Handle 
  25588.      _sopen - Open Shared File 
  25589.      <stdio.h> 
  25590.  
  25591.  
  25592. ΓòÉΓòÉΓòÉ 4.250. setjmp - Preserve Environment ΓòÉΓòÉΓòÉ
  25593.  
  25594.  
  25595. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  25596.  
  25597. #include <setjmp.h>
  25598. int setjmp(jmp_buf env);
  25599.  
  25600.  
  25601. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  25602.  
  25603. Language Level: ANSI, SAA, POSIX, XPG4 
  25604.  
  25605. setjmp saves a stack environment that can subsequently be restored by longjmp. 
  25606. setjmp and longjmp provide a way to perform a nonlocal goto. They are often 
  25607. used in signal handlers. 
  25608.  
  25609. A call to setjmp causes it to save the current stack environment in env.  A 
  25610. subsequent call to longjmp restores the saved environment and returns control 
  25611. to a point corresponding to the setjmp call.  The values of all variables 
  25612. (except register variables) accessible to the function receiving control 
  25613. contain the values they had when longjmp was called. The values of variables 
  25614. that are allocated to registers by the compiler are unpredictable. Because any 
  25615. auto variable could be allocated to a register in optimized code, you should 
  25616. consider the values of all auto variables to be unpredictable after a longjmp 
  25617. call. 
  25618.  
  25619. C++ Considerations  When you call setjmp in a C++ program, ensure that that 
  25620. part of the program does not also create C++ objects that need to be destroyed. 
  25621. When you call longjmp, objects existing at the time of the setjmp call will 
  25622. still exist, but any destructors called after setjmp are not called. Click here 
  25623. for an example. 
  25624.  
  25625. Return Value 
  25626. setjmp returns the value 0 after saving the stack environment. If setjmp 
  25627. returns as a result of a longjmp call, it returns the value argument of 
  25628. longjmp, or 1 if the value argument of longjmp is 0. There is no error return 
  25629. value. 
  25630.  
  25631.  
  25632. ΓòÉΓòÉΓòÉ <hidden> Example of setjmp ΓòÉΓòÉΓòÉ
  25633.  
  25634. /************************************************************************
  25635.  
  25636. This example stores the stack environment at the statement 
  25637.  
  25638.   if(setjmp(mark) != 0) ...
  25639.  
  25640. When the system first performs the if statement, it saves the environment in 
  25641. mark and sets the condition to FALSE because setjmp returns a 0 when it saves 
  25642. the environment. The program prints the message 
  25643.  
  25644.   setjmp has been called
  25645.  
  25646. The subsequent call to function p tests for a local error condition, which can 
  25647. cause it to perform the longjmp function. Then, control returns to the original 
  25648. setjmp function using the environment saved in mark. This time, the condition 
  25649. is TRUE because -1 is the return value from the longjmp function. The program 
  25650. then performs the statements in the block and prints 
  25651.  
  25652.   longjmp has been called
  25653.  
  25654. Then the program calls the recover function and exits. 
  25655.  
  25656. ************************************************************************/
  25657.  
  25658. #include <stdio.h>
  25659. #include <stdlib.h>
  25660. #include <setjmp.h>
  25661.  
  25662. jmp_buf mark;
  25663.  
  25664. void p(void)
  25665. {
  25666.    int error = 0;
  25667.  
  25668.    error = 9;
  25669.  
  25670.    if (error != 0)
  25671.       longjmp(mark, -1);
  25672. }
  25673.  
  25674. void recover(void)
  25675. {
  25676. }
  25677.  
  25678. int main(void)
  25679. {
  25680.    if (setjmp(mark) != 0) {
  25681.       printf("longjmp has been called\n");
  25682.       recover();
  25683.       return 0;
  25684.    }
  25685.    printf("setjmp has been called\n");
  25686.  
  25687.    p();
  25688.  
  25689.    return 0;
  25690.  
  25691.    /****************************************************************************
  25692.       The output should be:
  25693.  
  25694.       setjmp has been called
  25695.       longjmp has been called
  25696.    ****************************************************************************/
  25697. }
  25698.  
  25699.  
  25700. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  25701.  
  25702. Example of setjmp 
  25703.  
  25704.      longjmp - Restore Stack Environment 
  25705.      goto in the Language Reference 
  25706.      <setjmp.h> 
  25707.  
  25708.  
  25709. ΓòÉΓòÉΓòÉ 4.251. setlocale - Set Locale ΓòÉΓòÉΓòÉ
  25710.  
  25711.  
  25712. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  25713.  
  25714. #include <locale.h>
  25715. char *setlocale(int category, const char *locale);
  25716.  
  25717.  
  25718. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  25719.  
  25720. Language Level:  ANSI, SAA, POSIX, XPG4 
  25721.  
  25722. setlocale sets or queries the specified category of the program's locale. A 
  25723. locale is the complete definition of that part of a program that depends on 
  25724. language and cultural conventions. 
  25725.  
  25726. The default VisualAge C++ locale is the POSIX C locale definition, represented 
  25727. as "C" or "POSIX". This locale is standard for all ANSI-conforming and 
  25728. POSIX-conforming compilers. You can accept the default, or you can use 
  25729. setlocale to set the locale to one of the supplied locales listed in 
  25730. "Introduction to Locale" in the Programming Guide. 
  25731.  
  25732. Some examples of the supplied locales as you would specify them for setlocale 
  25733. are: 
  25734.  
  25735.       "En_GB.IBM-850" (English, Great Britain, code page 850) 
  25736.       "Fr_CA.IBM-863" (French, Canada, code page 863) 
  25737.       "Ja_JP.IBM-932" (Japanese, Japan, code page 932) 
  25738.  
  25739.  Note: 
  25740.  
  25741.    1. If you are already using the code page for one of these locales, you can 
  25742.       specify the locale name without the code page. For example, if you are 
  25743.       using code page 850, you can specify "En_GB" for the English Great 
  25744.       Britain locale. 
  25745.  
  25746.    2. In earlier versions of C Set ++, you could also specify locales using the 
  25747.       macros LC_C, LC_C_GERMANY, LC_C_FRANCE, LC_C_SPAIN, LC_C_ITALY, 
  25748.       LC_C_JAPAN, LC_C_USA, or LC_C_UK. These macros are provided only for 
  25749.       compatibility with earlier releases; you can still use these macros, but 
  25750.       the locales they specify are not POSIX locales. 
  25751.  
  25752.  The result of setlocale depends on the arguments you specify: 
  25753.  
  25754.      To set a category to a specific locale, specify both the category and 
  25755.       locale names.  For example: 
  25756.  
  25757.                setlocale(LC_CTYPE, "POSIX");
  25758.       sets the LC_CTYPE category according to the "POSIX" locale. The category 
  25759.       names and their purpose are described in Locale Categories for setlocale 
  25760.  
  25761.       If you specify a null string ("") for locale, setlocale checks 
  25762.       locale-related environment variables in the program's environment to find 
  25763.       a locale name or names to use for category.  If category is not LC_ALL, 
  25764.       setlocale gets the locale name from: 
  25765.  
  25766.         1. LC_ALL, if it is defined and not null 
  25767.         2. The environment variable with the same name as category, if it is 
  25768.            defined and not null 
  25769.         3. LANG, if it is defined and not null 
  25770.         4. If none of these variables is defined to a valid locale name, 
  25771.            setlocale uses the "C" locale. 
  25772.  
  25773.       For example, if the LC_ALL environment variable is set to "GERM" (Germany 
  25774.       locale): 
  25775.  
  25776.                setlocale(LC_TIME, "");
  25777.       sets the LC_TIME category to the "GERM" locale. 
  25778.  
  25779.       If category is LC_ALL and locale is a null string, setlocale checks the 
  25780.       environment variables in the same order listed above.  However, it checks 
  25781.       the variable for each category and sets the category to the locale 
  25782.       specified, which could be different for each category.  (By contrast, if 
  25783.       you specified LC_ALL and a specific locale name, all categories would be 
  25784.       set to the same locale that you specify.) The string returned lists all 
  25785.       the locales for all the categories. 
  25786.  
  25787.      To query the locale for a category, specify a null pointer for locale. 
  25788.       setlocale then returns a string indicating the locale setting for that 
  25789.       category, without changing it. For example: 
  25790.  
  25791.                char *s = setlocale(LC_CTYPE, NULL);
  25792.       returns the current locale for the LC_CTYPE category. 
  25793.  
  25794.  Return Value: 
  25795.  setlocale returns a string that specifies the locale for the category.  If you 
  25796.  specified "" for locale, the string names the current locale; otherwise, it 
  25797.  indicates the new locale that the category was set to. 
  25798.  
  25799.  If you specified LC_ALL for category, the returned string can be either a 
  25800.  single locale name or, if the individual categories have different locales, a 
  25801.  list of the locale names for each category in the following order: 
  25802.  
  25803.    1. LC_COLLATE 
  25804.    2. LC_CTYPE 
  25805.    3. LC_MONETARY 
  25806.    4. LC_NUMERIC 
  25807.    5. LC_TIME 
  25808.    6. LC_TOD 
  25809.    7. LC_MESSAGES 
  25810.    8. LC_SYNTAX 
  25811.  
  25812.  The string can be used on a subsequent call to restore that part of the 
  25813.  program's locale. Because the returned string can be overwritten by subsequent 
  25814.  calls to setlocale, you should copy the string if you plan to use it later. 
  25815.  
  25816.  If an error occurs, setlocale returns NULL and does not alter the program's 
  25817.  locale.  Errors can occur if the category or locale is not valid, or if the 
  25818.  value of the environment variable for a category does not contain a valid 
  25819.  locale. 
  25820.  
  25821.  
  25822. ΓòÉΓòÉΓòÉ <hidden> Example 1 of setlocale ΓòÉΓòÉΓòÉ
  25823.  
  25824. /************************************************************************
  25825.  
  25826. This example sets the locale of the program to be "fr_fr.ibm-850" and prints 
  25827. the string that is associated with the locale. 
  25828.  
  25829. ************************************************************************/
  25830.  
  25831. #include <stdio.h>
  25832. #include <locale.h>
  25833.  
  25834. int main(void)
  25835. {
  25836.    char *string;
  25837.  
  25838.    if (NULL == (string = setlocale(LC_ALL, "fr_fr.ibm-850")))
  25839.       printf("setlocale failed.\n");
  25840.    else
  25841.       printf("The current locale is set to %s.\n", string);
  25842.    return 0;
  25843.  
  25844.    /****************************************************************************
  25845.       The output should be similar to :
  25846.  
  25847.       The current locale is set to fr_fr.ibm-850.
  25848.    ****************************************************************************/
  25849. }
  25850.  
  25851.  
  25852. ΓòÉΓòÉΓòÉ <hidden> Example 2 of setlocale ΓòÉΓòÉΓòÉ
  25853.  
  25854. /************************************************************************
  25855.  
  25856. This example uses setenv to set the value of the environment variable LC_TIME 
  25857. to FRAN, calls setlocale to set all categories to default values, then query 
  25858. all categories, and uses printf to print results. 
  25859.  
  25860. ************************************************************************/
  25861.  
  25862. #include <locale.h>
  25863. #include <stdio.h>
  25864.  
  25865. int main(void)
  25866. {
  25867.    char *string;
  25868.  
  25869.    _putenv("LC_TIME=FRAN");
  25870.    if (NULL == (string = setlocale(LC_ALL, "")))
  25871.       printf("setlocale failed.\n");
  25872.    else
  25873.       printf("The current locale categories are: \"%s\"\n", string);
  25874.    return 0;
  25875.  
  25876.    /****************************************************************************
  25877.       The output should be similar to :
  25878.  
  25879.       The current locale categories are: "C,C,C,C,FRAN,C,C,C"
  25880.    ****************************************************************************/
  25881. }
  25882.  
  25883.  
  25884. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  25885.  
  25886. setlocale Example 1 
  25887.  
  25888. setlocale Example 2 
  25889.  
  25890.      Locale Categories for setlocale 
  25891.      "Introduction to Locale" in the Programming Guide 
  25892.      getenv - Search for Environment Variables 
  25893.      localeconv - Retrieve Information from the Environment 
  25894.      <locale.h> 
  25895.  
  25896.  
  25897. ΓòÉΓòÉΓòÉ 4.251.1. Locale Categories for setlocale ΓòÉΓòÉΓòÉ
  25898.  
  25899. You can set the category argument of setlocale to one of these values: 
  25900.  
  25901.  Category Purpose 
  25902.  
  25903.  LC_ALL 
  25904.     Specifies all categories associated with the program's locale. 
  25905.  
  25906.  LC_COLLATE 
  25907.     Defines the collation sequence, that is, the relative order of collation 
  25908.     elements (characters and multicharacter collation elements) in the 
  25909.     program's locale. The collation sequence definition is used by regular 
  25910.     expression, pattern matching, and sorting functions. Affects the regular 
  25911.     expression functions regcomp and regexec; the string functions strcoll, 
  25912.     strxfrm, wcscoll, and wcsxfrm; and the collating functions collequiv, 
  25913.     collorder, collrange, colltostr, ismccollel, maxcoll, and strtocoll. 
  25914.  
  25915.     Note:  Because both LC_CTYPE and LC_COLLATE modify the same storage area, 
  25916.     setting LC_CTYPE and LC_COLLATE to different categories causes 
  25917.     unpredictable results. 
  25918.  
  25919.  LC_CTYPE 
  25920.     Defines character classification and case conversion for characters in the 
  25921.     program's locale. Affects the behavior of character-handling functions 
  25922.     defined in the <ctype.h> header file: csid, isalnum, isalpha, isblank, 
  25923.     iswblank iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, 
  25924.     isupper, iswalnum, iswalpha, iswcntrl, iswctype, iswdigit, iswgraph, 
  25925.     iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit, isxdigit, 
  25926.     tolower, toupper, towlower, towupper, wcsid, and wctype. 
  25927.  
  25928.     Affects behavior of the printf and scanf families of functions: fprintf, 
  25929.     printf, sprintf, swprintf, vfprintf, vprintf, vsprintf, vswprintf; fscanf, 
  25930.     scanf, sscanf, and swscanf. 
  25931.  
  25932.     Affects the behavior of wide character input/output functions: fgetwc, 
  25933.     fgetws, getwc, getwchar, fputwc, fputws, putwc, putwchar, and ungetwc. 
  25934.  
  25935.     Affects the behavior of multibyte and wide character conversion functions: 
  25936.     mblen, mbrlen, mbrtowc, mbsrtowcs, mbstowcs, mbtowc, wcrtomb, wcsrtombs, 
  25937.     wcstod, wcstol, wcstombs, wcstoul, wcswidth, wctomb, and wcwidth. 
  25938.  
  25939.     Note:  Because both LC_CTYPE and LC_COLLATE modify the same storage area, 
  25940.     setting LC_CTYPE and LC_COLLATE to different categories causes 
  25941.     unpredictable results. 
  25942.  
  25943.  LC_MESSAGES 
  25944.     Under VisualAge C++, affects the values returned by nl_langinfo and also 
  25945.     defines affirmative and negative response patterns, which affect rpmatch. 
  25946.  
  25947.     LC_MESSAGES does not affect the messages for the following functions: 
  25948.     perror, strerror, _strerror, and regerror. 
  25949.  
  25950.  LC_MONETARY 
  25951.     Affects monetary information returned by localeconv and strfmon. It defines 
  25952.     the rules and symbols used to format monetary numeric information in the 
  25953.     program's locale. The formatting rules and symbols are strings. localeconv 
  25954.     returns pointers to these strings with names found in the <locale.h> header 
  25955.     file. 
  25956.  
  25957.  LC_NUMERIC 
  25958.     Affects the decimal-point character for the formatted input/output and 
  25959.     string conversion functions, and the nonmonetary formatting information 
  25960.     returned by the localeconv function, specifically: 
  25961.  
  25962.         printf family of functions 
  25963.         scanf family of functions 
  25964.         strtod 
  25965.         atof. 
  25966.  
  25967.  LC_TIME 
  25968.     Defines time and date format information in the program's locale, affecting 
  25969.     the strftime strptime, and wcsftime functions. 
  25970.  
  25971.  LC_SYNTAX 
  25972.     Affects the values that can be retrieved by the getsyntx function. It does 
  25973.     not affect the behavior of functions that are dependent on the encoded 
  25974.     values for formatting characters, as it may do on other platforms. 
  25975.  
  25976.  LC_TOD 
  25977.     Affects the behavior of the functions related to time zone and Daylight 
  25978.     Savings Time information in the program's locale. ctime, localtime, mktime, 
  25979.     setlocale, and strftime call the tzset function to override the LC_TOD 
  25980.     category information when TZ is defined and valid. 
  25981.  
  25982.  
  25983. ΓòÉΓòÉΓòÉ 4.252. _setmode - Set File Translation Mode ΓòÉΓòÉΓòÉ
  25984.  
  25985.  
  25986. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  25987.  
  25988. #include <fcntl.h>
  25989. #include <io.h>
  25990. int _setmode(int handle, int mode);
  25991.  
  25992.  
  25993. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  25994.  
  25995. Language Level: Extension 
  25996.  
  25997. _setmode sets the translation mode of the file given by handle to mode. The 
  25998. mode must be one of the values in the following table: 
  25999.  
  26000.  Value          Meaning 
  26001.  O_TEXT         Sets the translated text mode.  Carriage-return line-feed 
  26002.                 combinations are translated into a single line feed on input. 
  26003.                 Line-feed characters are translated into carriage-return 
  26004.                 line-feed combinations on output. 
  26005.  O_BINARY       Sets the binary (untranslated) mode.  The above translations 
  26006.                 are suppressed. 
  26007.  
  26008.  Use _setmode to change the translation mode of a file handle. The translation 
  26009.  mode only affects the read and write functions. _setmode does not affect the 
  26010.  translation mode of streams. 
  26011.  
  26012.  If a file handle is acquired other than by a call to open, creat, _sopen or 
  26013.  fileno, you should call _setmode for that file handle before using it within 
  26014.  the read or write functions. 
  26015.  
  26016.  Return Value 
  26017.  _setmode returns the previous translation mode if successful. A return value 
  26018.  of -1 indicates an error, and errno is set to one of the following values: 
  26019.  
  26020.  Value          Meaning 
  26021.  EBADF          The file handle is not a handle for an open file. 
  26022.  EINVAL         Incorrect mode (neither O_TEXT nor O_BINARY) 
  26023.  
  26024.  
  26025. ΓòÉΓòÉΓòÉ <hidden> Example of _setmode ΓòÉΓòÉΓòÉ
  26026.  
  26027. /************************************************************************
  26028.  
  26029. This example uses open to create the file setmode.dat and writes to it.  The 
  26030. program then uses _setmode to change the translation mode of setmode.dat from 
  26031. binary to text. 
  26032.  
  26033. ************************************************************************/
  26034.  
  26035. #include <stdio.h>
  26036. #include <stdlib.h>
  26037. #include <fcntl.h>
  26038. #include <io.h>
  26039. #include <sys\stat.h>
  26040.  
  26041. #define  FILENAME      "setmode.dat"
  26042.  
  26043. /* routine to validate return codes                                           */
  26044.  
  26045. void ckrc(int rc)
  26046. {
  26047.    if (-1 == rc) {
  26048.       printf("Unexpected return code = -1\n");
  26049.       remove(FILENAME);
  26050.       exit(EXIT_FAILURE);
  26051.    }
  26052. }
  26053.  
  26054. int main(void)
  26055. {
  26056.    int h;
  26057.    int xfer;
  26058.    int mode;
  26059.    char rbuf[256];
  26060.    char wbuf[] = "123\n456\n";
  26061.  
  26062.    ckrc(h = open(FILENAME, O_CREAT|O_RDWR|O_TRUNC|O_TEXT, S_IREAD|S_IWRITE));
  26063.    ckrc(write(h, wbuf, sizeof(wbuf)));     /* write the file (text)           */
  26064.    ckrc(lseek(h, 0, SEEK_SET));         /* seek back to the start of the file */
  26065.    ckrc(xfer = read(h, rbuf, 5));           /* read the file text             */
  26066.    printf("Read in %d characters (4 expected)\n", xfer);
  26067.    ckrc(mode = _setmode(h, O_BINARY));
  26068.    if (O_TEXT == mode)
  26069.       printf("Mode changed from binary to text\n");
  26070.    else
  26071.       printf("Previous mode was not text (unexpected)\n");
  26072.    ckrc(xfer = read(h, rbuf, 5));           /* read the file (binary)         */
  26073.    printf("Read in %d characters (5 expected)\n", xfer);
  26074.    ckrc(close(h));
  26075.    remove(FILENAME);
  26076.    return 0;
  26077.  
  26078.    /****************************************************************************
  26079.       The output should be:
  26080.  
  26081.       Read in 4 characters (4 expected)
  26082.       Mode changed from binary to text
  26083.       Read in 5 characters (5 expected)
  26084.    ****************************************************************************/
  26085. }
  26086.  
  26087.  
  26088. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  26089.  
  26090. Example of _setmode 
  26091.  
  26092.      creat - Create New File 
  26093.      open - Open File 
  26094.      _sopen - Open Shared File 
  26095.      read - Read Into Buffer 
  26096.      write - Writes from Buffer to File 
  26097.      <fcntl.h> 
  26098.      <io.h> 
  26099.      <share.h> 
  26100.      <sys\stat.h> 
  26101.  
  26102.  
  26103. ΓòÉΓòÉΓòÉ 4.253. setvbuf - Control Buffering ΓòÉΓòÉΓòÉ
  26104.  
  26105.  
  26106. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  26107.  
  26108. #include <stdio.h>
  26109. int setvbuf(FILE *stream, char *buf, int type, size_t size);
  26110.  
  26111.  
  26112. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  26113.  
  26114. Language Level: ANSI, SAA, XPG4 
  26115.  
  26116. setvbuf allows control over the buffering strategy and buffer size for a 
  26117. specified stream. The stream must refer to a file that has been opened, but not 
  26118. read or written to. 
  26119.  
  26120. The array pointed to by buf designates an area that you provide that the C 
  26121. library may choose to use as a buffer for the stream.  A buf value of NULL 
  26122. indicates that no such area is supplied and that the C library is to assume 
  26123. responsibility for managing its own buffers for the stream.  If you supply a 
  26124. buffer, it must exist until the stream is closed. 
  26125.  
  26126. The type must be one of the following: 
  26127.  
  26128.  Value       Meaning 
  26129.  _IONBF      No buffer is used. 
  26130.  _IOFBF      Full buffering is used for input and output. Use buf as the buffer 
  26131.              and size as the size of the buffer. 
  26132.  _IOLBF      Line buffering is used.  The buffer is flushed when a new-line 
  26133.              character is written, when the buffer is full, or when input is 
  26134.              requested. 
  26135.  
  26136.  If type is _IOFBF or _IOLBF, size is the size of the supplied buffer.  If buf 
  26137.  is NULL, the C library takes size as the suggested size for its own buffer. 
  26138.  If type is _IONBF, both buf and size are ignored. 
  26139.  
  26140.  The value for size must be greater than 0. 
  26141.  
  26142.  Return Value 
  26143.  setvbuf returns 0 if successful. It returns nonzero if an invalid value was 
  26144.  specified in the parameter list, or if the request cannot be performed. 
  26145.  
  26146.  Warning: The array used as the buffer must still exist when the specified 
  26147.  stream is closed. For example, if the buffer is declared within the scope of a 
  26148.  function block, the stream must be closed before the function is terminated 
  26149.  and frees the storage allocated to the buffer. 
  26150.  
  26151.  
  26152. ΓòÉΓòÉΓòÉ <hidden> Example of setvbuf ΓòÉΓòÉΓòÉ
  26153.  
  26154. /************************************************************************
  26155.  
  26156. This example sets up a buffer of buf for stream1 and specifies that input to 
  26157. stream2 is to be unbuffered. 
  26158.  
  26159. ************************************************************************/
  26160.  
  26161. #include <stdio.h>
  26162. #include <stdlib.h>
  26163.  
  26164. #define  BUF_SIZE      1024
  26165. #define  FILE1         "setvbuf1.dat"
  26166. #define  FILE2         "setvbuf2.dat"
  26167.  
  26168. char buf[BUF_SIZE];
  26169. FILE *stream1,*stream2;
  26170.  
  26171. int main(void)
  26172. {
  26173.    int flag = EXIT_SUCCESS;
  26174.  
  26175.    stream1 = fopen(FILE1, "r");
  26176.    stream2 = fopen(FILE2, "r");
  26177.  
  26178.    /* stream1 uses a user-assigned buffer of BUF_SIZE bytes                   */
  26179.  
  26180.    if (setvbuf(stream1, buf, _IOFBF, sizeof(buf)) != 0) {
  26181.       printf("Incorrect type or size of buffer\n");
  26182.       flag = EXIT_FAILURE;
  26183.    }
  26184.  
  26185.    /* stream2 is unbuffered                                                   */
  26186.  
  26187.    if (setvbuf(stream2, NULL, _IONBF, 0) != 0) {
  26188.       printf("Incorrect type or size of buffer\n");
  26189.       flag = EXIT_FAILURE;
  26190.    }
  26191.  
  26192.    fclose(stream1);
  26193.    fclose(stream2);
  26194.    return  flag;
  26195. }
  26196.  
  26197.  
  26198. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  26199.  
  26200. Example of setvbuf 
  26201.  
  26202.      fclose - Close Stream 
  26203.      fflush - Write Buffer to File 
  26204.      _flushall - Write Buffers to Files 
  26205.      fopen - Open Files 
  26206.      setbuf - Control Buffering 
  26207.      <stdio.h> 
  26208.  
  26209.  
  26210. ΓòÉΓòÉΓòÉ 4.254. signal - Handle Interrupt Signals ΓòÉΓòÉΓòÉ
  26211.  
  26212.  
  26213. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  26214.  
  26215. #include <signal.h>
  26216. void ( *signal(int sig, void (*sig_handler)(int)) )(int);
  26217.  
  26218.  
  26219. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  26220.  
  26221. Language Level:  ANSI, SAA, XPG4, Extension 
  26222.  
  26223. signal function assigns the signal handler sig_handler to handle the interrupt 
  26224. signal sig. Signals can be reported as a result of a machine interrupt (for 
  26225. example, division by zero) or by an explicit request to report a signal by 
  26226. using the raise function. 
  26227.  
  26228. The sig argument must be one of the signal constants defined in <signal.h>: 
  26229.  
  26230.  Value           Meaning 
  26231.  SIGABRT         Abnormal termination signal sent by abort. Default action: end 
  26232.                  the program. 
  26233.  SIGBREAK        Ctrl-Break signal. Default action: end the program. 
  26234.  SIGFPE          Floating-point exceptions that are not masked, such as 
  26235.                  overflow, division by zero, and invalid operation.  Default 
  26236.                  action: end the program and provide an error message. If 
  26237.                  machine-state dumps are enabled (with the /Tx compiler 
  26238.                  option), a dump is also provided. 
  26239.  SIGILL          Instruction not allowed.  Default action: end the program and 
  26240.                  provide an error message. If machine-state dumps are enabled 
  26241.                  (with the /Tx compiler option), a dump is also provided. 
  26242.  SIGINT          Ctrl-C signal. Default action: end the program. 
  26243.  SIGSEGV         Access to memory not valid. Default action: end the program 
  26244.                  and provide an error message. If machine-state dumps are 
  26245.                  enabled (with the /Tx compiler option), a dump is also 
  26246.                  provided. 
  26247.  SIGTERM         Program termination signal sent by the user. Default action: 
  26248.                  end the program. 
  26249.  SIGUSR1         Defined by the user. Default action: ignore the signal. 
  26250.  SIGUSR2         Defined by the user. Default action: ignore the signal. 
  26251.  SIGUSR3         Defined by the user. Default action: ignore the signal. 
  26252.  
  26253.  For sig_handler, you must specify either the SIG_DFL or SIG_IGN constant (also 
  26254.  defined in <signal.h>), or the address of a function that takes an integer 
  26255.  argument (the signal). 
  26256.  
  26257.  The action taken when the interrupt signal is received depends on the value of 
  26258.  sig_handler: 
  26259.  
  26260.  Value           Meaning 
  26261.  
  26262.  SIG_DFL         Perform the default action. This is the initial setting for 
  26263.                  all signals. The default actions are described in the list of 
  26264.                  signals above. All files controlled by the process are closed, 
  26265.                  but buffers are not flushed. 
  26266.  
  26267.  SIG_IGN         Ignore the interrupt signal. 
  26268.  
  26269.  sig_handler     Call the function sig_handler, which you provide, to handle 
  26270.                  the signal specified. 
  26271.  
  26272.  Your signal handler function (sig_handler) must take two integer arguments. 
  26273.  The first argument is always the signal identifier. The second argument is 0, 
  26274.  unless the signal is SIG_FPE. For SIG_FPE signals, the second argument passed 
  26275.  is a floating-point error signal as defined in <float.h>. If your sig_handler 
  26276.  returns, the calling process resumes running immediately following the point 
  26277.  at which it received the interrupt signal. 
  26278.  
  26279.  After a signal is reported and the sig_handler is called, signal handling for 
  26280.  that signal is reset to the default. Depending on the purpose of the signal 
  26281.  handler, you may want to call signal inside sig_handler to reestablish 
  26282.  sig_handler as the signal handler. You can also reset the default handling at 
  26283.  any time by calling signal and specifying SIG_DFL. 
  26284.  
  26285.  Signals and signal handlers are not shared between threads. If you do not 
  26286.  establish a handler for a specific signal within a thread, the default signal 
  26287.  handling is used regardless of what handlers you may have established in other 
  26288.  concurrent threads. 
  26289.  
  26290.  Note:  If an exception occurs in a math or critical library function, it is 
  26291.  handled by the VisualAge C++ exception handler.  Your sig_handler will not be 
  26292.  called. For more information about signals and exceptions, refer to Signal and 
  26293.  OS/2 Exception Handling in the Programming Guide. 
  26294.  
  26295.  Return Value 
  26296.  All calls to signal return the address of the previous handler for the 
  26297.  re-assigned signal. 
  26298.  
  26299.  A return value of SIG_ERR (defined in <signal.h>) indicates an error, and 
  26300.  errno is set to EINVAL. The possible causes of the error are an incorrect sig 
  26301.  value or an undefined value for sig_handler. 
  26302.  
  26303.  
  26304. ΓòÉΓòÉΓòÉ <hidden> Example of signal ΓòÉΓòÉΓòÉ
  26305.  
  26306. /************************************************************************
  26307.  
  26308. In the following example, the call to signal in main establishes the function 
  26309. handler to process the interrupt signal raised by abort. The handler prints a 
  26310. message and returns to the system. 
  26311.  
  26312. ************************************************************************/
  26313.  
  26314. #define INCL_DOSFILEMGR
  26315. #include <os2.h>
  26316. #include <signal.h>
  26317. #include <stdio.h>
  26318. #include <stdlib.h>
  26319. #include <string.h>
  26320.  
  26321. void handler(int sig)
  26322. {
  26323.    UCHAR FileData[100];
  26324.    ULONG Wrote;
  26325.  
  26326.    strcpy(FileData, "Signal occurred.\n\r");
  26327.    DosWrite(2, (PVOID)FileData, strlen(FileData), &Wrote);
  26328. }
  26329.  
  26330. int main(void)
  26331. {
  26332.    if (SIG_ERR == signal(SIGABRT, handler)) {
  26333.       perror("Could not set SIGABRT");
  26334.       return EXIT_FAILURE;
  26335.    }
  26336.    abort();                             /* signal raised by abort             */
  26337.    return 0;                            /* code should not reach here         */
  26338.  
  26339.    /****************************************************************************
  26340.       The output should be:
  26341.  
  26342.       Signal occurred.
  26343.    ****************************************************************************/
  26344. }
  26345.  
  26346.  
  26347. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  26348.  
  26349. Example of signal 
  26350.  
  26351.      abort - Stop a Program 
  26352.      atexit - Record Program Termination Function 
  26353.      exit - End Program 
  26354.      _exit - End Process 
  26355.      _fpreset - Reset Floating-Point Unit 
  26356.      raise - Send Signal 
  26357.      _spawnl - _spawnvpe - Start and Run Child Processes 
  26358.      Signal and OS/2 Exception Handling in the Programming Guide 
  26359.      <signal.h> 
  26360.  
  26361.  
  26362. ΓòÉΓòÉΓòÉ 4.255. sin - Calculate Sine ΓòÉΓòÉΓòÉ
  26363.  
  26364.  
  26365. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  26366.  
  26367. #include <math.h>
  26368. double sin(double x);
  26369.  
  26370.  
  26371. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  26372.  
  26373. Language Level: ANSI, SAA, POSIX, XPG4 
  26374.  
  26375. sin calculates the sine of x, with x expressed in radians. If x is too large, a 
  26376. partial loss of significance in the result may occur. 
  26377.  
  26378. Return Value 
  26379. sin returns the value of the sine of x. 
  26380.  
  26381.  
  26382. ΓòÉΓòÉΓòÉ <hidden> Example of sin ΓòÉΓòÉΓòÉ
  26383.  
  26384. /************************************************************************
  26385.  
  26386. This example computes y as the sine of pi/2. 
  26387.  
  26388. ************************************************************************/
  26389.  
  26390. #include <math.h>
  26391.  
  26392. int main(void)
  26393. {
  26394.    double pi,x,y;
  26395.  
  26396.    pi = 3.1415926535;
  26397.    x = pi/2;
  26398.    y = sin(x);
  26399.    printf("sin( %lf ) = %lf\n", x, y);
  26400.    return 0;
  26401.  
  26402.    /****************************************************************************
  26403.       The output should be:
  26404.  
  26405.       sin( 1.570796 ) = 1.000000
  26406.    ****************************************************************************/
  26407. }
  26408.  
  26409.  
  26410. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  26411.  
  26412. Example of sin 
  26413.  
  26414.      asin - Calculate Arcsine 
  26415.      cos - Calculate Cosine 
  26416.      _fasin - Calculate Arcsine 
  26417.      _fcossin - Calculate Cosine and Sine 
  26418.      _fsin - Calculate Sine 
  26419.      _fsincos - Calculate Sine and Cosine 
  26420.      sinh - Calculate Hyperbolic Sine 
  26421.      tan - Calculate Tangent 
  26422.      <math.h> 
  26423.  
  26424.  
  26425. ΓòÉΓòÉΓòÉ 4.256. sinh - Calculate Hyperbolic Sine ΓòÉΓòÉΓòÉ
  26426.  
  26427.  
  26428. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  26429.  
  26430. #include <math.h>
  26431. double sinh(double x);
  26432.  
  26433.  
  26434. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  26435.  
  26436. Language Level: ANSI, SAA, POSIX, XPG4 
  26437.  
  26438. sinh calculates the hyperbolic sine of x, with x expressed in radians. 
  26439.  
  26440. Return Value 
  26441. sinh returns the value of the hyperbolic sine of x. If the result is too large, 
  26442. sinh sets errno to ERANGE and returns the value HUGE_VAL (positive or negative, 
  26443. depending on the value of x). 
  26444.  
  26445.  
  26446. ΓòÉΓòÉΓòÉ <hidden> Example of sinh ΓòÉΓòÉΓòÉ
  26447.  
  26448. /************************************************************************
  26449.  
  26450. This example computes y as the hyperbolic sine of pi/2. 
  26451.  
  26452. ************************************************************************/
  26453.  
  26454. #include <math.h>
  26455.  
  26456. int main(void)
  26457. {
  26458.    double pi,x,y;
  26459.  
  26460.    pi = 3.1415926535;
  26461.    x = pi/2;
  26462.    y = sinh(x);
  26463.    printf("sinh( %lf ) = %lf\n", x, y);
  26464.    return 0;
  26465.  
  26466.    /****************************************************************************
  26467.       The output should be:
  26468.  
  26469.       sinh( 1.570796 ) = 2.301299
  26470.    ****************************************************************************/
  26471. }
  26472.  
  26473.  
  26474. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  26475.  
  26476. Example of sinh 
  26477.  
  26478.      asin - Calculate Arcsine 
  26479.      cosh - Calculate Hyperbolic Cosine 
  26480.      _fasin - Calculate Arcsine 
  26481.      _fcossin - Calculate Cosine and Sine 
  26482.      _fsin - Calculate Sine 
  26483.      _fsincos - Calculate Sine and Cosine 
  26484.      sin - Calculate Sine 
  26485.      tanh - Calculate Hyperbolic Tangent 
  26486.      <math.h> 
  26487.  
  26488.  
  26489. ΓòÉΓòÉΓòÉ 4.257. _sopen - Open Shared File ΓòÉΓòÉΓòÉ
  26490.  
  26491.  
  26492. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  26493.  
  26494. #include <fcntl.h>
  26495. #include <sys\stat.h>
  26496. #include <share.h>
  26497. #include <io.h>
  26498. int _sopen(char *pathname, int oflag, int shflag , int pmode);
  26499.  
  26500.  
  26501. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  26502.  
  26503. Language Level:  Extension 
  26504.  
  26505. _sopen opens the file specified by pathname and prepares the file for 
  26506. subsequent shared reading or writing as defined by oflag and shflag. The oflag 
  26507. is an integer expression formed by combining one or more of the constants 
  26508. defined in <fcntl.h>. When more than one constant is given, the constants are 
  26509. joined with the OR operator (|). 
  26510.  
  26511.  Oflag          Meaning 
  26512.  O_APPEND       Reposition the file pointer to the end of the file before every 
  26513.                 write operation. 
  26514.  O_CREAT        Create and open a new file.  This flag has no effect if the 
  26515.                 file specified by pathname exists. 
  26516.  O_EXCL         Return an error value if the file specified by pathname exists. 
  26517.                 This flag applies only when used with O_CREAT. 
  26518.  O_RDONLY       Open the file for reading only.  If this flag is given, neither 
  26519.                 O_RDWR nor O_WRONLY can be given. 
  26520.  O_RDWR         Open the file for both reading and writing.  If this flag is 
  26521.                 given, neither O_RDONLY nor O_WRONLY can be given. 
  26522.  O_TRUNC        Open and truncate an existing file to 0 length. The file must 
  26523.                 have write permission. The contents of the file are destroyed. 
  26524.                 On the OS/2 operating system, do not specify O_TRUNC with 
  26525.                 O_RDONLY. 
  26526.  O_WRONLY       Open the file for writing only.  If this flag is given, neither 
  26527.                 O_RDONLY nor O_RDWR can be given. 
  26528.  O_BINARY       Open the file in binary (untranslated) mode. 
  26529.  O_TEXT         Open the file in text (translated) mode. (See "Stream 
  26530.                 Processing" in the Programming Guide for a description of text 
  26531.                 and binary mode.) 
  26532.  
  26533.  The shflag argument is one of the following constants, defined in <share.h>: 
  26534.  
  26535.  Shflag          Meaning 
  26536.  SH_DENYRW       Deny read and write access to file. 
  26537.  SH_DENYWR       Deny write access to file. 
  26538.  SH_DENYRD       Deny read access to file. 
  26539.  SH_DENYNO       Permit read and write access. 
  26540.  
  26541.  There is no default value for the shflag. 
  26542.  
  26543.  The pmode argument is required only when you specify O_CREAT. If the file does 
  26544.  not exist, pmode specifies the permission settings of the file, which are set 
  26545.  when the new file is closed for the first time. If the file exists, the value 
  26546.  of pmode is ignored. The pmode must be one of the following values, defined in 
  26547.  <sys\stat.h>: 
  26548.  
  26549.  Value                   Meaning 
  26550.  S_IWRITE                Writing permitted 
  26551.  S_IREAD                 Reading permitted 
  26552.  S_IREAD | S_IWRITE      Reading and writing permitted. 
  26553.  
  26554.  If write permission is not given, the file is read-only. On the OS/2 operating 
  26555.  system, all files are readable; you cannot give write-only permission.  Thus, 
  26556.  the modes S_IWRITE and S_IREAD | S_IWRITE are equivalent. Specifying a pmode 
  26557.  of S_IREAD is similar to making a file read-only with the ATTRIB system 
  26558.  command. 
  26559.  
  26560.  _sopen applies the current file permission mask to pmode before setting the 
  26561.  permissions. (See umask - Sets File Mask of Current Process for information on 
  26562.  file permission masks.) 
  26563.  
  26564.  _sopen returns a file handle for the opened file. A return value of -1 
  26565.  indicates an error, and errno is set to one of the following values: 
  26566.  
  26567.  Value         Meaning 
  26568.  EACCESS       The given path name is a directory, but the file is read-only 
  26569.                and at attempt was made to open if for writing, or a sharing 
  26570.                violation occurred. 
  26571.  EEXIST        The O_CREAT and O_EXCL flags are specified, but the named file 
  26572.                already exists. 
  26573.  EMFILE        No more file handles are available. 
  26574.  ENOENT        The file or path name was not found. 
  26575.  EINVAL        An incorrect argument was passed. 
  26576.  EOS2ERR       The call to the operating system was not successful. 
  26577.  
  26578.  
  26579. ΓòÉΓòÉΓòÉ <hidden> Example of _sopen ΓòÉΓòÉΓòÉ
  26580.  
  26581. /************************************************************************
  26582.  
  26583. This example opens the file sopen.dat for shared reading and writing using 
  26584. _sopen. It then opens the file for shared reading. 
  26585.  
  26586. ************************************************************************/
  26587.  
  26588. #include <io.h>
  26589. #include <stdio.h>
  26590. #include <stdlib.h>
  26591. #include <fcntl.h>
  26592. #include <share.h>
  26593.  
  26594. #define FILENAME "sopen.dat"
  26595.  
  26596. int main(void)
  26597. {
  26598.    int fh1,fh2;
  26599.  
  26600.    printf("Creating file.\n");
  26601.    system("echo Sample Program > " FILENAME);
  26602.  
  26603.    /* share open the file for reading and writing                            */
  26604.    if (-1 == (fh1 = _sopen(FILENAME, O_RDWR, SH_DENYNO))) {
  26605.       perror("sopen failed");
  26606.       remove(FILENAME);
  26607.       return EXIT_FAILURE;
  26608.    }
  26609.    /* share open the file for reading only                                   */
  26610.    if (-1 == (fh2 = _sopen(FILENAME, O_RDONLY, SH_DENYNO))) {
  26611.       perror("sopen failed");
  26612.       close(fh1);
  26613.       remove(FILENAME);
  26614.       return EXIT_FAILURE;
  26615.    }
  26616.    printf("File successfully opened for sharing.\n");
  26617.    close(fh1);
  26618.    close(fh2);
  26619.    remove(FILENAME);
  26620.    return 0;
  26621.  
  26622.    /****************************************************************************
  26623.       The output should be:
  26624.  
  26625.       Creating file.
  26626.       File successfully opened for sharing.
  26627.    ****************************************************************************/
  26628. }
  26629.  
  26630.  
  26631. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  26632.  
  26633. Example of _sopen 
  26634.  
  26635.      close - Close File Associated with Handle 
  26636.      creat - Create New File 
  26637.      open - Open File 
  26638.      fdopen - Associates Input Or Output With File 
  26639.      fopen - Open Files 
  26640.      _sopen - Open Shared File 
  26641.      umask - Sets File Mask of Current Process 
  26642.      <fcntl.h> 
  26643.      <io.h> 
  26644.      <share.h> 
  26645.      <sys\stat.h> 
  26646.  
  26647.  
  26648. ΓòÉΓòÉΓòÉ 4.258. _spawnl - _spawnvpe - Start and Run Child Processes ΓòÉΓòÉΓòÉ
  26649.  
  26650.  
  26651. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  26652.  
  26653. #include <process.h>
  26654. int _spawnl(int modeflag, char *pathname, char *arg0, char *arg1, ...,
  26655.               char *argn, NULL);
  26656. int _spawnlp(int modeflag, char *pathname, char *arg0, char *arg1, ...,
  26657.               char *argn, NULL);
  26658. int _spawnle(int modeflag, char *pathname, char *arg0, char *arg1, ...,
  26659.               char *argn, NULL, char *envp[ ]);
  26660. int _spawnlpe(int modeflag, char *pathname, char *arg0, char *arg1, ...,
  26661.               char *argn, NULL, char *envp[ ]);
  26662. int _spawnv(int modeflag, char *pathname, char *argv[ ]);
  26663. int _spawnvp(int modeflag, char *pathname, char *argv[ ]);
  26664. int _spawnve(int modeflag, char *pathname, char *argv[ ], char *envp[ ]);
  26665. int _spawnvpe(int modeflag, char *pathname, char *argv[ ], char *envp[ ])
  26666.  
  26667.  
  26668. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  26669.  
  26670. Language Level:  Extension 
  26671.  
  26672. Each of the _spawn functions creates and runs a new child process. Enough 
  26673. storage must be available for loading and running the child process. All of the 
  26674. _spawn functions are versions of the same routine; the letters at the end 
  26675. determine the specific variation: 
  26676.  
  26677.  Letter    Variation 
  26678.   p        Uses PATH environment variable to find the file to be run 
  26679.   l        Lists command-line arguments separately 
  26680.   v        Passes to the child process an array of pointers to command-line 
  26681.            arguments 
  26682.   e        Passes to the child process an array of pointers to environment 
  26683.            strings. 
  26684.  
  26685.  The modeflag argument determines the action taken by the parent process before 
  26686.  and during the _spawn. The values for modeflag are defined in <process.h>: 
  26687.  
  26688.  Value          Meaning 
  26689.  P_WAIT         Suspend the parent process until the child process is complete. 
  26690.  P_NOWAIT       Continue to run the parent process concurrently. 
  26691.  P_OVERLAY      Start the child process, and then, if successful, end the 
  26692.                 parent process.  (This has the same effect as exec calls.) 
  26693.  
  26694.  The pathname argument specifies the file to run as the child process.  The 
  26695.  pathname can specify a full path (from the root), a partial path (from the 
  26696.  current working directory), or just a file name.  If pathname does not have a 
  26697.  file-name extension or end with a period, the _spawn functions add the 
  26698.  extension .EXE and search for the file. If pathname has an extension, only 
  26699.  that extension is used.  If pathname ends with a period, the _spawn functions 
  26700.  search for pathname with no extension. The _spawnlp, _spawnlpe, _spawnvp, and 
  26701.  _spawnvpe functions search for pathname (using the same procedures) in the 
  26702.  directories specified by the PATH environment variable. 
  26703.  
  26704.  You pass arguments to the child process by giving one or more pointers to 
  26705.  character strings as arguments in the _spawn routine.  These character strings 
  26706.  form the argument list for the child process. 
  26707.  
  26708.  The argument pointers can be passed as separate arguments (_spawnl, _spawnle, 
  26709.  _spawnlp, and _spawnlpe) or as an array of pointers (_spawnv, _spawnve, 
  26710.  _spawnvp, and _spawnvpe).  At least one argument, either arg0 or argv[0], must 
  26711.  be passed to the child process.  By convention, this argument is a copy of the 
  26712.  pathname argument.  However, a different value will not produce an error. 
  26713.  
  26714.  Use the _spawnl, _spawnle, _spawnlp, and _spawnlpe functions where you know 
  26715.  the number of arguments. The arg0 is usually a pointer to pathname. The arg1 
  26716.  through argn arguments are pointers to the character strings forming the new 
  26717.  argument list. Following argn, a NULL pointer must mark the end of the 
  26718.  argument list. 
  26719.  
  26720.  The _spawnv, _spawnve, _spawnvp, and _spawnvpe functions are useful when the 
  26721.  number of arguments to the child process is variable.  Pointers to the 
  26722.  arguments are passed as an array, argv.  The argv[0] argument is usually a 
  26723.  pointer to the pathname. The argv[1] through argv[n] arguments are pointers to 
  26724.  the character strings forming the new argument list. The argv[n+1] argument 
  26725.  must be a NULL pointer to mark the end of the argument list. 
  26726.  
  26727.  Files that are open when a _spawn call is made remain open in the child 
  26728.  process.  In the _spawnl, _spawnlp, _spawnv, and _spawnvp calls, the child 
  26729.  process inherits the environment of the parent. The _spawnle, _spawnlpe, 
  26730.  _spawnve, and _spawnvpe functions let you alter the environment for the child 
  26731.  process by passing a list of environment settings through the envp argument. 
  26732.  The envp argument is an array of character pointers, each element of which 
  26733.  points to a null-terminated string, that defines an environment variable. 
  26734.  Such a string has the form: 
  26735.  
  26736.      NAME=value
  26737.  
  26738.  where NAME is the name of an environment variable, and value is the string 
  26739.  value to which that variable is set.  (Notice that value is not enclosed in 
  26740.  double quotation marks.) The final element of the envp array should be NULL. 
  26741.  When envp itself is NULL, the child process inherits the environment settings 
  26742.  of the parent process. 
  26743.  
  26744.  Note:  Signal settings are not preserved in child processes created by calls 
  26745.  to _spawn functions. The signal settings are reset to the default in the child 
  26746.  process. 
  26747.  
  26748.  Return Value 
  26749.  The return from a spawn function has one of two different meanings.  The 
  26750.  return value of a synchronous spawn is the exit status of the child process. 
  26751.  The return value of an asynchronous spawn is the process identification of the 
  26752.  child process.  You can use wait or _cwait to get the child process exit code 
  26753.  if an asynchronous spawn was done. 
  26754.  
  26755.  A return value of -1 indicates an error (the child process is not started), 
  26756.  and errno is set to one of the following values: 
  26757.  
  26758.  Value       Meaning 
  26759.  EAGAIN      The limit of the number of processes that the operating system 
  26760.              permits has been reached. 
  26761.  EINVAL      The modeflag argument is incorrect. 
  26762.  ENOENT      The file or path name was not found or was not specified 
  26763.              correctly. 
  26764.  ENOEXEC     The specified file is not executable or has an incorrect 
  26765.              executable file format. 
  26766.  ENOMEM      Not enough storage is available to run the child process. 
  26767.  
  26768.  
  26769. ΓòÉΓòÉΓòÉ <hidden> Example of _spawnl - _spawnvpe ΓòÉΓòÉΓòÉ
  26770.  
  26771. /************************************************************************
  26772.  
  26773. This example calls four of the eight _spawn routines. When called without 
  26774. arguments from the command line, the program first runs the code for case 
  26775. PARENT. It spawns a copy of itself, waits for its child process to run, and 
  26776. then spawns a second child process. The instructions for the child process are 
  26777. blocked to run only if argv[0] and one parameter were passed (case CHILD). In 
  26778. its turn, each child process spawns a grandchild as a copy of the same program. 
  26779. The grandchild instructions are blocked by the existence of two passed 
  26780. parameters. The grandchild process can overlay the child process. Each of the 
  26781. processes prints a message identifying itself. 
  26782.  
  26783. ************************************************************************/
  26784.  
  26785. #include <stdio.h>
  26786. #include <process.h>
  26787.  
  26788. #define  PARENT        1
  26789. #define  CHILD         2
  26790. #define  GRANDCHILD    3
  26791.  
  26792. int main(int argc,char **argv,char **envp)
  26793. {
  26794.    int result;
  26795.    char *args[4];
  26796.  
  26797.    switch (argc) {
  26798.       case  PARENT :  /* no argument was passed: spawn child and wait         */
  26799.          result = _spawnle(P_WAIT, argv[0], argv[0], "one", NULL, envp);
  26800.          if (result)
  26801.             abort();
  26802.          args[0] = argv[0];
  26803.          args[1] = "two";
  26804.          args[2] = NULL;
  26805.  
  26806.           /* spawn another child, and wait for it                             */
  26807.  
  26808.          result = _spawnve(P_WAIT, argv[0], args, envp);
  26809.          if (result)
  26810.             abort();
  26811.          printf("Parent process ended\n");
  26812.          exit(0);
  26813.       case  CHILD :  /* one argument passed: allow grandchild to overlay      */
  26814.          printf("child process %s began\n", argv[1]);
  26815.          if ('o' == *argv[1])                             /* child one?       */
  26816.             {
  26817.             _spawnl(P_OVERLAY, argv[0], argv[0], "one", "two", NULL);
  26818.             abort();       /* not executed because child was overlaid         */
  26819.          }
  26820.          if ('t' == *argv[1])                             /* child two?       */
  26821.             {
  26822.             args[0] = argv[0];
  26823.             args[1] = "two";
  26824.             args[2] = "one";
  26825.             args[3] = NULL;
  26826.             _spawnv(P_OVERLAY, argv[0], args);
  26827.             abort();       /* not executed because child was overlaid         */
  26828.          }
  26829.          abort();                            /* argument not valid            */
  26830.       case  GRANDCHILD :   /* two arguments passed                            */
  26831.          printf("grandchild %s ran\n", argv[1]);
  26832.          exit(0);
  26833.    }
  26834.    /****************************************************************************
  26835.       The output should be:
  26836.  
  26837.       child process one began
  26838.       grandchild one ran
  26839.       child process two began
  26840.       grandchild two ran
  26841.       Parent process ended
  26842.    ****************************************************************************/
  26843. }
  26844.  
  26845.  
  26846. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  26847.  
  26848. Example of _spawnl - _spawnvpe 
  26849.  
  26850.      abort - Stop a Program 
  26851.      _cwait - Wait for Child Process 
  26852.      execl - _execvpe - Load and Run Child Process 
  26853.      exit - End Program 
  26854.      _exit - End Process 
  26855.      wait - Wait for Child Process 
  26856.      <process.h> 
  26857.  
  26858.  
  26859. ΓòÉΓòÉΓòÉ 4.259. _splitpath - Decompose Path Name ΓòÉΓòÉΓòÉ
  26860.  
  26861.  
  26862. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  26863.  
  26864. #include <stdlib.h>
  26865. void _splitpath(char *path, char *drive, char *dir,
  26866.                     char *fname, char *ext);
  26867.  
  26868.  
  26869. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  26870.  
  26871. Language Level:  Extension 
  26872.  
  26873. _splitpath decomposes an existing path name path into its four components. The 
  26874. path should point to a buffer containing the complete path name. 
  26875.  
  26876. The maximum size necessary for each buffer is specified by the _MAX_DRIVE, 
  26877. _MAX_DIR, _MAX_FNAME, and _MAX_EXT constants defined in <stdlib.h>.  The other 
  26878. arguments point to the following buffers used to store the path name elements: 
  26879.  
  26880.  Buffer    Description 
  26881.  drive     Contains the drive letter followed by a colon (:) if a drive is 
  26882.            specified in path. 
  26883.  dir       Contains the path of subdirectories, if any, including the trailing 
  26884.            slash.  Slashes (/), backslashes (\), or both may be present in 
  26885.            path. 
  26886.  fname     Contains the base file name without any extensions. 
  26887.  ext       Contains the file name extension, if any, including the leading 
  26888.            period (.). 
  26889.  
  26890.  You can specify NULL for any of the buffer pointers to indicate that you do 
  26891.  not want the string for that component returned. 
  26892.  
  26893.  The return parameters contain empty strings for any path name components not 
  26894.  found in path. 
  26895.  
  26896.  Return Value 
  26897.  There is no return value. 
  26898.  
  26899.  
  26900. ΓòÉΓòÉΓòÉ <hidden> Example of _splitpath ΓòÉΓòÉΓòÉ
  26901.  
  26902. /************************************************************************
  26903.  
  26904. This example builds a file name path from the specified components, and then 
  26905. extracts the individual components. 
  26906.  
  26907. ************************************************************************/
  26908.  
  26909. #include <stdio.h>
  26910. #include <stdlib.h>
  26911.  
  26912. int main(void)
  26913. {
  26914.    char path_buffer[_MAX_PATH];
  26915.    char drive[_MAX_DRIVE];
  26916.    char dir[_MAX_DIR];
  26917.    char fname[_MAX_FNAME];
  26918.    char ext[_MAX_EXT];
  26919.  
  26920.    _makepath(path_buffer, "c", "qc\\bob\\eclibref\\e", "makepath", "c");
  26921.    printf("Path created with _makepath: %s\n\n", path_buffer);
  26922.    _splitpath(path_buffer, drive, dir, fname, ext);
  26923.    printf("Path extracted with _splitpath:\n");
  26924.    printf("drive: %s\n", drive);
  26925.    printf("directory: %s\n", dir);
  26926.    printf("file name: %s\n", fname);
  26927.    printf("extension: %s\n", ext);
  26928.    return 0;
  26929.  
  26930.    /****************************************************************************
  26931.       The output should be:
  26932.  
  26933.       Path created with _makepath: c:qc\bob\eclibref\e\makepath.c
  26934.  
  26935.       Path extracted with _splitpath:
  26936.       drive: c:
  26937.       directory: qc\bob\eclibref\e\
  26938.       file name: makepath
  26939.       extension: .c
  26940.    ****************************************************************************/
  26941. }
  26942.  
  26943.  
  26944. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  26945.  
  26946. Example of _splitpath 
  26947.  
  26948.      _fullpath - Get Full Path Name of Partial Path 
  26949.      _getcwd - Get Path Name of Current Directory 
  26950.      _getdcwd - Get Full Path Name of Current Directory 
  26951.      _makepath - Create Path 
  26952.      <stdlib.h> 
  26953.  
  26954.  
  26955. ΓòÉΓòÉΓòÉ 4.260. sprintf - Print Formatted Data to Buffer ΓòÉΓòÉΓòÉ
  26956.  
  26957.  
  26958. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  26959.  
  26960. #include <stdio.h>
  26961. int sprintf(char *buffer, const char *format-string, argument-list);
  26962.  
  26963.  
  26964. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  26965.  
  26966. Language Level: ANSI, SAA, POSIX, XPG4, Extension 
  26967.  
  26968. sprintf formats and stores a series of characters and values in the array 
  26969. buffer. Any argument-list is converted and put out according to the 
  26970. corresponding format specification in the format-string. 
  26971.  
  26972. The format-string consists of ordinary characters and has the same form and 
  26973. function as the format-string argument for the printf function. See printf for 
  26974. a description of the format-string and arguments. 
  26975.  
  26976. In extended mode, sprintf also converts floating-point values of NaN and 
  26977. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  26978. and sign of the string is determined by the format specifiers.  See Infinity 
  26979. and NaN Support for more information on infinity and NaN values. 
  26980.  
  26981. If you specify a null string for the %s or %ls format specifier, sprintf prints 
  26982. (null). (In previous releases of C Set ++, sprintf produced no output for a 
  26983. null string.) 
  26984.  
  26985. Return Value 
  26986. sprintf returns the number of bytes written in the array, not counting the 
  26987. ending null character. 
  26988.  
  26989.  
  26990. ΓòÉΓòÉΓòÉ <hidden> Example of sprintf ΓòÉΓòÉΓòÉ
  26991.  
  26992. /************************************************************************
  26993.  
  26994. This example uses sprintf to format and print various data. 
  26995.  
  26996. ************************************************************************/
  26997.  
  26998. #include <stdio.h>
  26999.  
  27000. char buffer[200];
  27001. int i,j;
  27002. double fp;
  27003. char *s = "baltimore";
  27004. char c;
  27005.  
  27006. int main(void)
  27007. {
  27008.    c = 'l';
  27009.    i = 35;
  27010.    fp = 1.7320508;
  27011.  
  27012.     /* Format and print various data                                          */
  27013.  
  27014.    j = sprintf(buffer, "%s\n", s);
  27015.    j += sprintf(buffer+j, "%c\n", c);
  27016.    j += sprintf(buffer+j, "%d\n", i);
  27017.    j += sprintf(buffer+j, "%f\n", fp);
  27018.    printf("string:\n%s\ncharacter count = %d\n", buffer, j);
  27019.    return 0;
  27020.  
  27021.    /****************************************************************************
  27022.       The output should be:
  27023.  
  27024.       string:
  27025.       baltimore
  27026.       l
  27027.       35
  27028.       1.732051
  27029.  
  27030.       character count = 24
  27031.    ****************************************************************************/
  27032. }
  27033.  
  27034.  
  27035. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27036.  
  27037. Example of sprintf 
  27038.  
  27039.      Infinity and NaN Support 
  27040.      _cprintf - Print Characters to Screen 
  27041.      fprintf - Write Formatted Data to a Stream 
  27042.      printf - Print Formatted Characters 
  27043.      sscanf - Read Data 
  27044.      swprintf - Format and Write Wide Characters to Buffer 
  27045.      vfprintf - Print Argument Data to Stream 
  27046.      vprintf - Print Argument Data 
  27047.      vsprintf - Print Argument Data to Buffer 
  27048.      vswprintf - Format and Write Wide Characters to Buffer 
  27049.      <stdio.h> 
  27050.  
  27051.  
  27052. ΓòÉΓòÉΓòÉ 4.261. sqrt - Calculate Square Root ΓòÉΓòÉΓòÉ
  27053.  
  27054.  
  27055. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27056.  
  27057. #include <math.h>
  27058. double sqrt(double x);
  27059.  
  27060.  
  27061. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27062.  
  27063. Language Level: ANSI, SAA SAA, POSIX, XPG4 
  27064.  
  27065. sqrt calculates the nonnegative value of the square root of x. 
  27066.  
  27067. Return Value 
  27068. sqrt returns the square root result.  If x is negative, the function sets errno 
  27069. to EDOM, and returns 0. 
  27070.  
  27071.  
  27072. ΓòÉΓòÉΓòÉ <hidden> Example of sqrt ΓòÉΓòÉΓòÉ
  27073.  
  27074. /************************************************************************
  27075.  
  27076. This example computes the square root of the quantity passed as the first 
  27077. argument to main. It prints an error message if you pass a negative value. 
  27078.  
  27079. ************************************************************************/
  27080.  
  27081. #include <stdio.h>
  27082. #include <stdlib.h>
  27083. #include <math.h>
  27084.  
  27085. int main(int argc,char **argv)
  27086. {
  27087.    double value = 45.0;
  27088.  
  27089.    printf("sqrt( %f ) = %f\n", value, sqrt(value));
  27090.    return 0;
  27091.  
  27092.    /****************************************************************************
  27093.       The output should be:
  27094.  
  27095.       sqrt( 45.000000 ) = 6.708204
  27096.    ****************************************************************************/
  27097. }
  27098.  
  27099.  
  27100. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27101.  
  27102. Example of sqrt 
  27103.  
  27104.      exp - Calculate Exponential Function 
  27105.      _fsqrt -  Calculate Square Root 
  27106.      hypot - Calculate Hypotenuse 
  27107.      log - Calculate Natural Logarithm 
  27108.      log10 - Calculate Base 10 Logarithm 
  27109.      pow - Compute Power 
  27110.      <math.h> 
  27111.  
  27112.  
  27113. ΓòÉΓòÉΓòÉ 4.262. srand - Set Seed for rand Function ΓòÉΓòÉΓòÉ
  27114.  
  27115.  
  27116. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27117.  
  27118. #include <stdlib.h>
  27119. void srand(unsigned int seed);
  27120.  
  27121.  
  27122. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27123.  
  27124. Language Level: ANSI, SAA, POSIX, XPG4 
  27125.  
  27126. srand sets the starting point for producing a series of pseudo-random integers. 
  27127. If srand is not called, the rand seed is set as if srand(1) were called at 
  27128. program start.  Any other value for seed sets the generator to a different 
  27129. starting point. 
  27130.  
  27131. The rand function generates the pseudo-random numbers. 
  27132.  
  27133. Return Value 
  27134. There is no return value. 
  27135.  
  27136.  
  27137. ΓòÉΓòÉΓòÉ <hidden> Example of srand ΓòÉΓòÉΓòÉ
  27138.  
  27139. /************************************************************************
  27140.  
  27141. This example first calls srand with a value other than 1 to initiate the random 
  27142. value sequence.  Then the program computes five random values for the array of 
  27143. integers called ranvals. 
  27144.  
  27145. ************************************************************************/
  27146.  
  27147. #include <stdlib.h>
  27148. #include <stdio.h>
  27149.  
  27150. int main(void)
  27151. {
  27152.    int i,ranvals[5];
  27153.  
  27154.    srand(17);
  27155.    for (i = 0; i < 5; i++) {
  27156.       ranvals[i] = rand();
  27157.       printf("Iteration %d ranvals [%d] = %d\n", i+1, i, ranvals[i]);
  27158.    }
  27159.    return 0;
  27160.  
  27161.    /****************************************************************************
  27162.       The output should be similar to:
  27163.  
  27164.       Iteration 1 ranvals [0] = 24107
  27165.       Iteration 2 ranvals [1] = 16552
  27166.       Iteration 3 ranvals [2] = 12125
  27167.       Iteration 4 ranvals [3] = 9427
  27168.       Iteration 5 ranvals [4] = 13152
  27169.    ****************************************************************************/
  27170. }
  27171.  
  27172.  
  27173. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27174.  
  27175. Example of srand 
  27176.  
  27177.      rand - Generate Random Number 
  27178.      <stdlib.h> 
  27179.  
  27180.  
  27181. ΓòÉΓòÉΓòÉ 4.263. _srotl - _srotr - Rotate Bits of Unsigned Short Value ΓòÉΓòÉΓòÉ
  27182.  
  27183.  
  27184. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27185.  
  27186. #include <stdlib.h>   /* also in <builtin.h> */
  27187.  
  27188. unsigned short _srotl(unsigned short value, int shift);
  27189. unsigned short _srotr(unsigned short value, int shift);
  27190.  
  27191.  
  27192. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27193.  
  27194. Language Level:  Extension 
  27195.  
  27196. The _srotl and _srotr functions rotate the unsigned short integer value by 
  27197. shift bits. The _srotl function rotates to the left, and _srotr to the right. 
  27198.  
  27199. Note:  Both _srotl and _srotr are built-in functions, which means they are 
  27200.        implemented as inline instructions and have no backing code in the 
  27201.        library. For this reason: 
  27202.  
  27203.      You cannot take the address of these functions. 
  27204.      You cannot parenthesize a call to either function. (Parentheses specify a 
  27205.       call to the function's backing code, and these functions have none.) 
  27206.  
  27207.  Return Value 
  27208.  
  27209.  Both functions return the rotated value. There is no error return value. 
  27210.  
  27211.  
  27212. ΓòÉΓòÉΓòÉ <hidden> Example of _srotl - _srotr ΓòÉΓòÉΓòÉ
  27213.  
  27214. /************************************************************************
  27215. *
  27216.  
  27217. This example uses _srotl and _srotr with different shift values to rotate the 
  27218. character value: 
  27219.  
  27220.                                                                         *
  27221. ************************************************************************/
  27222.  
  27223. #include <stdio.h>
  27224. #include <stdlib.h>
  27225.  
  27226. int main(void)
  27227. {
  27228.    unsigned short val = 0X0123;
  27229.  
  27230.    printf("The value of 0x%4.4x rotated 4 bits to the left is 0x%4.4x\n", val,
  27231.       _srotl(val, 4));
  27232.    printf("The value of 0x%4.4x rotated 8 bits to the right is 0x%4.4x\n",
  27233.       val, _srotr(val, 8));
  27234.    return 0;
  27235.  
  27236.    /****************************************************************************
  27237.       The output should be:
  27238.  
  27239.       The value of 0x0123 rotated 4 bits to the left is 0x1230
  27240.       The value of 0x0123 rotated 8 bits to the right is 0x2301
  27241.    ****************************************************************************/
  27242. }
  27243.  
  27244.  
  27245. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27246.  
  27247. Example 
  27248.  
  27249.      _crotl - _crotr - Rotate Bits of Character Value 
  27250.      _lrotl - _lrotr - Rotate Bits of Unsigned Long Value 
  27251.      _rotl - _rotr - Rotate Bits of Unsigned Integer 
  27252.      <stdlib.h> 
  27253.      <builtin.h> 
  27254.  
  27255.  
  27256. ΓòÉΓòÉΓòÉ 4.264. sscanf - Read Data ΓòÉΓòÉΓòÉ
  27257.  
  27258.  
  27259. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27260.  
  27261. #include <stdio.h>
  27262. int sscanf(const char *buffer, const char *format, argument-list);
  27263.  
  27264.  
  27265. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27266.  
  27267. Language Level: ANSI, SAA, POSIX, XPG4, Extension 
  27268.  
  27269. sscanf reads data from buffer into the locations given by argument-list.  Each 
  27270. argument must be a pointer to a variable with a type that corresponds to a type 
  27271. specifier in the format-string. See scanf for a description of the 
  27272. format-string. 
  27273.  
  27274. In extended mode, sscanf also reads in the strings "INFINITY", "INF", and "NAN" 
  27275. (in upper or lowercase) and converts them to the corresponding floating-point 
  27276. value.  The sign of the value is determined by the format specification. See 
  27277. Infinity and NaN Support for more information on infinity and NaN values. 
  27278.  
  27279. Return Value 
  27280. sscanf returns the number of fields that were successfully converted and 
  27281. assigned.  The return value does not include fields that were read but not 
  27282. assigned. 
  27283.  
  27284. The return value is EOF when the end of the string is encountered before 
  27285. anything is converted. 
  27286.  
  27287.  
  27288. ΓòÉΓòÉΓòÉ <hidden> Example of sscanf ΓòÉΓòÉΓòÉ
  27289.  
  27290. /************************************************************************
  27291.  
  27292. This example uses sscanf to read various data from the string tokenstring, and 
  27293. then displays that data. 
  27294.  
  27295. ************************************************************************/
  27296.  
  27297. #include <stdio.h>
  27298.  
  27299. #define  SIZE          81
  27300.  
  27301. char *tokenstring = "15 12 14";
  27302. int i;
  27303. float fp;
  27304. char s[SIZE];
  27305. char c;
  27306.  
  27307. int main(void)
  27308. {
  27309.  
  27310.     /* Input various data                                                     */
  27311.    sscanf(tokenstring, "%s %c%d%f", s, &c, &i, &fp);
  27312.  
  27313.     /* If there were no space between %s and %c,                              */
  27314.     /* sscanf would read the first character following                        */
  27315.     /* the string, which is a blank space.                                    */
  27316.  
  27317.     /* Display the data                                                       */
  27318.    printf("string = %s\n", s);
  27319.    printf("character = %c\n", c);
  27320.    printf("integer = %d\n", i);
  27321.    printf("floating-point number = %f\n", fp);
  27322.    return 0;
  27323.  
  27324.    /****************************************************************************
  27325.       The output should be:
  27326.  
  27327.       string = 15
  27328.       character = 1
  27329.       integer = 2
  27330.       floating-point number = 14.000000
  27331.    ****************************************************************************/
  27332. }
  27333.  
  27334.  
  27335. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27336.  
  27337. Example of sscanf 
  27338.  
  27339.      Infinity and NaN Support 
  27340.      _cscanf - Read Data from Keyboard 
  27341.      fscanf - Read Formatted Data 
  27342.      scanf - Read Data 
  27343.      sprintf - Print Formatted Data to Buffer 
  27344.      swscanf - Read Wide Characters from Buffer 
  27345.      <stdio.h> 
  27346.  
  27347.  
  27348. ΓòÉΓòÉΓòÉ 4.265. stat - Get Information about File or Directory ΓòÉΓòÉΓòÉ
  27349.  
  27350.  
  27351. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27352.  
  27353. #include <sys\types.h>
  27354. #include <sys\stat.h>
  27355. int stat(const char *pathname, struct stat *buffer)    ;
  27356.  
  27357.  
  27358. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27359.  
  27360. Language Level:  XPG4, Extension 
  27361.  
  27362. stat stores information about the file or directory specified by pathname in 
  27363. the structure to which buffer points.  The stat structure, defined in 
  27364. <sys\stat.h>, contains the following fields: 
  27365.  
  27366.  Field          Value 
  27367.  
  27368.  st_mode        Bit mask for file-mode information. stat sets the S_IFCHR bit 
  27369.                 if handle refers to a device. The S_IFDIR bit is set if 
  27370.                 pathname specifies a directory. The S_IFREG bit is set if 
  27371.                 pathname specifies an ordinary file.  User read/write bits are 
  27372.                 set according to the permission mode of the file. The S_IEXEC 
  27373.                 bit is set using the file name extension. The other bits are 
  27374.                 undefined. 
  27375.  
  27376.  st_dev         Drive number of the disk containing the file. 
  27377.  
  27378.  st_rdev        Drive number of the disk containing the file (same as st_dev). 
  27379.  
  27380.  st_nlink       Always 1. 
  27381.  
  27382.  st_size        Size of the file in bytes. 
  27383.  
  27384.  st_atime       Time of last access of file. 
  27385.  
  27386.  st_mtime       Time of last modification of file. 
  27387.  
  27388.  st_ctime       Time of file creation. 
  27389.  
  27390.  Note:  If the given pathname specifies only a device (for example C:\), stat 
  27391.  returns an error, and fields in the stat structure are not meaningful. 
  27392.  
  27393.  Note:  In earlier releases of C Set ++, stat began with an underscore (_stat). 
  27394.  Because it is defined by the X/Open standard, the underscore has been removed. 
  27395.  For compatibility, VisualAge C++ will map _stat to stat for you. 
  27396.  
  27397.  Return Value 
  27398.  stat returns the value 0 if the file status information is obtained.  A return 
  27399.  value of -1 indicates an error, and errno is set to ENOENT, indicating that 
  27400.  the file name or path name could not be found. 
  27401.  
  27402.  
  27403. ΓòÉΓòÉΓòÉ <hidden> Example of stat ΓòÉΓòÉΓòÉ
  27404.  
  27405. /************************************************************************
  27406.  
  27407. This example requests that the status information for the file test.exe be 
  27408. placed into the structure buf.  If the request is successful and the file is 
  27409. executable, the example runs test.exe. 
  27410.  
  27411. ************************************************************************/
  27412.  
  27413. #include <sys\types.h>
  27414. #include <sys\stat.h>
  27415. #include <process.h>
  27416. #include <stdio.h>
  27417.  
  27418. int main(void)
  27419. {
  27420.    struct stat buf;
  27421.  
  27422.    if (0 == stat("test.exe", &buf)) {
  27423.       if ((buf.st_mode&S_IFREG) && (buf.st_mode&S_IEXEC))
  27424.          execl("test.exe", "test", NULL);         /* file is executable       */
  27425.    }
  27426.    else
  27427.       printf("File could not be found\n");
  27428.    return 0;
  27429.  
  27430.    /****************************************************************************
  27431.       The source for test.exe is:
  27432.  
  27433.       #include <stdio.h>
  27434.       int main(void)
  27435.       {
  27436.           puts("test.exe is an executable file");
  27437.       }
  27438.  
  27439.       The output should be:
  27440.  
  27441.       test.exe is an executable file
  27442.    ****************************************************************************/
  27443. }
  27444.  
  27445.  
  27446. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27447.  
  27448. Example of stat 
  27449.  
  27450.      fstat - Information about Open File 
  27451.      <sys\stat.h> 
  27452.      <sys\types.h> 
  27453.  
  27454.  
  27455. ΓòÉΓòÉΓòÉ 4.266. _status87 - Get Floating-Point Status Word ΓòÉΓòÉΓòÉ
  27456.  
  27457.  
  27458. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27459.  
  27460. #include <float.h>  /* also in <builtin.h> */
  27461. unsigned int _status87(void);
  27462.  
  27463.  
  27464. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27465.  
  27466. Language Level:  Extension 
  27467.  
  27468. _status87 gets the current floating-point status word. The floating-point 
  27469. status word is a combination of the numeric coprocessor status word and other 
  27470. conditions detected by the numeric exception handler, such as floating-point 
  27471. stack underflow and overflow. 
  27472.  
  27473. Return Value 
  27474. The bits in the value returned reflect the floating-point status for the 
  27475. current thread only before the call was made. _status87 does not affect any 
  27476. other threads that may be processing. 
  27477.  
  27478.  
  27479. ΓòÉΓòÉΓòÉ <hidden> Example of _status87 ΓòÉΓòÉΓòÉ
  27480.  
  27481. /************************************************************************
  27482.  
  27483. This example uses _status87 to get the value of the floating-point status word. 
  27484.  
  27485. ************************************************************************/
  27486.  
  27487. #include <stdio.h>
  27488. #include <float.h>
  27489.  
  27490. double a = 1e-40,b;
  27491. float x,y;
  27492.  
  27493. int main(void)
  27494. {
  27495.    printf("status = 0x%.4x - clear\n", _status87());
  27496.  
  27497.    /* change control word to mask all exceptions                              */
  27498.  
  27499.    _control87(0x037f, 0xffff);
  27500.    y = a;                     /* store into y is inexact and causes underflow */
  27501.    printf("status = 0x%.4X - inexact, underflow\n", _status87());
  27502.  
  27503.    /* reinitialize the floating point unit                                    */
  27504.  
  27505.    _fpreset();
  27506.  
  27507.    /* change control word to mask all exceptions                              */
  27508.  
  27509.    _control87(0x037f, 0xffff);
  27510.    b = y;                                                 /* y is denormal    */
  27511.    printf("status = 0x%.4X - denormal\n", _status87());
  27512.  
  27513.    /* reinitialize the floating point unit                                    */
  27514.  
  27515.    _fpreset();
  27516.    return 0;
  27517.  
  27518.    /****************************************************************************
  27519.       The output should be:
  27520.  
  27521.       status = 0x0000 - clear
  27522.       status = 0x0030 - inexact, underflow
  27523.       status = 0x0002 - denormal
  27524.    ****************************************************************************/
  27525. }
  27526.  
  27527.  
  27528. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27529.  
  27530. Example of _status87 
  27531.  
  27532.      _clear87 - Clear Floating-Point Status Word 
  27533.      _control87 - Set Floating-Point Control Word 
  27534.      _fpreset - Reset Floating-Point Unit 
  27535.      <float.h> 
  27536.  
  27537.  
  27538. ΓòÉΓòÉΓòÉ 4.267. strcat - Concatenate Strings ΓòÉΓòÉΓòÉ
  27539.  
  27540.  
  27541. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27542.  
  27543. #include <string.h>
  27544. char *strcat(char *string1, const char *string2);
  27545.  
  27546.  
  27547. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27548.  
  27549. Language Level: ANSI, SAA, POSIX, XPG4 
  27550.  
  27551. strcat concatenates string2 to string1 and ends the resulting string with the 
  27552. null character. 
  27553.  
  27554. strcat operates on null-terminated strings. The string arguments to the 
  27555. function should contain a null character (\0) marking the end of the string. No 
  27556. length checking is performed. You should not use a literal string for a string1 
  27557. value, although string2 may be a literal string. 
  27558.  
  27559. If the storage of string1 overlaps the storage of string2, the behavior is 
  27560. undefined. 
  27561.  
  27562. Return Value 
  27563. strcat returns a pointer to the concatenated string (string1). 
  27564.  
  27565.  
  27566. ΓòÉΓòÉΓòÉ <hidden> Example of strcat ΓòÉΓòÉΓòÉ
  27567.  
  27568. /************************************************************************
  27569.  
  27570. This example creates the string "computer program" using strcat. 
  27571.  
  27572. ************************************************************************/
  27573.  
  27574. #include <stdio.h>
  27575. #include <string.h>
  27576.  
  27577. #define  SIZE          40
  27578.  
  27579. int main(void)
  27580. {
  27581.    char buffer1[SIZE] = "computer";
  27582.    char *ptr;
  27583.  
  27584.    ptr = strcat(buffer1, " program");
  27585.    printf("buffer1 = %s\n", buffer1);
  27586.    return 0;
  27587.  
  27588.    /****************************************************************************
  27589.       The output should be:
  27590.  
  27591.       buffer1 = computer program
  27592.    ****************************************************************************/
  27593. }
  27594.  
  27595.  
  27596. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27597.  
  27598. Example of strcat 
  27599.  
  27600.      strchr - Search for Character 
  27601.      strcmp - Compare Strings 
  27602.      strcpy - Copy Strings 
  27603.      strcspn - Compare Strings for Substrings 
  27604.      strncat - Concatenate Strings 
  27605.      wcscat - Concatenate Wide-Character Strings 
  27606.      wcsncat - Concatenate Wide-Character Strings 
  27607.      <string.h> 
  27608.  
  27609.  
  27610. ΓòÉΓòÉΓòÉ 4.268. strchr - Search for Character ΓòÉΓòÉΓòÉ
  27611.  
  27612.  
  27613. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27614.  
  27615. #include <string.h>
  27616. char *strchr(const char *string, int c);
  27617.  
  27618.  
  27619. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27620.  
  27621. Language Level: ANSI, SAA, POSIX, XPG4 
  27622.  
  27623. strchr finds the first occurrence of a character in a string. The character c 
  27624. can be the null character (\0); the ending null character of string is included 
  27625. in the search. 
  27626.  
  27627. The strchr function operates on null-terminated strings. The string arguments 
  27628. to the function should contain a null character (\0) marking the end of the 
  27629. string. 
  27630.  
  27631. Return Value 
  27632. strchr returns a pointer to the first occurrence of c converted to a character 
  27633. in string. The function returns NULL if the specified character is not found. 
  27634.  
  27635.  
  27636. ΓòÉΓòÉΓòÉ <hidden> Example of strchr ΓòÉΓòÉΓòÉ
  27637.  
  27638. /************************************************************************
  27639.  
  27640. This example finds the first occurrence of the character p in "computer 
  27641. program". 
  27642.  
  27643. ************************************************************************/
  27644.  
  27645. #include <stdio.h>
  27646. #include <string.h>
  27647.  
  27648. #define  SIZE          40
  27649.  
  27650. int main(void)
  27651. {
  27652.    char buffer1[SIZE] = "computer program";
  27653.    char *ptr;
  27654.    int ch = 'p';
  27655.  
  27656.    ptr = strchr(buffer1, ch);
  27657.    printf("The first occurrence of %c in '%s' is '%s'\n", ch, buffer1, ptr);
  27658.    return 0;
  27659.  
  27660.    /****************************************************************************
  27661.       The output should be:
  27662.  
  27663.       The first occurrence of p in 'computer program' is 'puter program'
  27664.    ****************************************************************************/
  27665. }
  27666.  
  27667.  
  27668. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27669.  
  27670. Example of strchr 
  27671.  
  27672.      strcmp - Compare Strings 
  27673.      strcspn - Compare Strings for Substrings 
  27674.      strncmp - Compare Strings 
  27675.      strpbrk - Find Characters in String 
  27676.      strrchr - Find Last Occurrence of Character in String 
  27677.      strspn - Search Strings 
  27678.      wcschr - Search for Wide Character 
  27679.      wcsspn - Search Wide-Character Strings 
  27680.      <string.h> 
  27681.  
  27682.  
  27683. ΓòÉΓòÉΓòÉ 4.269. strcmp - Compare Strings ΓòÉΓòÉΓòÉ
  27684.  
  27685.  
  27686. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27687.  
  27688. #include <string.h>
  27689. int strcmp(const char *string1, const char *string2);
  27690.  
  27691.  
  27692. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27693.  
  27694. Language Level: ANSI, SAA, POSIX, XPG4 
  27695.  
  27696. strcmp compares string1 and string2. The function operates on null-terminated 
  27697. strings. The string arguments to the function should contain a null character 
  27698. (\0) marking the end of the string. 
  27699.  
  27700. Return Value 
  27701. strcmp returns a value indicating the relationship between the two strings, as 
  27702. follows: 
  27703.  
  27704.  Value             Meaning 
  27705.  Less than 0       string1 less than string2 
  27706.  0                 string1 identical to string2 
  27707.  Greater than 0    string1 greater than string2. 
  27708.  
  27709.  
  27710. ΓòÉΓòÉΓòÉ <hidden> Example of strcmp ΓòÉΓòÉΓòÉ
  27711.  
  27712. /************************************************************************
  27713.  
  27714. This example compares the two strings passed to main using strcmp. 
  27715.  
  27716. ************************************************************************/
  27717.  
  27718. #include <stdio.h>
  27719. #include <string.h>
  27720.  
  27721. int main(int argc,char **argv)
  27722. {
  27723.    int result;
  27724.  
  27725.    if (argc != 3) {
  27726.       printf("Usage: %s string1 string2\n", argv[0]);
  27727.    }
  27728.    else {
  27729.       result = strcmp(argv[1], argv[2]);
  27730.       if (0 == result)
  27731.          printf("\"%s\" is identical to \"%s\"\n", argv[1], argv[2]);
  27732.       else
  27733.          if (result < 0)
  27734.             printf("\"%s\" is less than \"%s\"\n", argv[1], argv[2]);
  27735.          else
  27736.             printf("\"%s\" is greater than \"%s\"\n", argv[1], argv[2]);
  27737.    }
  27738.    return 0;
  27739.  
  27740.    /****************************************************************************
  27741.       If the following arguments are passed to this program:
  27742.  
  27743.       "is this first?" "is this before that one?"
  27744.  
  27745.       The output should be:
  27746.  
  27747.       "is this first?" is greater than "is this before that one?"
  27748.    ****************************************************************************/
  27749. }
  27750.  
  27751.  
  27752. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27753.  
  27754. Example of strcmp 
  27755.  
  27756.      strcmpi - Compare Strings Without Case Sensitivity 
  27757.      strcoll - Compare Strings Using Collation Rules 
  27758.      strcspn - Compare Strings for Substrings 
  27759.      stricmp - Compare Strings as Lowercase 
  27760.      strncmp - Compare Strings 
  27761.      strnicmp - Compare Strings Without Case Sensitivity 
  27762.      wcscmp - Compare Wide-Character Strings 
  27763.      wcsncmp - Compare Wide-Character Strings 
  27764.      <string.h> 
  27765.  
  27766.  
  27767. ΓòÉΓòÉΓòÉ 4.270. strcmpi - Compare Strings Without Case Sensitivity ΓòÉΓòÉΓòÉ
  27768.  
  27769.  
  27770. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27771.  
  27772. #include <string.h>
  27773. int strcmpi(const char *string1, const char *string2);
  27774.  
  27775.  
  27776. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27777.  
  27778. Language Level:  Extension 
  27779.  
  27780. strcmpi compares string1 and string2 without sensitivity to case.  All 
  27781. alphabetic characters in the two arguments string1 and string2 are converted to 
  27782. lowercase before the comparison. 
  27783.  
  27784. The function operates on null-ended strings. The string arguments to the 
  27785. function are expected to contain a null character (\0) marking the end of the 
  27786. string. 
  27787.  
  27788. Return Value 
  27789. strcmpi returns a value indicating the relationship between the two strings, as 
  27790. follows: 
  27791.  
  27792.  Value             Meaning 
  27793.  Less than 0       string1 less than string2 
  27794.  0                 string1 equivalent to string2 
  27795.  Greater than 0    string1 greater than string2. 
  27796.  
  27797.  
  27798. ΓòÉΓòÉΓòÉ <hidden> Example of strcmpi ΓòÉΓòÉΓòÉ
  27799.  
  27800. /************************************************************************
  27801.  
  27802. This example uses strcmpi to compare two strings. 
  27803.  
  27804. ************************************************************************/
  27805.  
  27806. #include <stdio.h>
  27807. #include <string.h>
  27808.  
  27809. int main(void)
  27810. {
  27811.  
  27812.    /* Compare two strings without regard to case                              */
  27813.  
  27814.    if (0 == strcmpi("hello", "HELLO"))
  27815.       printf("The strings are equivalent.\n");
  27816.    else
  27817.       printf("The strings are not equivalent.\n");
  27818.    return 0;
  27819.  
  27820.    /****************************************************************************
  27821.       The output should be:
  27822.  
  27823.       The strings are equivalent.
  27824.    ****************************************************************************/
  27825. }
  27826.  
  27827.  
  27828. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27829.  
  27830. Example of strcmpi 
  27831.  
  27832.      strcoll - Compare Strings Using Collation Rules 
  27833.      strcspn - Compare Strings for Substrings 
  27834.      strdup - Duplicate String 
  27835.      stricmp - Compare Strings as Lowercase 
  27836.      strncmp - Compare Strings 
  27837.      strnicmp - Compare Strings Without Case Sensitivity 
  27838.      wcscmp - Compare Wide-Character Strings 
  27839.      wcsncmp - Compare Wide-Character Strings 
  27840.      <string.h> 
  27841.  
  27842.  
  27843. ΓòÉΓòÉΓòÉ 4.271. strcoll - Compare Strings Using Collation Rules ΓòÉΓòÉΓòÉ
  27844.  
  27845.  
  27846. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27847.  
  27848. #include <string.h>
  27849. int strcoll(const char *string1, const char *string2);
  27850.  
  27851.  
  27852. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27853.  
  27854. Language Level:  ANSI, SAA, XPG4 
  27855.  
  27856. strcoll compares the string pointed to by string1 against the string pointed to 
  27857. by string2, both interpreted according to the information in the LC_COLLATE 
  27858. category of the current locale. 
  27859.  
  27860. strcoll differs from the strcmp function. strcoll performs a comparison between 
  27861. two character strings based on language collation rules as controlled by the 
  27862. LC_COLLATE category. In contrast, strcmp performs a character to character 
  27863. comparison. 
  27864.  
  27865. Return Value 
  27866. strcoll returns an integer value indicating the relationship between the 
  27867. strings, as listed below: 
  27868.  
  27869.  Value             Meaning 
  27870.  Less than 0       string1 is less than string2 
  27871.  0                 string1 is equivalent to string2 
  27872.  Greater than 0    string1 is greater than string2 
  27873.  
  27874.  Note: 
  27875.  
  27876.    1. strcoll might need to allocate additional memory to perform the 
  27877.       comparison algorithm specified in the LC_COLLATE. If the memory request 
  27878.       cannot be satisfied (by malloc), then strcoll fails. 
  27879.  
  27880.    2. If the locale supports double-byte characters (MB_CUR_MAX specified as 
  27881.       2), strcoll validates the multibyte characters. (Previously, strcoll did 
  27882.       not validate the string.) strcoll will fail if the string contains 
  27883.       invalid multibyte characters. 
  27884.  
  27885.    3. If MB_CUR_MAX is specified as 2, but the charmap file does not specify 
  27886.       the DBCS characters, the DBCS characters will collate after the 
  27887.       single-byte characters. 
  27888.  
  27889.  
  27890. ΓòÉΓòÉΓòÉ <hidden> Example of strcoll ΓòÉΓòÉΓòÉ
  27891.  
  27892. /************************************************************************
  27893.  
  27894. This example compares the two strings passed to main. 
  27895.  
  27896. ************************************************************************/
  27897.  
  27898. #include <stdio.h>
  27899. #include <string.h>
  27900.  
  27901. int main(int argc,char **argv)
  27902. {
  27903.    int result;
  27904.  
  27905.    if (argc != 3) {
  27906.       printf("Usage: %s string1 string2\n", argv[0]);
  27907.    }
  27908.    else {
  27909.       result = strcoll(argv[1], argv[2]);
  27910.       if (0 == result)
  27911.          printf("\"%s\" is identical to \"%s\"\n", argv[1], argv[2]);
  27912.       else
  27913.          if (result < 0)
  27914.             printf("\"%s\" is less than \"%s\"\n", argv[1], argv[2]);
  27915.          else
  27916.             printf("\"%s\" is greater than \"%s\"\n", argv[1], argv[2]);
  27917.    }
  27918.    return 0;
  27919.  
  27920.    /****************************************************************************
  27921.       If the program is passed the following arguments:
  27922.  
  27923.       "firststring" "secondstring"
  27924.  
  27925.       The output should be:
  27926.  
  27927.       "firststring" is less than "secondstring"
  27928.    ****************************************************************************/
  27929. }
  27930.  
  27931.  
  27932. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  27933.  
  27934. Example of strcoll 
  27935.  
  27936.      setlocale - Set Locale 
  27937.      strcmp - Compare Strings 
  27938.      strcmpi - Compare Strings Without Case Sensitivity 
  27939.      strncmp - Compare Strings 
  27940.      wcscoll - Compare Wide-Character Strings 
  27941.      <string.h> 
  27942.  
  27943.  
  27944. ΓòÉΓòÉΓòÉ 4.272. strcpy - Copy Strings ΓòÉΓòÉΓòÉ
  27945.  
  27946.  
  27947. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  27948.  
  27949. #include <string.h>
  27950. char *strcpy(char *string1, const char *string2);
  27951.  
  27952.  
  27953. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  27954.  
  27955. Language Level: ANSI, SAA, POSIX, XPG4 
  27956.  
  27957. strcpy copies string2, including the ending null character, to the location 
  27958. specified by string1. 
  27959.  
  27960. strcpy operates on null-terminated strings. The string arguments to the 
  27961. function should contain a null character (\0) marking the end of the string. No 
  27962. length checking is performed. You should not use a literal string for a string1 
  27963. value, although string2 may be a literal string. 
  27964.  
  27965. Return Value 
  27966. strcpy returns a pointer to the copied string (string1.). 
  27967.  
  27968.  
  27969. ΓòÉΓòÉΓòÉ <hidden> Example of strcpy ΓòÉΓòÉΓòÉ
  27970.  
  27971. /************************************************************************
  27972.  
  27973. This example copies the contents of source to destination. 
  27974.  
  27975. ************************************************************************/
  27976.  
  27977. #include <stdio.h>
  27978. #include <string.h>
  27979.  
  27980. #define  SIZE          40
  27981.  
  27982. int main(void)
  27983. {
  27984.    char source[SIZE] = "123456789";
  27985.    char source1[SIZE] = "123456789";
  27986.    char destination[SIZE] = "abcdefg";
  27987.    char destination1[SIZE] = "abcdefg";
  27988.    char *return_string;
  27989.    int index = 5;
  27990.  
  27991.    /* This is how strcpy works                                                */
  27992.  
  27993.    printf("destination is originally = '%s'\n", destination);
  27994.    return_string = strcpy(destination, source);
  27995.    printf("After strcpy, destination becomes '%s'\n\n", destination);
  27996.  
  27997.    /* This is how strncpy works                                               */
  27998.  
  27999.    printf("destination1 is originally = '%s'\n", destination1);
  28000.    return_string = strncpy(destination1, source1, index);
  28001.    printf("After strncpy, destination1 becomes '%s'\n", destination1);
  28002.    return 0;
  28003.  
  28004.    /****************************************************************************
  28005.       The output should be:
  28006.  
  28007.       destination is originally = 'abcdefg'
  28008.       After strcpy, destination becomes '123456789'
  28009.  
  28010.       destination1 is originally = 'abcdefg'
  28011.       After strncpy, destination1 becomes '12345fg'
  28012.    ****************************************************************************/
  28013. }
  28014.  
  28015.  
  28016. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28017.  
  28018. Example of strcpy 
  28019.  
  28020.      strcat - Concatenate Strings 
  28021.      strdup - Duplicate String 
  28022.      strncpy - Copy Strings 
  28023.      wcscpy - Copy Wide-Character Strings 
  28024.      wcsncpy - Copy Wide-Character Strings 
  28025.      <string.h> 
  28026.  
  28027.  
  28028. ΓòÉΓòÉΓòÉ 4.273. strcspn - Compare Strings for Substrings ΓòÉΓòÉΓòÉ
  28029.  
  28030.  
  28031. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28032.  
  28033. #include <string.h>
  28034. size_t strcspn(const char *string1, const char *string2);
  28035.  
  28036.  
  28037. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28038.  
  28039. Language Level: ANSI, SAA, POSIX, XPG4 
  28040.  
  28041. strcspn finds the first occurrence of a character in string1 that belongs to 
  28042. the set of characters specified by string2. Ending null characters are not 
  28043. considered in the search. 
  28044.  
  28045. The strcspn function operates on null-terminated strings. The string arguments 
  28046. to the function should contain a null character (\0) marking the end of the 
  28047. string. 
  28048.  
  28049. Return Value 
  28050. strcspn returns the index of the first character found. This value is 
  28051. equivalent to the length of the initial substring of string1 that consists 
  28052. entirely of characters not in string2. 
  28053.  
  28054.  
  28055. ΓòÉΓòÉΓòÉ <hidden> Example of strcspn ΓòÉΓòÉΓòÉ
  28056.  
  28057. /************************************************************************
  28058.  
  28059. This example uses strcspn to find the first occurrence of any of the characters 
  28060. a, x, l or e in string. 
  28061.  
  28062. ************************************************************************/
  28063.  
  28064. #include <stdio.h>
  28065. #include <string.h>
  28066.  
  28067. #define  SIZE          40
  28068.  
  28069. int main(void)
  28070. {
  28071.    char string[SIZE] = "This is the source string";
  28072.    char *substring = "axle";
  28073.  
  28074.    printf("The first %i characters in the string \"%s\" are not in the "
  28075.       "string \"%s\" \n", strcspn(string, substring), string, substring);
  28076.    return 0;
  28077.  
  28078.    /****************************************************************************
  28079.       The output should be:
  28080.  
  28081.       The first 10 characters in the string "This is the source string" are not
  28082.       in the string "axle"
  28083.    ****************************************************************************/
  28084. }
  28085.  
  28086.  
  28087. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28088.  
  28089. Example of strcspn 
  28090.  
  28091.      strchr - Search for Character 
  28092.      strcmp - Compare Strings 
  28093.      strcmpi - Compare Strings Without Case Sensitivity 
  28094.      stricmp - Compare Strings as Lowercase 
  28095.      strncmp - Compare Strings 
  28096.      strnicmp - Compare Strings Without Case Sensitivity 
  28097.      strpbrk - Find Characters in String 
  28098.      strspn - Search Strings 
  28099.      wcscmp - Compare Wide-Character Strings 
  28100.      wcsncmp - Compare Wide-Character Strings 
  28101.      <string.h> 
  28102.  
  28103.  
  28104. ΓòÉΓòÉΓòÉ 4.274. _strdate - Copy Current Date ΓòÉΓòÉΓòÉ
  28105.  
  28106.  
  28107. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28108.  
  28109. #include <time.h>
  28110. char *_strdate(char *date);
  28111.  
  28112.  
  28113. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28114.  
  28115. Language Level:  Extension 
  28116.  
  28117. _strdate stores the current date as a string in the buffer pointed to by date 
  28118. in the following format: 
  28119.  
  28120.    mm/dd/yy
  28121.  
  28122. The two digits mm represent the month, the digits dd represent the day of the 
  28123. month, and the digits yy represent the year.  For example, the string 10/08/91 
  28124. represents October 8, 1991. The buffer must be at least 9 bytes. 
  28125.  
  28126. Note:  The time and date functions begin at 00:00 Coordinated Universal Time, 
  28127. January 1, 1970. 
  28128.  
  28129. Return Value 
  28130. _strdate returns a pointer to the buffer containing the date string.  There is 
  28131. no error return. 
  28132.  
  28133.  
  28134. ΓòÉΓòÉΓòÉ <hidden> Example of _strdate ΓòÉΓòÉΓòÉ
  28135.  
  28136. /************************************************************************
  28137.  
  28138. This example prints the current date. 
  28139.  
  28140. ************************************************************************/
  28141.  
  28142. #include <stdio.h>
  28143. #include <time.h>
  28144.  
  28145. int main(void)
  28146. {
  28147.    char buffer[9];
  28148.  
  28149.    printf("The current date is %s \n", _strdate(buffer));
  28150.    return 0;
  28151.  
  28152.    /****************************************************************************
  28153.       The output should be similar to:
  28154.  
  28155.       The current date is 01/02/95
  28156.    ****************************************************************************/
  28157. }
  28158.  
  28159.  
  28160. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28161.  
  28162. Example of _strdate 
  28163.  
  28164.      asctime - Convert Time to Character String 
  28165.      ctime - Convert Time to Character String 
  28166.      _ftime - Store Current Time 
  28167.      gmtime - Convert Time 
  28168.      localtime - Convert Time 
  28169.      mktime - Convert Local Time 
  28170.      time - Determine Current Time 
  28171.      tzset - Assign Values to Locale Information 
  28172.      <time.h> 
  28173.  
  28174.  
  28175. ΓòÉΓòÉΓòÉ 4.275. strdup - Duplicate String ΓòÉΓòÉΓòÉ
  28176.  
  28177.  
  28178. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28179.  
  28180. #include <string.h>
  28181. char *strdup(const char *string);
  28182.  
  28183.  
  28184. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28185.  
  28186. Language Level:  XPG2, Extension 
  28187.  
  28188. strdup reserves storage space for a copy of string by calling malloc. The 
  28189. string argument to this function is expected to contain a null character (\0) 
  28190. marking the end of the string. Remember to free the storage reserved with the 
  28191. call to strdup. 
  28192.  
  28193. Return Value 
  28194. strdup returns a pointer to the storage space containing the copied string. If 
  28195. it cannot reserve storage strdup returns NULL. 
  28196.  
  28197.  
  28198. ΓòÉΓòÉΓòÉ <hidden> Example of strdup ΓòÉΓòÉΓòÉ
  28199.  
  28200. /************************************************************************
  28201.  
  28202. This example uses strdup to duplicate a string and print the copy. 
  28203.  
  28204. ************************************************************************/
  28205.  
  28206. #include <stdio.h>
  28207. #include <string.h>
  28208.  
  28209. int main(void)
  28210. {
  28211.    char *string = "this is a copy";
  28212.    char *newstr;
  28213.  
  28214.    /* Make newstr point to a duplicate of string                              */
  28215.  
  28216.    if ((newstr = strdup(string)) != NULL)
  28217.       printf("The new string is: %s\n", newstr);
  28218.    return 0;
  28219.  
  28220.    /****************************************************************************
  28221.       The output should be:
  28222.  
  28223.       The new string is: this is a copy
  28224.    ****************************************************************************/
  28225. }
  28226.  
  28227.  
  28228. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28229.  
  28230. Example of strdup 
  28231.  
  28232.      strcpy - Copy Strings 
  28233.      strncpy - Copy Strings 
  28234.      wcscpy - Copy Wide-Character Strings 
  28235.      wcsncpy - Copy Wide-Character Strings 
  28236.      <string.h> 
  28237.  
  28238.  
  28239. ΓòÉΓòÉΓòÉ 4.276. strerror - Set Pointer to Runtime Error Message ΓòÉΓòÉΓòÉ
  28240.  
  28241.  
  28242. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28243.  
  28244. #include <string.h>
  28245. char *strerror(int errnum);
  28246.  
  28247.  
  28248. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28249.  
  28250. Language Level:  ANSI, SAA, XPG4 
  28251.  
  28252. strerror maps the error number in errnum to an error message string. 
  28253.  
  28254. Return Value 
  28255. strerror returns a pointer to the string. It does not use the program locale in 
  28256. any way. 
  28257.  
  28258. The value of errno may be set to: 
  28259.  
  28260.  EILSEQ  An encoding error has occurred converting a multibyte character. 
  28261.  E2BIG   The output buffer is too small. 
  28262.  
  28263.  
  28264. ΓòÉΓòÉΓòÉ <hidden> Example of strerror ΓòÉΓòÉΓòÉ
  28265.  
  28266. /************************************************************************
  28267.  
  28268. This example opens a file and prints a runtime error message if an error 
  28269. occurs. 
  28270.  
  28271. ************************************************************************/
  28272.  
  28273. #include <stdio.h>
  28274. #include <string.h>
  28275. #include <errno.h>
  28276.  
  28277. #define FILENAME "strerror.dat"
  28278.  
  28279. int main(void)
  28280. {
  28281.    FILE *stream;
  28282.  
  28283.    if (NULL == (stream = fopen(FILENAME, "r")))
  28284.       printf(" %s \n", strerror(errno));
  28285.    return 0;
  28286. }
  28287.  
  28288.  
  28289. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28290.  
  28291. Example of strerror 
  28292.  
  28293.      clearerr - Reset Error Indicators. 
  28294.      ferror - Test for Read/Write Errors 
  28295.      perror - Print Error Message 
  28296.      _strerror - Set Pointer to System Error String 
  28297.      <string.h> 
  28298.  
  28299.  
  28300. ΓòÉΓòÉΓòÉ 4.277. _strerror - Set Pointer to System Error String ΓòÉΓòÉΓòÉ
  28301.  
  28302.  
  28303. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28304.  
  28305. #include <string.h>
  28306. char *_strerror(char *string);
  28307.  
  28308.  
  28309. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28310.  
  28311. Language Level:  Extension 
  28312.  
  28313. _strerror tests for system error. It gets the system error message for the last 
  28314. library call that produced an error and prefaces it with your string message. 
  28315.  
  28316. Your string message can be a maximum of 94 bytes. 
  28317.  
  28318. Unlike perror, _strerror by itself does not print a message.  To print the 
  28319. message returned by _strerror to stdout, use a printf statement similar to the 
  28320. following: 
  28321.  
  28322.    if ((access("datafile",2)) == -1)
  28323.       printf(stderr,_strerror(NULL));
  28324.  
  28325. You could also print the message to stderr with an fprintf statement. 
  28326.  
  28327. To produce accurate results, call _strerror immediately after a library 
  28328. function returns with an error. Otherwise, subsequent calls might write over 
  28329. the errno value. 
  28330.  
  28331. Return Value 
  28332. If string is equal to NULL, _strerror returns a pointer to a string containing 
  28333. the system error message for the last library call that produced an error, 
  28334. ended by a new-line character (\n). 
  28335.  
  28336. If string is not equal to NULL, _strerror returns a pointer to a string 
  28337. containing: 
  28338.  
  28339.      Your string message 
  28340.      A colon 
  28341.      A space 
  28342.      The system error message for the last library call producing an error 
  28343.      A new-line character (\n). 
  28344.  
  28345.  
  28346. ΓòÉΓòÉΓòÉ <hidden> Example of _strerror ΓòÉΓòÉΓòÉ
  28347.  
  28348. /************************************************************************
  28349.  
  28350. This example shows how _strerror can be used with the fopen function. 
  28351.  
  28352. ************************************************************************/
  28353.  
  28354. #include <string.h>
  28355. #include <stdio.h>
  28356.  
  28357. #define INFILE    "_strerro.in"
  28358. #define OUTFILE   "_strerro.out"
  28359.  
  28360. int main(void)
  28361. {
  28362.    FILE *fh1,*fh2;
  28363.  
  28364.    fh1 = fopen(INFILE, "r");
  28365.    if (NULL == fh1)
  28366.      /*  the error message goes through stdout not stderr                     */
  28367.       printf(_strerror("Open failed on input file"));
  28368.    fh2 = fopen(OUTFILE, "w+");
  28369.    if (NULL == fh2)
  28370.       printf(_strerror("Open failed on output file"));
  28371.    else
  28372.       printf("Open on output file was successful.\n");
  28373.    if (fh1 != NULL)
  28374.       fclose(fh1);
  28375.    if (fh2 != NULL)
  28376.       fclose(fh2);
  28377.    remove(OUTFILE);
  28378.    return 0;
  28379.  
  28380.    /****************************************************************************
  28381.       The output should be:
  28382.  
  28383.       Open failed on input file: The file cannot be found.
  28384.       Open on output file was successful.
  28385.    ****************************************************************************/
  28386. }
  28387.  
  28388.  
  28389. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28390.  
  28391. Example of _strerror 
  28392.  
  28393.      clearerr - Reset Error Indicators. 
  28394.      ferror - Test for Read/Write Errors 
  28395.      perror - Print Error Message 
  28396.      strerror - Set Pointer to Runtime Error Message 
  28397.      <string.h> 
  28398.  
  28399.  
  28400. ΓòÉΓòÉΓòÉ 4.278. strfmon - Convert Monetary Value to String ΓòÉΓòÉΓòÉ
  28401.  
  28402.  
  28403. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28404.  
  28405. #include <monetary.h>
  28406. int strfmon(char *s, size_t maxsize, const char *format, ...);
  28407.  
  28408.  
  28409. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28410.  
  28411. Language Level:  XPG4 
  28412.  
  28413. strfmon places characters into the array pointed to by *s, as controlled by the 
  28414. string pointed to by format. No more than maxsize characters are placed into 
  28415. the array. 
  28416.  
  28417. The character string format contains two types of objects: 
  28418.  
  28419.      Plain characters, which are copied to the output array. 
  28420.      Directives, each of which results in the fetching of zero or more 
  28421.       arguments that are converted and formatted. 
  28422.  
  28423.  The results are undefined if there are insufficient arguments for the format. 
  28424.  If the format is exhausted while arguments remain, the excess arguments are 
  28425.  simply ignored. If objects pointed to by s and format overlap, the behavior is 
  28426.  undefined. 
  28427.  
  28428.  The directive (conversion specification) consists of the following sequence. 
  28429.  
  28430.    1. A % character 
  28431.  
  28432.    2. Optional flags, described below: =f, ^, then +, C, (, then ! 
  28433.  
  28434.    3. Optional field width (may be preceded by -) 
  28435.  
  28436.    4. Optional left precision: #n 
  28437.  
  28438.    5. Optional right precision: .p 
  28439.  
  28440.    6. Required conversion character to indicate what conversion should be 
  28441.       performed: i or n. 
  28442.  
  28443.  Each directive is replaced by the appropriate characters, as described in the 
  28444.  following list: 
  28445.  
  28446.  %i          The double argument is formatted according to the locale's 
  28447.              international currency format (for example, in USA: USD 1,234.56). 
  28448.  
  28449.  %n          The double argument is formatted according to the locale's 
  28450.              national currency format (for example, in USA: $1,234.56). 
  28451.  
  28452.  %% is replaced by %. No argument is converted. 
  28453.  
  28454.  You can give optional conversion specifications immediately after the initial 
  28455.  % of a directive in the following order: 
  28456.  
  28457.  Specifier   Meaning 
  28458.  
  28459.  =f          Specifies f as the numeric fill character. This flag is used in 
  28460.              conjunction with the maximum digits specification #n (see below). 
  28461.              The default numeric fill character is the space character. This 
  28462.              option does not affect the other fill operations that always use a 
  28463.              space as the fill character. 
  28464.  
  28465.  ^           Formats the currency amount without thousands grouping characters. 
  28466.              The default is to insert the grouping characters if defined for 
  28467.              the current locale. 
  28468.  
  28469.  + | C | (   Specifies the style of representing positive and negative currency 
  28470.              amounts. You can specify only one of +, C, or (. The + specifies 
  28471.              to use the locale's equivalent of + and -. For example, in USA, 
  28472.              the empty (null) string if positive and - if negative. C specifies 
  28473.              to use the locale's equivalent of DB for negative and CR for 
  28474.              positive. The ( specifies to use the locale's equivalent of 
  28475.              enclosing negative amounts within parenthesis. If this option is 
  28476.              not included, a default specified by the current locale is used. 
  28477.  
  28478.  !           Suppresses the currency symbol from the output conversion. 
  28479.  
  28480.  [-]w        A decimal digit string that specifies a minimum field width in 
  28481.              which the result of the conversion is right-justified (or 
  28482.              left-justified if the - flag is specified). 
  28483.  
  28484.  #n          A decimal digit string that specifies a maximum number of digits 
  28485.              expected to be formatted to the left of the radix character. You 
  28486.              can use this option to keep the formatted output from multiple 
  28487.              calls to strfmon aligned in the same columns. You can also use it 
  28488.              to fill unused positions with a special character, as in 
  28489.              $***123.45. This option causes an amount to be formatted as if it 
  28490.              has the number of digits specified by n. If more digit positions 
  28491.              are required than specified, this conversion specification is 
  28492.              ignored. Digit positions in excess of those actually required are 
  28493.              filled with the numeric fill character. (See the =f specification 
  28494.              above). 
  28495.  
  28496.              If thousands grouping is enabled, the behavior is: 
  28497.  
  28498.                1. Format the number as if it is an n digit number. 
  28499.  
  28500.                2. Insert fill characters to the left of the leftmost digit (for 
  28501.                   example, $0001234.56 or $***1234.56). 
  28502.  
  28503.                3. Insert the separator character (for example, $0,001,234.56 or 
  28504.                   $*,**1,234.56). 
  28505.  
  28506.                4. If the fill character is not the digit zero, the separators 
  28507.                   are replaced by the fill character (for example, 
  28508.                   $****1,234.56). 
  28509.  
  28510.              To ensure alignment, any characters appearing before or after the 
  28511.              number in the formatted output, such as currency or sign symbols, 
  28512.              are padded with space characters to make their positive and 
  28513.              negative formats an equal length. 
  28514.  
  28515.  .p          A decimal digit string that specifies the number of digits after 
  28516.              the radix character. If the value of the precision p is 0, no 
  28517.              radix character appears. If this option is not included, a default 
  28518.              specified by the current locale is used. The amount being 
  28519.              formatted is rounded to the specified number of digits prior to 
  28520.              formatting. 
  28521.  
  28522.  The LC_MONETARY category of the program's locale affects the behavior of this 
  28523.  function, including the monetary radix character (which is different from the 
  28524.  numeric radix character affected by the LC_NUMERIC category), the thousands 
  28525.  (or alternate grouping) separator, the currency symbols, and formats. The 
  28526.  international currency symbol should be in accordance with those specified in 
  28527.  ISO 4217 Codes for the representation of currencies and funds. 
  28528.  
  28529.  Return Value 
  28530.  If the total number of resulting bytes including the terminating null 
  28531.  character is not more than maxsize, strfmon returns the number of bytes placed 
  28532.  into the array pointed to by s, not including the terminating null character. 
  28533.  Otherwise, strfmon returns -1 and the contents of the array are indeterminate. 
  28534.  
  28535.  
  28536. ΓòÉΓòÉΓòÉ <hidden> Example of strfmon ΓòÉΓòÉΓòÉ
  28537.  
  28538. /************************************************************************
  28539.  
  28540. This example uses strfmon to format the monetary value for money, then prints 
  28541. the resulting string. 
  28542.  
  28543. ************************************************************************/
  28544.  
  28545. #include <monetary.h>
  28546. #include <locale.h>
  28547. #include <stdio.h>
  28548. #include <stdlib.h>
  28549.  
  28550. int main(void)
  28551. {
  28552.    char   string[100];     /* hold the string returned from strfmon() */
  28553.    double money = 1234.56;
  28554.  
  28555.    if (NULL == setlocale(LC_ALL, "en_us.ibm-850")) {
  28556.       printf("Unable to setlocale().\n");
  28557.       exit(EXIT_FAILURE);
  28558.    }
  28559.    strfmon(string, 100, "%i", money);
  28560.    printf("International currency format = \"%s\"\n", string);
  28561.    strfmon(string, 100, "%n", money);
  28562.    printf("National currency format      = \"%s\"\n", string);
  28563.    return 0;
  28564.  
  28565.    /****************************************************************************
  28566.       The output should be similar to :
  28567.  
  28568.       International currency format = "USD 1,234.56"
  28569.       National currency format      = "$1,234.56"
  28570.    ****************************************************************************/
  28571. }
  28572.  
  28573.  
  28574. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28575.  
  28576. Example of strfmon 
  28577.  
  28578.      strftime - Convert to Formatted Time 
  28579.      <monetary.h> 
  28580.  
  28581.  
  28582. ΓòÉΓòÉΓòÉ 4.279. strftime - Convert to Formatted Time ΓòÉΓòÉΓòÉ
  28583.  
  28584.  
  28585. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28586.  
  28587. #include <time.h>
  28588. size_t strftime(char *dest, size_t maxsize,
  28589.                 const char *format, const struct tm *timeptr);
  28590.  
  28591.  
  28592. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28593.  
  28594. Language Level:  ANSI, SAA, XPG4, POSIX 
  28595.  
  28596. strftime converts the time and date specification in the timeptr structure into 
  28597. a character string.  It then stores the null-terminated string in the array 
  28598. pointed to by dest according to the format string pointed to by format. maxsize 
  28599. specifies the maximum number of characters that can be copied into the array. 
  28600.  
  28601. The format string is a multibyte character string containing: 
  28602.  
  28603.      Conversion specification characters, preceded by a % sign. 
  28604.      Ordinary multibyte characters, which are copied into the array unchanged. 
  28605.  
  28606.  If data has the form of a conversion specifier, but is not one of the accepted 
  28607.  specifiers, the characters following the % are copied to the output. 
  28608.  
  28609.  The characters that are converted are determined by the LC_CTYPE category of 
  28610.  the current locale and by the values in the time structure pointed to by 
  28611.  timeptr. The time structure pointed to by timeptr is usually obtained by 
  28612.  calling the gmtime or localtime function. 
  28613.  
  28614.  When objects to be copied overlap, the behavior is undefined. 
  28615.  
  28616.  strftime obtains time zone information from an internal structure.  You can 
  28617.  set the values in this structure by calling either tzset or setlocale. tzset 
  28618.  sets the structure according to the information in the TZ environment 
  28619.  variable; setlocale sets it according to the LC_TOD category in the current 
  28620.  locale.  If you do not set the values by calling one of these functions, the 
  28621.  defaults used are EST for time zone name, EDT for Daylight Savings time zone 
  28622.  name, and 300 minutes for time zone. 
  28623.  
  28624.  Return Value 
  28625.  If the total number of characters in the resulting string, including the 
  28626.  terminating null character, does not exceed maxsize, strftime returns the 
  28627.  number of characters (bytes) placed into dest, not including the terminating 
  28628.  null character. Otherwise, strftime returns 0 and the content of the string is 
  28629.  indeterminate. 
  28630.  
  28631.  
  28632. ΓòÉΓòÉΓòÉ <hidden> Example of strftime ΓòÉΓòÉΓòÉ
  28633.  
  28634. /************************************************************************
  28635.  
  28636. This example gets the time and date from localtime, calls strftime to format 
  28637. it, and prints the resulting string. 
  28638.  
  28639. ************************************************************************/
  28640.  
  28641. #include <stdio.h>
  28642. #include <time.h>
  28643.  
  28644. int main(void)
  28645. {
  28646.    char dest[70];
  28647.    int ch;
  28648.    time_t temp;
  28649.    struct tm *timeptr;
  28650.  
  28651.    temp = time(NULL);
  28652.    timeptr = localtime(&temp);
  28653.    ch = strftime(dest, sizeof(dest)-1, "Today is %A,"" %b %d. \n Time: %I:%M %p"
  28654.       , timeptr);
  28655.    printf("%d characters placed in string to make: \n \n %s", ch, dest);
  28656.    return 0;
  28657.  
  28658.    /****************************************************************************
  28659.       The output should be similar to:
  28660.  
  28661.       41 characters placed in string to make:
  28662.        Today is Monday, Sep 16.
  28663.        Time: 06:31 pm
  28664.    ****************************************************************************/
  28665. }
  28666.  
  28667.  
  28668. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28669.  
  28670. Example of strftime 
  28671.  
  28672.      Conversion Specifiers Used by strftime 
  28673.      asctime - Convert Time to Character String 
  28674.      ctime - Convert Time to Character String 
  28675.      gmtime - Convert Time 
  28676.      localtime - Convert Time 
  28677.      setlocale - Set Locale 
  28678.      strptime - Convert to Formatted Date and Time 
  28679.      time - Determine Current Time 
  28680.      wcsftime - Convert to Formatted Date and Time 
  28681.      <time.h> 
  28682.  
  28683.  
  28684. ΓòÉΓòÉΓòÉ 4.279.1. Conversion Specifiers Used by strftime ΓòÉΓòÉΓòÉ
  28685.  
  28686. The following table lists the strftime conversion specifiers: 
  28687.  
  28688. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  28689. Γöé SPECIFIER     Γöé MEANING                          Γöé
  28690. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28691. Γöé %a        Γöé Replace with abbreviated weekday name of locale.      Γöé
  28692. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28693. Γöé %A        Γöé Replace with full weekday name of locale.         Γöé
  28694. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28695. Γöé %b        Γöé Replace with abbreviated month name of locale.       Γöé
  28696. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28697. Γöé %B        Γöé Replace with full month name of locale.          Γöé
  28698. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28699. Γöé %c        Γöé Replace with date and time of locale.           Γöé
  28700. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28701. Γöé %C        Γöé Replace with locale's century number (year divided by 100 Γöé
  28702. Γöé          Γöé and truncated)                       Γöé
  28703. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28704. Γöé %d        Γöé Replace with day of the month (01-31).           Γöé
  28705. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28706. Γöé %D        Γöé Insert date in mm/dd/yy form, regardless of locale.    Γöé
  28707. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28708. Γöé %e        Γöé Insert month of the year as a decimal number ("01"-"12"). Γöé
  28709. Γöé          Γöé                              Γöé
  28710. Γöé          Γöé Under POSIX, it's a 2-character, right-justified, blank-  Γöé
  28711. Γöé          Γöé filled field.                       Γöé
  28712. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28713. Γöé %E[cCxXyY]    Γöé If the alternate date/time format is not available, the  Γöé
  28714. Γöé          Γöé %E descriptors are mapped to their unextended counter-   Γöé
  28715. Γöé          Γöé parts.  For example, %EC is mapped to %C.         Γöé
  28716. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28717. Γöé %Ec        Γöé Replace with the locale's alternative date and time rep-  Γöé
  28718. Γöé          Γöé resentation.                        Γöé
  28719. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28720. Γöé %EC        Γöé Replace with the name of the base year (period) in the   Γöé
  28721. Γöé          Γöé locale's alternate representation.             Γöé
  28722. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28723. Γöé %Ex        Γöé Replace with the locale's alternative date represen-    Γöé
  28724. Γöé          Γöé tation.                          Γöé
  28725. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28726. Γöé %EX        Γöé Replace with the locale's alternative time represen-    Γöé
  28727. Γöé          Γöé tation.                          Γöé
  28728. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28729. Γöé %Ey        Γöé Replace with the offset from %EC (year only) in the    Γöé
  28730. Γöé          Γöé locale's alternate representation.             Γöé
  28731. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28732. Γöé %EY        Γöé Replace with the full alternative year representation.   Γöé
  28733. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28734. Γöé %h        Γöé Replace with locale's abbreviated month name. This is the Γöé
  28735. Γöé          Γöé same as %b.                        Γöé
  28736. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28737. Γöé %H        Γöé Replace with hour (24-hour clock) as a decimal number   Γöé
  28738. Γöé          Γöé (00-23).                          Γöé
  28739. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28740. Γöé %I        Γöé Replace with hour (12-hour clock) as a decimal number   Γöé
  28741. Γöé          Γöé (01-12).                          Γöé
  28742. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28743. Γöé %j        Γöé Replace with day of the year (001-366).          Γöé
  28744. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28745. Γöé %m        Γöé Replace with month (01-12).                Γöé
  28746. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28747. Γöé %M        Γöé Replace with minute (00-59).                Γöé
  28748. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28749. Γöé %n        Γöé Replace with a new line.                  Γöé
  28750. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28751. Γöé %O[deHImMSUwWy]  Γöé                              Γöé
  28752. Γöé          Γöé                              Γöé
  28753. Γöé          Γöé If the alternative date/time format is not available, the Γöé
  28754. Γöé          Γöé %O descriptors are mapped to their unextended counter-   Γöé
  28755. Γöé          Γöé parts.  For example, %Od is mapped to %d.         Γöé
  28756. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28757. Γöé %Od        Γöé Replace with the day of month, using the locale's alter-  Γöé
  28758. Γöé          Γöé native numeric symbols, filled as needed with leading   Γöé
  28759. Γöé          Γöé zeroes if there is any alternative symbol for zero; oth-  Γöé
  28760. Γöé          Γöé erwise fill with leading spaces.              Γöé
  28761. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28762. Γöé %Oe        Γöé Replace with the day of the month, using the locale's   Γöé
  28763. Γöé          Γöé alternative numeric symbols, filled as needed with     Γöé
  28764. Γöé          Γöé leading spaces.                      Γöé
  28765. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28766. Γöé %OH        Γöé Replace with the hour (24-hour clock), using the locale's Γöé
  28767. Γöé          Γöé alternative numeric symbols.                Γöé
  28768. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28769. Γöé %OI        Γöé Replace with the hour (12-hour clock), using the locale's Γöé
  28770. Γöé          Γöé alternative numeric symbols.                Γöé
  28771. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  28772. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  28773. Γöé %Om        Γöé Replace with the month, using the locale's alternative   Γöé
  28774. Γöé          Γöé numeric symbols.                      Γöé
  28775. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28776. Γöé %OM        Γöé Replace with the minutes, using the locale's alternative  Γöé
  28777. Γöé          Γöé numeric symbols.                      Γöé
  28778. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28779. Γöé %OS        Γöé Replace with the seconds, using the locale's alternative  Γöé
  28780. Γöé          Γöé numeric symbols.                      Γöé
  28781. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28782. Γöé %Ou        Γöé Replace with the weekday as a decimal number (1 to 7),   Γöé
  28783. Γöé          Γöé with 1 representing Monday, using the locale's alterna-  Γöé
  28784. Γöé          Γöé tive numeric symbols.                   Γöé
  28785. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28786. Γöé %OU        Γöé Replace with the week number of the year (00-53), where  Γöé
  28787. Γöé          Γöé Sunday is the first day of the week, using the locale's  Γöé
  28788. Γöé          Γöé alternative numeric symbols.                Γöé
  28789. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28790. Γöé &OV        Γöé Replace with week number of the year (01-53), where    Γöé
  28791. Γöé          Γöé Monday is the first day of the week, using the locale's  Γöé
  28792. Γöé          Γöé alternative numeric symbols.                Γöé
  28793. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28794. Γöé %Ow        Γöé Replace with the weekday (Sunday=0), using the locale's  Γöé
  28795. Γöé          Γöé alternative numeric symbols.                Γöé
  28796. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28797. Γöé %OW        Γöé Replace with the week number of the year (01-53), where  Γöé
  28798. Γöé          Γöé Monday is the first day of the week, using the locale's  Γöé
  28799. Γöé          Γöé alternative numeric symbols.                Γöé
  28800. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28801. Γöé %Oy        Γöé Replace with the year (offset from %C) in the locale's   Γöé
  28802. Γöé          Γöé alternative representation, using the locale's alterna-  Γöé
  28803. Γöé          Γöé tive numeric symbols.                   Γöé
  28804. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28805. Γöé %p        Γöé Replace with the locale's equivalent of AM or PM.     Γöé
  28806. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28807. Γöé %r        Γöé Replace with a string equivalent to %I:%M:%S %p; or use  Γöé
  28808. Γöé          Γöé "t_fmt_ampm" from LC_TIME, if present.           Γöé
  28809. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28810. Γöé %R        Γöé Replace with time in 24 hour notation (%H:%M)       Γöé
  28811. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28812. Γöé %S        Γöé Replace with second (00-61).                Γöé
  28813. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28814. Γöé %t        Γöé Replace with a tab.                    Γöé
  28815. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28816. Γöé %T        Γöé Replace with a string equivalent to %H:%M:%S.       Γöé
  28817. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28818. Γöé %u        Γöé Replace with the weekday as a decimal number (1 to 7),   Γöé
  28819. Γöé          Γöé with 1 representing Monday.                Γöé
  28820. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28821. Γöé %U        Γöé Replace with week number of the year (00-53), where    Γöé
  28822. Γöé          Γöé Sunday is the first day of the week.            Γöé
  28823. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28824. Γöé %V        Γöé Replace with week number of the year (01-53), where    Γöé
  28825. Γöé          Γöé Monday is the first day of the week.            Γöé
  28826. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28827. Γöé %w        Γöé Replace with weekday (0-6), where Sunday is 0.       Γöé
  28828. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28829. Γöé %W        Γöé Replace with week number of the year (00-53), where    Γöé
  28830. Γöé          Γöé Monday is the first day of the week.            Γöé
  28831. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28832. Γöé %x        Γöé Replace with date representation of locale.        Γöé
  28833. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28834. Γöé %X        Γöé Replace with time representation of locale.        Γöé
  28835. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28836. Γöé %y        Γöé Replace with year without the century (00-99).       Γöé
  28837. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28838. Γöé %Y        Γöé Replace with year including the century.          Γöé
  28839. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28840. Γöé %Z        Γöé Replace with name of time zone, or no characters if time  Γöé
  28841. Γöé          Γöé zone is not available.                   Γöé
  28842. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  28843. Γöé %%        Γöé Replace with %.                      Γöé
  28844. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  28845.  
  28846. For %Z, the tm_isdst flag in the tm structure passed to strftime specifies 
  28847. whether the time zone is standard or Daylight Savings time. 
  28848.  
  28849. If data has the form of a directive, but is not one of the above, the 
  28850. characters following the % are copied to the output. 
  28851.  
  28852.  
  28853. ΓòÉΓòÉΓòÉ 4.280. stricmp - Compare Strings as Lowercase ΓòÉΓòÉΓòÉ
  28854.  
  28855.  
  28856. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28857.  
  28858. #include <string.h>
  28859. int stricmp(const char *string1, const char *string2);
  28860.  
  28861.  
  28862. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28863.  
  28864. Language Level:  Extension 
  28865.  
  28866. stricmp compares string1 and string2 without sensitivity for case. All 
  28867. alphabetic characters in the arguments string1 and string2 are converted to 
  28868. lowercase before the comparison. stricmp operates on null-terminated strings. 
  28869.  
  28870. Return Value 
  28871. stricmp returns a value that indicates the following relationship between the 
  28872. two strings : 
  28873.  
  28874.  Value             Meaning 
  28875.  Less than 0       string1 less than string2 
  28876.  0                 string1 identical to string2 
  28877.  Greater than 0    string1 greater than string2. 
  28878.  
  28879.  
  28880. ΓòÉΓòÉΓòÉ <hidden> Example of stricmp ΓòÉΓòÉΓòÉ
  28881.  
  28882. /************************************************************************
  28883.  
  28884. This example uses stricmp to compare two strings. 
  28885.  
  28886. ************************************************************************/
  28887.  
  28888. #include <stdio.h>
  28889. #include <string.h>
  28890.  
  28891. int main(void)
  28892. {
  28893.    char *str1 = "this is a string";
  28894.    char *str2 = "THIS IS A STRING";
  28895.  
  28896.    /* Compare two strings without regard to case                              */
  28897.  
  28898.    if (stricmp(str1, str2))
  28899.       printf("str1 is not the same as str2\n");
  28900.    else
  28901.       printf("str1 is the same as str2\n");
  28902.    return 0;
  28903.  
  28904.    /****************************************************************************
  28905.       The output should be:
  28906.  
  28907.       str1 is the same as str2
  28908.    ****************************************************************************/
  28909. }
  28910.  
  28911.  
  28912. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28913.  
  28914. Example of stricmp 
  28915.  
  28916.      strcmp - Compare Strings 
  28917.      strcmpi - Compare Strings Without Case Sensitivity 
  28918.      strcspn - Compare Strings for Substrings 
  28919.      strncmp - Compare Strings 
  28920.      strnicmp - Compare Strings Without Case Sensitivity 
  28921.      wcscmp - Compare Wide-Character Strings 
  28922.      wcsncmp - Compare Wide-Character Strings 
  28923.      <string.h> 
  28924.  
  28925.  
  28926. ΓòÉΓòÉΓòÉ 4.281. strlen - Determine String Length ΓòÉΓòÉΓòÉ
  28927.  
  28928.  
  28929. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28930.  
  28931. #include <string.h>
  28932. size_t strlen(const char *string);
  28933.  
  28934.  
  28935. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28936.  
  28937. Language Level: ANSI, SAA, POSIX, XPG4 
  28938.  
  28939. strlen determines the length of string excluding the terminating null 
  28940. character. 
  28941.  
  28942. Return Value 
  28943. strlen returns the length of string. 
  28944.  
  28945.  
  28946. ΓòÉΓòÉΓòÉ <hidden> Example of strlen ΓòÉΓòÉΓòÉ
  28947.  
  28948. /************************************************************************
  28949.  
  28950. This example determines the length of the string that is passed to main. 
  28951.  
  28952. ************************************************************************/
  28953.  
  28954. #include <stdio.h>
  28955. #include <string.h>
  28956.  
  28957. int main(int argc,char **argv)
  28958. {
  28959.    char *String = "How long is this string?";
  28960.  
  28961.    printf("Length of string \"%s\" is %i.\n", String, strlen(String));
  28962.    return 0;
  28963.  
  28964.    /****************************************************************************
  28965.       The output should be:
  28966.  
  28967.       Length of string "How long is this string?" is 24.
  28968.    ****************************************************************************/
  28969. }
  28970.  
  28971.  
  28972. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  28973.  
  28974. Example of strlen 
  28975.  
  28976.      mblen - Determine Length of Multibyte Character 
  28977.      strrev - Reverse String 
  28978.      wcslen - Calculate Length of Wide-Character String 
  28979.      <string.h> 
  28980.  
  28981.  
  28982. ΓòÉΓòÉΓòÉ 4.282. strlwr - Convert Uppercase to Lowercase ΓòÉΓòÉΓòÉ
  28983.  
  28984.  
  28985. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  28986.  
  28987. #include <string.h>
  28988. char *strlwr(char *string);
  28989.  
  28990.  
  28991. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  28992.  
  28993. Language Level:  Extension 
  28994.  
  28995. strlwr converts any uppercase letters in the given null-terminated string to 
  28996. lowercase.  Other characters are not affected. 
  28997.  
  28998. Return Value 
  28999. strlwr returns a pointer to the converted string. There is no error return. 
  29000.  
  29001.  
  29002. ΓòÉΓòÉΓòÉ <hidden> Example of strlwr ΓòÉΓòÉΓòÉ
  29003.  
  29004. /************************************************************************
  29005.  
  29006. This example makes a copy in all lowercase of the string "General Assembly", 
  29007. and then prints the copy. 
  29008.  
  29009. ************************************************************************/
  29010.  
  29011. #include <string.h>
  29012. #include <stdio.h>
  29013.  
  29014. int main(void)
  29015. {
  29016.    char *string = "General Assembly";
  29017.    char *copy;
  29018.  
  29019.    copy = strlwr(strdup(string));
  29020.    printf("Expected result: general assembly\n");
  29021.    printf("strlwr returned: %s\n", copy);
  29022.    return 0;
  29023.  
  29024.    /****************************************************************************
  29025.       The output should be:
  29026.  
  29027.       Expected result: general assembly
  29028.       strlwr returned: general assembly
  29029.    ****************************************************************************/
  29030. }
  29031.  
  29032.  
  29033. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29034.  
  29035. Example of strlwr 
  29036.  
  29037.      strupr - Convert Lowercase to Uppercase 
  29038.      _toascii - _tolower - _toupper - Convert Character 
  29039.      tolower() - toupper() - Convert Character Case 
  29040.      towlower - towupper - Convert Wide Character Case 
  29041.      <string.h> 
  29042.  
  29043.  
  29044. ΓòÉΓòÉΓòÉ 4.283. strncat - Concatenate Strings ΓòÉΓòÉΓòÉ
  29045.  
  29046.  
  29047. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29048.  
  29049. #include <string.h>
  29050. char *strncat(char *string1, const char *string2, size_t count);
  29051.  
  29052.  
  29053. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29054.  
  29055. Language Level: ANSI, SAA, POSIX, XPG4 
  29056.  
  29057. strncat appends the first count characters of string2 to string1 and ends the 
  29058. resulting string with a null character (\0). If count is greater than the 
  29059. length of string2, the length of string2 is used in place of count. 
  29060.  
  29061. The strncat function operates on null-terminated strings. The string argument 
  29062. to the function should contain a null character (\0) marking the end of the 
  29063. string. 
  29064.  
  29065. Return Value 
  29066. strncat returns a pointer to the joined string (string1). 
  29067.  
  29068.  
  29069. ΓòÉΓòÉΓòÉ <hidden> Example of strncat ΓòÉΓòÉΓòÉ
  29070.  
  29071. /************************************************************************
  29072.  
  29073. This example demonstrates the difference between strcat and strncat. strcat 
  29074. appends the entire second string to the first, whereas strncat appends only the 
  29075. specified number of characters in the second string to the first. 
  29076.  
  29077. ************************************************************************/
  29078.  
  29079. #include <stdio.h>
  29080. #include <string.h>
  29081.  
  29082. #define  SIZE          40
  29083.  
  29084. int main(void)
  29085. {
  29086.    char buffer1[SIZE] = "computer";
  29087.    char *ptr;
  29088.  
  29089.    /* Call strcat with buffer1 and " program"                                 */
  29090.  
  29091.    ptr = strcat(buffer1, " program");
  29092.    printf("strcat : buffer1 = \"%s\"\n", buffer1);
  29093.  
  29094.    /* Reset buffer1 to contain just the string "computer" again               */
  29095.  
  29096.    memset(buffer1, '\0', sizeof(buffer1));
  29097.    ptr = strcpy(buffer1, "computer");
  29098.  
  29099.    /* Call strncat with buffer1 and " program"                                */
  29100.  
  29101.    ptr = strncat(buffer1, " program", 3);
  29102.    printf("strncat: buffer1 = \"%s\"\n", buffer1);
  29103.    return 0;
  29104.  
  29105.    /****************************************************************************
  29106.       The output should be:
  29107.  
  29108.       strcat : buffer1 = "computer program"
  29109.       strncat: buffer1 = "computer pr"
  29110.    ****************************************************************************/
  29111. }
  29112.  
  29113.  
  29114. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29115.  
  29116. Example of strncat 
  29117.  
  29118.      strcat - Concatenate Strings 
  29119.      strnicmp - Compare Strings Without Case Sensitivity 
  29120.      wcscat - Concatenate Wide-Character Strings 
  29121.      wcsncat - Concatenate Wide-Character Strings 
  29122.      <string.h> 
  29123.  
  29124.  
  29125. ΓòÉΓòÉΓòÉ 4.284. strncmp - Compare Strings ΓòÉΓòÉΓòÉ
  29126.  
  29127.  
  29128. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29129.  
  29130. #include <string.h>
  29131. int strncmp(const char *string1, const char *string2, size_t count);
  29132.  
  29133.  
  29134. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29135.  
  29136. Language Level: ANSI, SAA, POSIX, XPG4 
  29137.  
  29138. strncmp compares the first count characters of string1 and string2. 
  29139.  
  29140. Return Value 
  29141. strncmp returns a value indicating the relationship between the substrings, as 
  29142. follows: 
  29143.  
  29144.  Value             Meaning 
  29145.  Less than 0       substring1 less than substring2 
  29146.  0                 substring1 equivalent to substring2 
  29147.  Greater than 0    substring1 greater than substring2 
  29148.  
  29149.  
  29150. ΓòÉΓòÉΓòÉ <hidden> Example of strncmp ΓòÉΓòÉΓòÉ
  29151.  
  29152. /************************************************************************
  29153.  
  29154. This example demonstrates the difference between strcmp and strncmp. 
  29155.  
  29156. ************************************************************************/
  29157.  
  29158. #include <stdio.h>
  29159. #include <string.h>
  29160.  
  29161. #define  SIZE          10
  29162.  
  29163. int main(void)
  29164. {
  29165.    int result;
  29166.    int index = 3;
  29167.    char buffer1[SIZE] = "abcdefg";
  29168.    char buffer2[SIZE] = "abcfg";
  29169.    void print_result(int, char *, char *);
  29170.  
  29171.    result = strcmp(buffer1, buffer2);
  29172.    printf("Comparison of each character\n");
  29173.    printf("  strcmp: ");
  29174.    print_result(result, buffer1, buffer2);
  29175.    result = strncmp(buffer1, buffer2, index);
  29176.    printf("\nComparison of only the first %i characters\n", index);
  29177.    printf("  strncmp: ");
  29178.    print_result(result, buffer1, buffer2);
  29179.    return 0;
  29180.  
  29181.    /****************************************************************************
  29182.       The output should be:
  29183.  
  29184.       Comparison of each character
  29185.         strcmp: "abcdefg" is less than "abcfg"
  29186.  
  29187.       Comparison of only the first 3 characters
  29188.         strncmp: "abcdefg" is identical to "abcfg"
  29189.    ****************************************************************************/
  29190. }
  29191.  
  29192. void print_result(int res,char *p_buffer1,char *p_buffer2)
  29193. {
  29194.    if (0 == res)
  29195.       printf("\"%s\" is identical to \"%s\"\n", p_buffer1, p_buffer2);
  29196.    else
  29197.       if (res < 0)
  29198.          printf("\"%s\" is less than \"%s\"\n", p_buffer1, p_buffer2);
  29199.       else
  29200.          printf("\"%s\" is greater than \"%s\"\n", p_buffer1, p_buffer2);
  29201. }
  29202.  
  29203.  
  29204. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29205.  
  29206. Example of strncmp 
  29207.  
  29208.      strcmp - Compare Strings 
  29209.      strcmpi - Compare Strings Without Case Sensitivity 
  29210.      strcoll - Compare Strings Using Collation Rules 
  29211.      strcspn - Compare Strings for Substrings 
  29212.      stricmp - Compare Strings as Lowercase 
  29213.      strnicmp - Compare Strings Without Case Sensitivity 
  29214.      wcscmp - Compare Wide-Character Strings 
  29215.      wcsncmp - Compare Wide-Character Strings 
  29216.      <string.h> 
  29217.  
  29218.  
  29219. ΓòÉΓòÉΓòÉ 4.285. strncpy - Copy Strings ΓòÉΓòÉΓòÉ
  29220.  
  29221.  
  29222. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29223.  
  29224. #include <string.h>
  29225. char *strncpy(char *string1, const char *string2, size_t count);
  29226.  
  29227.  
  29228. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29229.  
  29230. Language Level: ANSI, SAA, POSIX, XPG4 
  29231.  
  29232. strncpy copies count characters of string2 to string1. If count is less than or 
  29233. equal to the length of string2, a null character (\0) is not appended to the 
  29234. copied string. If count is greater than the length of string2, the string1 
  29235. result is padded with null characters (\0) up to length count. 
  29236.  
  29237. Return Value 
  29238. strncpy returns a pointer to string1. 
  29239.  
  29240.  
  29241. ΓòÉΓòÉΓòÉ <hidden> Example of strncpy ΓòÉΓòÉΓòÉ
  29242.  
  29243. /************************************************************************
  29244.  
  29245. This example demonstrates the difference between strcpy and strncpy. 
  29246.  
  29247. ************************************************************************/
  29248.  
  29249. #include <stdio.h>
  29250. #include <string.h>
  29251.  
  29252. #define  SIZE          40
  29253.  
  29254. int main(void)
  29255. {
  29256.    char source[SIZE] = "123456789";
  29257.    char source1[SIZE] = "123456789";
  29258.    char destination[SIZE] = "abcdefg";
  29259.    char destination1[SIZE] = "abcdefg";
  29260.    char *return_string;
  29261.    int index = 5;
  29262.  
  29263.    /* This is how strcpy works                                                */
  29264.  
  29265.    printf("destination is originally = '%s'\n", destination);
  29266.    return_string = strcpy(destination, source);
  29267.    printf("After strcpy, destination becomes '%s'\n\n", destination);
  29268.  
  29269.    /* This is how strncpy works                                               */
  29270.  
  29271.    printf("destination1 is originally = '%s'\n", destination1);
  29272.    return_string = strncpy(destination1, source1, index);
  29273.    printf("After strncpy, destination1 becomes '%s'\n", destination1);
  29274.    return 0;
  29275.  
  29276.    /****************************************************************************
  29277.       The output should be:
  29278.  
  29279.       destination is originally = 'abcdefg'
  29280.       After strcpy, destination becomes '123456789'
  29281.  
  29282.       destination1 is originally = 'abcdefg'
  29283.       After strncpy, destination1 becomes '12345fg'
  29284.    ****************************************************************************/
  29285. }
  29286.  
  29287.  
  29288. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29289.  
  29290. Example of strncpy 
  29291.  
  29292.      strcpy - Copy Strings 
  29293.      strdup - Duplicate String 
  29294.      strnicmp - Compare Strings Without Case Sensitivity 
  29295.      <string.h> 
  29296.  
  29297.  
  29298. ΓòÉΓòÉΓòÉ 4.286. strnicmp - Compare Strings Without Case Sensitivity ΓòÉΓòÉΓòÉ
  29299.  
  29300.  
  29301. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29302.  
  29303. #include <string.h>
  29304. int strnicmp(const char *string1, const char *string2, int n);
  29305.  
  29306.  
  29307. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29308.  
  29309. Language Level:  Extension 
  29310.  
  29311. strnicmp compares, at most, the first n characters of string1 and string2. It 
  29312. operates on null-terminated strings. 
  29313.  
  29314. strnicmp is case insensitive; the uppercase and lowercase forms of a letter are 
  29315. considered equivalent. 
  29316.  
  29317. Return Value 
  29318. strnicmp returns a value indicating the relationship between the substrings, as 
  29319. listed below: 
  29320.  
  29321.  Value             Meaning 
  29322.  Less than 0       substring1 less than substring2 
  29323.  0                 substring1 equivalent to substring2 
  29324.  Greater than 0    substring1 greater than substring2. 
  29325.  
  29326.  
  29327. ΓòÉΓòÉΓòÉ <hidden> Example of strnicmp ΓòÉΓòÉΓòÉ
  29328.  
  29329. /************************************************************************
  29330.  
  29331. This example uses strnicmp to compare two strings. 
  29332.  
  29333. ************************************************************************/
  29334.  
  29335. #include <string.h>
  29336. #include <stdio.h>
  29337.  
  29338. int main(void)
  29339. {
  29340.    char *str1 = "THIS IS THE FIRST STRING";
  29341.    char *str2 = "This is the second string";
  29342.    int numresult;
  29343.  
  29344.      /* Compare the first 11 characters of str1 and str2
  29345.         without regard to case                                                */
  29346.  
  29347.    numresult = strnicmp(str1, str2, 11);
  29348.    if (numresult < 0)
  29349.       printf("String 1 is less than string2.\n");
  29350.    else
  29351.       if (numresult > 0)
  29352.          printf("String 1 is greater than string2.\n");
  29353.       else
  29354.          printf("The two strings are equivalent.\n");
  29355.    return 0;
  29356.  
  29357.    /****************************************************************************
  29358.       The output should be:
  29359.  
  29360.       The two strings are equivalent.
  29361.    ****************************************************************************/
  29362. }
  29363.  
  29364.  
  29365. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29366.  
  29367. Example of strnicmp 
  29368.  
  29369.      strcmp - Compare Strings 
  29370.      strcmpi - Compare Strings Without Case Sensitivity 
  29371.      stricmp - Compare Strings as Lowercase 
  29372.      strncmp - Compare Strings 
  29373.      wcscmp - Compare Wide-Character Strings 
  29374.      wcsncmp - Compare Wide-Character Strings 
  29375.      <string.h> 
  29376.  
  29377.  
  29378. ΓòÉΓòÉΓòÉ 4.287. strnset - strset - Set Characters in String ΓòÉΓòÉΓòÉ
  29379.  
  29380.  
  29381. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29382.  
  29383. #include <string.h>
  29384. char *strnset(char *string, int c, size_t n);
  29385. char *strset(char *string, int c);
  29386.  
  29387.  
  29388. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29389.  
  29390. Language Level:  Extension 
  29391.  
  29392. strnset sets, at most, the first n characters of string to c (converted to a 
  29393. char). If n is greater than the length of string, the length of string is used 
  29394. in place of n. strset sets all characters of string, except the ending null 
  29395. character (\0), to c (converted to a char). 
  29396.  
  29397. For both functions, the string must be initialized and must end with a null 
  29398. character (\0). 
  29399.  
  29400. Return Value 
  29401. Both strset and strnset return a pointer to the altered string. There is no 
  29402. error return value. 
  29403.  
  29404.  
  29405. ΓòÉΓòÉΓòÉ <hidden> Example of strnset and strset ΓòÉΓòÉΓòÉ
  29406.  
  29407. /************************************************************************
  29408.  
  29409. In this example, strnset sets not more than four characters of a string to the 
  29410. character 'x'. Then the strset function changes any non-null characters of the 
  29411. string to the character 'k'. 
  29412.  
  29413. ************************************************************************/
  29414.  
  29415. #include <stdio.h>
  29416. #include <string.h>
  29417.  
  29418. int main(void)
  29419. {
  29420.    char *str = "abcdefghi";
  29421.  
  29422.    printf("This is the string: %s\n", str);
  29423.    printf("This is the string after strnset: %s\n", strnset(str, 'x', 4));
  29424.    printf("This is the string after strset: %s\n", strset(str, 'k'));
  29425.    return 0;
  29426.  
  29427.    /****************************************************************************
  29428.       The output should be:
  29429.  
  29430.       This is the string: abcdefghi
  29431.       This is the string after strnset: xxxxefghi
  29432.       This is the string after strset: kkkkkkkkk
  29433.    ****************************************************************************/
  29434. }
  29435.  
  29436.  
  29437. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29438.  
  29439. Example of strnset and strset 
  29440.  
  29441.      strchr - Search for Character 
  29442.      strpbrk - Find Characters in String 
  29443.      wcschr - Search for Wide Character 
  29444.      wcspbrk - Locate Wide Characters in String 
  29445.      <string.h> 
  29446.  
  29447.  
  29448. ΓòÉΓòÉΓòÉ 4.288. strpbrk - Find Characters in String ΓòÉΓòÉΓòÉ
  29449.  
  29450.  
  29451. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29452.  
  29453. #include <string.h>
  29454. char *strpbrk(const char *string1, const char *string2);
  29455.  
  29456.  
  29457. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29458.  
  29459. Language Level: ANSI, SAA, POSIX, XPG4 
  29460.  
  29461. strpbrk locates the first occurrence in the string pointed to by string1 of any 
  29462. character from the string pointed to by string2. 
  29463.  
  29464. Return Value 
  29465. strpbrk returns a pointer to the character. If string1 and string2 have no 
  29466. characters in common, a NULL pointer is returned. 
  29467.  
  29468.  
  29469. ΓòÉΓòÉΓòÉ <hidden> Example of strpbrk ΓòÉΓòÉΓòÉ
  29470.  
  29471. /************************************************************************
  29472.  
  29473. This example returns a pointer to the first occurrence in the array string of 
  29474. either a or b. 
  29475.  
  29476. ************************************************************************/
  29477.  
  29478. #include <stdio.h>
  29479. #include <string.h>
  29480.  
  29481. int main(void)
  29482. {
  29483.    char *result,*string = "A Blue Danube";
  29484.    char *chars = "ab";
  29485.  
  29486.    result = strpbrk(string, chars);
  29487.    printf("The first occurrence of any of the characters \"%s\" in "
  29488.       "\"%s\" is \"%s\"\n", chars, string, result);
  29489.    return 0;
  29490.  
  29491.    /****************************************************************************
  29492.       The output should be:
  29493.  
  29494.       The first occurrence of any of the characters "ab" in
  29495.       "A Blue Danube" is "anube"
  29496.    ****************************************************************************/
  29497. }
  29498.  
  29499.  
  29500. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29501.  
  29502. Example of strpbrk 
  29503.  
  29504.      strchr - Search for Character 
  29505.      strcspn - Compare Strings for Substrings 
  29506.      strrchr - Find Last Occurrence of Character in String 
  29507.      strspn - Search Strings 
  29508.      wcschr - Search for Wide Character 
  29509.      wcscspn - Find Offset of First Wide-Character Match 
  29510.      wcspbrk - Locate Wide Characters in String 
  29511.      wcsrchr - Locate Wide Character in String 
  29512.      wcswcs - Locate Wide-Character Substring 
  29513.      <string.h> 
  29514.  
  29515.  
  29516. ΓòÉΓòÉΓòÉ 4.289. strptime - Convert to Formatted Date and Time ΓòÉΓòÉΓòÉ
  29517.  
  29518.  
  29519. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29520.  
  29521. #include <time.h>
  29522. char *strptime(const char *buf, const char *fmt, struct tm *tm);
  29523.  
  29524.  
  29525. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29526.  
  29527. Language Level:  XPG4 
  29528.  
  29529. strptime uses the format specified by fmt to convert the character string 
  29530. pointed to by buf to values that are stored in the structure pointed to by tm. 
  29531.  
  29532. The *fmt is composed of zero or more directives. Each directive is composed of 
  29533. one of the following: 
  29534.  
  29535.      One or more white-space characters (as specified by the isspace function) 
  29536.      An ordinary character (neither % nor a white-space character) 
  29537.      A conversion specifier. 
  29538.  
  29539.  Each conversion specifier consists of a % character followed by a conversion 
  29540.  character that specifies the replacement required. There must be white-space 
  29541.  or other non-alphanumeric characters between any two conversion specifiers. 
  29542.  See  Conversion Specifiers Used by strptime for a list of conversion 
  29543.  specifiers. 
  29544.  
  29545.  For a directive composed of white-space characters, strptime scans input up to 
  29546.  the first character that is not white space (which remains unscanned), or 
  29547.  until no more characters can be scanned. 
  29548.  
  29549.  For a directive that is an ordinary character, strptime scans the next 
  29550.  character from the buffer. If the scanned character differs from the one 
  29551.  comprising the directive, the directive fails and the differing and subsequent 
  29552.  characters remain unscanned. 
  29553.  
  29554.  For a series of directives composed of %n, %t, white-space characters, or any 
  29555.  combination, strptime scans up to the first character that is not white space 
  29556.  (which remains unscanned), or until no more characters can be scanned. 
  29557.  
  29558.  For any other conversion specification, strptime scans characters until a 
  29559.  character matching the next directive is scanned, or until no more characters 
  29560.  can be scanned. It then compares these characters, excepting the one matching 
  29561.  the next directive, to the locale values associated with the conversion 
  29562.  specifier. If a match is found, strptime sets the appropriate tm structure 
  29563.  members to values corresponding to the locale information. Case is ignored 
  29564.  when items in buf are matched, such as month or weekday names. If no match is 
  29565.  found, strptime fails and no more characters are scanned. 
  29566.  
  29567.  Return Value 
  29568.  If successful, strptime returns a pointer to the character following the last 
  29569.  character parsed. Otherwise, a null pointer is returned. 
  29570.  
  29571.  
  29572. ΓòÉΓòÉΓòÉ <hidden> Example of strptime ΓòÉΓòÉΓòÉ
  29573.  
  29574. /************************************************************************
  29575.  
  29576. This example uses strptime to convert a string to the structure xmas, then 
  29577. prints the contents of the structure. 
  29578.  
  29579. ************************************************************************/
  29580.  
  29581. #include <time.h>
  29582. #include <stdio.h>
  29583. #include <stdlib.h>
  29584.  
  29585. int main(void)
  29586. {
  29587.    struct tm xmas;
  29588.  
  29589.    if (NULL == strptime("12/25/94 12:00:01", "%D %T", &xmas)) {
  29590.       printf("strptime() failed.\n");
  29591.       exit(EXIT_FAILURE);
  29592.    }
  29593.    printf("tm_sec  = %3d\n", xmas.tm_sec );
  29594.    printf("tm_min  = %3d\n", xmas.tm_min );
  29595.    printf("tm_hour = %3d\n", xmas.tm_hour);
  29596.    printf("tm_mday = %3d\n", xmas.tm_mday);
  29597.    printf("tm_mon  = %3d\n", xmas.tm_mon );
  29598.    printf("tm_year = %3d\n", xmas.tm_year);
  29599.    return 0;
  29600.  
  29601.    /****************************************************************************
  29602.       The output should be similar to :
  29603.  
  29604.       tm_sec  =   1
  29605.       tm_min  =   0
  29606.       tm_hour =  12
  29607.       tm_mday =  25
  29608.       tm_mon  =  11
  29609.       tm_year =  94
  29610.    ****************************************************************************/
  29611. }
  29612.  
  29613.  
  29614. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29615.  
  29616. Example of strptime 
  29617.  
  29618.      Conversion Specifiers Used by strptime 
  29619.      strftime - Convert to Formatted Time 
  29620.      wcsftime - Convert to Formatted Date and Time 
  29621.      <time.h> 
  29622.  
  29623.  
  29624. ΓòÉΓòÉΓòÉ 4.289.1. Conversion Specifiers Used by strptime ΓòÉΓòÉΓòÉ
  29625.  
  29626. The following tables list the conversion specifiers for strptime. 
  29627.  
  29628. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  29629. Γöé SPECIFIER   Γöé MEANING                     Γöé
  29630. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29631. Γöé %a       Γöé Day of week, using locale's abbreviated or full Γöé
  29632. Γöé        Γöé weekday name.                  Γöé
  29633. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29634. Γöé %A       Γöé Day of week, using locale's abbreviated or full Γöé
  29635. Γöé        Γöé weekday name.                  Γöé
  29636. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29637. Γöé %b       Γöé Month, using locale's abbreviated or full month Γöé
  29638. Γöé        Γöé name.                      Γöé
  29639. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29640. Γöé %B       Γöé Month, using locale's abbreviated or full month Γöé
  29641. Γöé        Γöé name.                      Γöé
  29642. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29643. Γöé %c       Γöé Date and time, using locale's date and time.   Γöé
  29644. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29645. Γöé %C       Γöé Century number (year divided by 100 and trun-  Γöé
  29646. Γöé        Γöé cated to an integer)               Γöé
  29647. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29648. Γöé %d       Γöé Day of the month (1-31; leading zeros permitted Γöé
  29649. Γöé        Γöé but not required).                Γöé
  29650. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29651. Γöé %D       Γöé Date as %m/%d/%y.                Γöé
  29652. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29653. Γöé %e       Γöé Day of the month (1-31; leading zeros permitted Γöé
  29654. Γöé        Γöé but not required).                Γöé
  29655. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29656. Γöé %h       Γöé Month, using locale's abbreviated or full month Γöé
  29657. Γöé        Γöé name.                      Γöé
  29658. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29659. Γöé %H       Γöé Hour (0-23; leading zeros permitted but not   Γöé
  29660. Γöé        Γöé required).                    Γöé
  29661. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29662. Γöé %I       Γöé Hour (0-12; leading zeros permitted but not   Γöé
  29663. Γöé        Γöé required).                    Γöé
  29664. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29665. Γöé %j       Γöé Day number of the year (001-366).        Γöé
  29666. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29667. Γöé %m       Γöé Month number (1-12; leading zeros permitted but Γöé
  29668. Γöé        Γöé not required).                  Γöé
  29669. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29670. Γöé %M       Γöé Minute (0-59; leading zeros permitted but not  Γöé
  29671. Γöé        Γöé required).                    Γöé
  29672. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29673. Γöé %n       Γöé Newline character.                Γöé
  29674. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29675. Γöé %p       Γöé Locale's equivalent of AM or PM.         Γöé
  29676. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29677. Γöé %r       Γöé Time as %I:%M:%S a.m. or %I:%M:%S p.m.      Γöé
  29678. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29679. Γöé %R       Γöé Time in 24 hour notation (%H%M)         Γöé
  29680. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29681. Γöé %S       Γöé Seconds (0-61; leading zeros permitted but not  Γöé
  29682. Γöé        Γöé required).                    Γöé
  29683. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29684. Γöé %t       Γöé Tab character.                  Γöé
  29685. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29686. Γöé %T       Γöé Time as %H:%M:%S.                Γöé
  29687. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29688. Γöé %U       Γöé Week number of the year (0-53; where Sunday is  Γöé
  29689. Γöé        Γöé the first day of the week; leading zeros per-  Γöé
  29690. Γöé        Γöé mitted but not required).            Γöé
  29691. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29692. Γöé %w       Γöé Weekday (0-6; where Sunday is 0; leading zeros  Γöé
  29693. Γöé        Γöé permitted but not required).           Γöé
  29694. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29695. Γöé %W       Γöé Week number of the year (0-53; where Monday is  Γöé
  29696. Γöé        Γöé the first day of the week; leading zeros per-  Γöé
  29697. Γöé        Γöé mitted but not required).            Γöé
  29698. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29699. Γöé %x       Γöé Date, using locale's date format.        Γöé
  29700. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29701. Γöé %X       Γöé Time, using locale's time format.        Γöé
  29702. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29703. Γöé %y       Γöé Year within century (0-99; leading zeros per-  Γöé
  29704. Γöé        Γöé mitted but not required).            Γöé
  29705. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29706. Γöé %Y       Γöé Year, including century.             Γöé
  29707. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29708. Γöé %Z       Γöé Time zone name                  Γöé
  29709. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29710. Γöé %%       Γöé Replace with %.                 Γöé
  29711. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  29712.  
  29713. Some directives can be modified by the E or O modifier characters to indicate 
  29714. that an alternative format or specification should be used rather than the one 
  29715. normally used by the unmodified directive. If the alternative format or 
  29716. specification does not exist in the current locale, the behavior will be as if 
  29717. the unmodified directive were used. 
  29718.  
  29719. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  29720. Γöé SPECIFIER   Γöé MEANING                     Γöé
  29721. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29722. Γöé %Ec      Γöé Replace with the locale's alternative date and  Γöé
  29723. Γöé        Γöé time representation.               Γöé
  29724. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29725. Γöé %EC      Γöé Replace with the name of the base year (period) Γöé
  29726. Γöé        Γöé in the locale's alternative representation.   Γöé
  29727. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29728. Γöé %Ex      Γöé Replace with the locale's alternative date rep- Γöé
  29729. Γöé        Γöé resentation.                   Γöé
  29730. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29731. Γöé %EX      Γöé Replace with the locale's alternative time rep- Γöé
  29732. Γöé        Γöé resentation.                   Γöé
  29733. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29734. Γöé %Ey      Γöé Replace with the offset from %EC (year only) in Γöé
  29735. Γöé        Γöé the locale's alternative representation.     Γöé
  29736. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29737. Γöé %EY      Γöé Replace with the full alternative year repre-  Γöé
  29738. Γöé        Γöé sentation.                    Γöé
  29739. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29740. Γöé %Od      Γöé Replace with the day of month, using the     Γöé
  29741. Γöé        Γöé locale's alternative numeric symbols, filled as Γöé
  29742. Γöé        Γöé needed with leading zeroes if there is any    Γöé
  29743. Γöé        Γöé alternative symbol for zero; otherwise, fill   Γöé
  29744. Γöé        Γöé with leading spaces.               Γöé
  29745. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29746. Γöé %Oe      Γöé Replace with the day of the month, using the   Γöé
  29747. Γöé        Γöé locale's alternative numeric symbols, filled as Γöé
  29748. Γöé        Γöé needed with leading spaces.           Γöé
  29749. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29750. Γöé %OH      Γöé Replace with the hour (24-hour clock), using   Γöé
  29751. Γöé        Γöé the locale's alternative numeric symbols.    Γöé
  29752. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29753. Γöé %OI      Γöé Replace with the hour (12-hour clock), using   Γöé
  29754. Γöé        Γöé the locale's alternative numeric symbols.    Γöé
  29755. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29756. Γöé %Om      Γöé Replace with the month, using the locale's    Γöé
  29757. Γöé        Γöé alternative numeric symbols.           Γöé
  29758. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29759. Γöé %OM      Γöé Replace with the minutes, using the locale's   Γöé
  29760. Γöé        Γöé alternative numeric symbols.           Γöé
  29761. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29762. Γöé %OS      Γöé Replace with the seconds, using the locale's   Γöé
  29763. Γöé        Γöé alternative numeric symbols.           Γöé
  29764. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29765. Γöé %OU      Γöé Replace with the week number of the year     Γöé
  29766. Γöé        Γöé (Sunday as the first day of the week, rules   Γöé
  29767. Γöé        Γöé corresponding to %U), using the locale's alter- Γöé
  29768. Γöé        Γöé native numeric symbols.             Γöé
  29769. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29770. Γöé %Ow      Γöé Replace with the weekday (Sunday=0), using the  Γöé
  29771. Γöé        Γöé locale's alternative numeric symbols.      Γöé
  29772. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29773. Γöé %OW      Γöé Replace with the week number of the year     Γöé
  29774. Γöé        Γöé (Monday as the first day of the week), using   Γöé
  29775. Γöé        Γöé the locale's alternative numeric symbols.    Γöé
  29776. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  29777. Γöé %Oy      Γöé Replace with the year (offset from %C) in the  Γöé
  29778. Γöé        Γöé locale's alternative representation, using the  Γöé
  29779. Γöé        Γöé locale's alternative numeric symbols.      Γöé
  29780. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  29781.  
  29782.  
  29783. ΓòÉΓòÉΓòÉ 4.290. strrchr - Find Last Occurrence of Character in String ΓòÉΓòÉΓòÉ
  29784.  
  29785.  
  29786. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29787.  
  29788. #include <string.h>
  29789. char *strrchr(const char *string, int c);
  29790.  
  29791.  
  29792. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29793.  
  29794. Language Level: ANSI, SAA, POSIX, XPG4 
  29795.  
  29796. strrchr finds the last occurrence of c (converted to a character) in string. 
  29797. The ending null character is considered part of the string. 
  29798.  
  29799. Return Value 
  29800. strrchr returns a pointer to the last occurrence of c in string. If the given 
  29801. character is not found, a NULL pointer is returned. 
  29802.  
  29803.  
  29804. ΓòÉΓòÉΓòÉ <hidden> Example of strrchr ΓòÉΓòÉΓòÉ
  29805.  
  29806. /************************************************************************
  29807.  
  29808. This example compares the use of strchr and strrchr.  It searches the string 
  29809. for the first and last occurrence of p in the string. 
  29810.  
  29811. ************************************************************************/
  29812.  
  29813. #include <stdio.h>
  29814. #include <string.h>
  29815.  
  29816. #define  SIZE          40
  29817.  
  29818. int main(void)
  29819. {
  29820.    char buf[SIZE] = "computer program";
  29821.    char *ptr;
  29822.    int ch = 'p';
  29823.  
  29824.    /* This illustrates strchr                                                 */
  29825.  
  29826.    ptr = strchr(buf, ch);
  29827.    printf("The first occurrence of %c in '%s' is '%s'\n", ch, buf, ptr);
  29828.  
  29829.    /* This illustrates strrchr                                                */
  29830.  
  29831.    ptr = strrchr(buf, ch);
  29832.    printf("The last occurrence of %c in '%s' is '%s'\n", ch, buf, ptr);
  29833.    return 0;
  29834.  
  29835.    /****************************************************************************
  29836.       The output should be:
  29837.  
  29838.       The first occurrence of p in 'computer program' is 'puter program'
  29839.       The last occurrence of p in 'computer program' is 'program'
  29840.    ****************************************************************************/
  29841. }
  29842.  
  29843.  
  29844. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29845.  
  29846. Example of strrchr 
  29847.  
  29848.      strchr - Search for Character 
  29849.      strcspn - Compare Strings for Substrings 
  29850.      strpbrk - Find Characters in String 
  29851.      strspn - Search Strings 
  29852.      wcschr - Search for Wide Character 
  29853.      wcspbrk - Locate Wide Characters in String 
  29854.      wcsrchr - Locate Wide Character in String 
  29855.      wcswcs - Locate Wide-Character Substring 
  29856.      <string.h> 
  29857.  
  29858.  
  29859. ΓòÉΓòÉΓòÉ 4.291. strrev - Reverse String ΓòÉΓòÉΓòÉ
  29860.  
  29861.  
  29862. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29863.  
  29864. #include <string.h>
  29865. char *strrev(char *string);
  29866.  
  29867.  
  29868. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29869.  
  29870. Language Level:  Extension 
  29871.  
  29872. strrev reverses the order of the characters in the given string.  The ending 
  29873. null character (\0) remains in place. 
  29874.  
  29875. Return Value 
  29876. strrev returns a pointer to the altered string.  There is no error return 
  29877. value. 
  29878.  
  29879.  
  29880. ΓòÉΓòÉΓòÉ <hidden> Example of strrev ΓòÉΓòÉΓòÉ
  29881.  
  29882. /************************************************************************
  29883.  
  29884. This example determines whether a string is a palindrome.  A palindrome is a 
  29885. string that reads the same forward and backward. 
  29886.  
  29887. ************************************************************************/
  29888.  
  29889. #include <stdio.h>
  29890. #include <stdlib.h>
  29891. #include <string.h>
  29892.  
  29893. int palindrome(char *string)
  29894. {
  29895.    char *string2;
  29896.  
  29897.    /* Duplicate string for comparison                                         */
  29898.  
  29899.    if (NULL == (string2 = strdup(string))) {
  29900.       printf("Storage could not be reserved for string\n");
  29901.       exit(EXIT_FAILURE);
  29902.    }
  29903.  
  29904.    /* If result equals 0, the string is a palindrome                          */
  29905.  
  29906.    return (strcmp(string, strrev(string2)));
  29907. }
  29908.  
  29909. int main(void)
  29910. {
  29911.    char string[81];
  29912.  
  29913.    printf("Please enter a string.\n");
  29914.    scanf("%80s", string);
  29915.    if (palindrome(string))
  29916.       printf("The string is not a palindrome.\n");
  29917.    else
  29918.       printf("The string is a palindrome.\n");
  29919.    return 0;
  29920.  
  29921.    /****************************************************************************
  29922.       Sample output from program:
  29923.  
  29924.       Please enter a string.
  29925.       level
  29926.       The string is a palindrome.
  29927.       ... or ...
  29928.       Please enter a string.
  29929.       levels
  29930.       The string is not a palindrome.
  29931.    ****************************************************************************/
  29932. }
  29933.  
  29934.  
  29935. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  29936.  
  29937. Example of strrev 
  29938.  
  29939.      strcat - Concatenate Strings 
  29940.      strcmp - Compare Strings 
  29941.      strcpy - Copy Strings 
  29942.      strdup - Duplicate String 
  29943.      strnset - strset - Set Characters in String 
  29944.      <string.h> 
  29945.  
  29946.  
  29947. ΓòÉΓòÉΓòÉ 4.292. strspn - Search Strings ΓòÉΓòÉΓòÉ
  29948.  
  29949.  
  29950. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  29951.  
  29952. #include <string.h>
  29953. size_t strspn(const char *string1, const char *string2);
  29954.  
  29955.  
  29956. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  29957.  
  29958. Language Level: ANSI, SAA, POSIX, XPG4 
  29959.  
  29960. strspn finds the first occurrence of a character in string1 that is not 
  29961. contained in the set of characters specified by string2. The null character 
  29962. (\0) that ends string2 is not considered in the matching process. 
  29963.  
  29964. Return Value 
  29965. strspn returns the index of the first character found. This value is equal to 
  29966. the length of the initial substring of string1 that consists entirely of 
  29967. characters from string2. If string1 begins with a character not in string2, 
  29968. strspn returns 0. If all the characters in string1 are found in string2, the 
  29969. length of string1 is returned. 
  29970.  
  29971.  
  29972. ΓòÉΓòÉΓòÉ <hidden> Example of strspn ΓòÉΓòÉΓòÉ
  29973.  
  29974. /************************************************************************
  29975.  
  29976. This example finds the first occurrence in the array string of a character that 
  29977. is not an a, b, or c.  Because the string in this example is cabbage, strspn 
  29978. returns 5, the length of the segment of cabbage before a character that is not 
  29979. an a, b, or c. 
  29980.  
  29981. ************************************************************************/
  29982.  
  29983. #include <stdio.h>
  29984. #include <string.h>
  29985.  
  29986. int main(void)
  29987. {
  29988.    char *string = "cabbage";
  29989.    char *source = "abc";
  29990.    int index;
  29991.  
  29992.    index = strspn(string, "abc");
  29993.    printf("The first %d characters of \"%s\" are found in \"%s\"\n", index,
  29994.       string, source);
  29995.    return 0;
  29996.  
  29997.    /****************************************************************************
  29998.       The output should be:
  29999.  
  30000.       The first 5 characters of "cabbage" are found in "abc"
  30001.    ****************************************************************************/
  30002. }
  30003.  
  30004.  
  30005. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30006.  
  30007. Example of strspn 
  30008.  
  30009.      strchr - Search for Character 
  30010.      strcspn - Compare Strings for Substrings 
  30011.      strpbrk - Find Characters in String 
  30012.      strrchr - Find Last Occurrence of Character in String 
  30013.      wcschr - Search for Wide Character 
  30014.      wcscspn - Find Offset of First Wide-Character Match 
  30015.      wcspbrk - Locate Wide Characters in String 
  30016.      wcsrchr - Locate Wide Character in String 
  30017.      wcsspn - Search Wide-Character Strings 
  30018.      wcswcs - Locate Wide-Character Substring 
  30019.      <string.h> 
  30020.  
  30021.  
  30022. ΓòÉΓòÉΓòÉ 4.293. strstr - Locate Substring ΓòÉΓòÉΓòÉ
  30023.  
  30024.  
  30025. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30026.  
  30027. #include <string.h>
  30028. char *strstr(const char *string1, const char *string2);
  30029.  
  30030.  
  30031. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30032.  
  30033. Language Level: ANSI, SAA, POSIX, XPG4 
  30034.  
  30035. strstr finds the first occurrence of string2 in string1. The function ignores 
  30036. the null character (\0) that ends string2 in the matching process. 
  30037.  
  30038. Return Value 
  30039. strstr returns a pointer to the beginning of the first occurrence of string2 in 
  30040. string1. If string2 does not appear in string1, strstr returns NULL. If string2 
  30041. points to a string with zero length, strstr returns string1. 
  30042.  
  30043.  
  30044. ΓòÉΓòÉΓòÉ <hidden> Example of strstr ΓòÉΓòÉΓòÉ
  30045.  
  30046. /************************************************************************
  30047.  
  30048. This example locates the string haystack in the string "needle in a haystack". 
  30049.  
  30050. ************************************************************************/
  30051.  
  30052. #include <string.h>
  30053.  
  30054. int main(void)
  30055. {
  30056.    char *string1 = "needle in a haystack";
  30057.    char *string2 = "haystack";
  30058.    char *result;
  30059.  
  30060.    result = strstr(string1, string2);
  30061.  
  30062.    /* Result = a pointer to "haystack"                                        */
  30063.  
  30064.    printf("%s\n", result);
  30065.    return 0;
  30066.  
  30067.    /****************************************************************************
  30068.       The output should be:
  30069.  
  30070.       haystack
  30071.    ****************************************************************************/
  30072. }
  30073.  
  30074.  
  30075. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30076.  
  30077. Example of strstr 
  30078.  
  30079.      strchr - Search for Character 
  30080.      strcspn - Compare Strings for Substrings 
  30081.      strpbrk - Find Characters in String 
  30082.      strrchr - Find Last Occurrence of Character in String 
  30083.      strspn - Search Strings 
  30084.      wcschr - Search for Wide Character 
  30085.      wcscspn - Find Offset of First Wide-Character Match 
  30086.      wcspbrk - Locate Wide Characters in String 
  30087.      wcsrchr - Locate Wide Character in String 
  30088.      wcsspn - Search Wide-Character Strings 
  30089.      wcswcs - Locate Wide-Character Substring 
  30090.      <string.h> 
  30091.  
  30092.  
  30093. ΓòÉΓòÉΓòÉ 4.294. _strtime - Copy Time ΓòÉΓòÉΓòÉ
  30094.  
  30095.  
  30096. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30097.  
  30098. #include <time.h>
  30099. char *_strtime(char *time);
  30100.  
  30101.  
  30102. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30103.  
  30104. Language Level:  Extension 
  30105.  
  30106. _strtime copies the current time into the buffer that time points to.  The 
  30107. format is: 
  30108.  
  30109.    hh:mm:ss
  30110.  
  30111. where 
  30112.  
  30113.       hh represents the hour in 24-hour notation, 
  30114.       mm represents the minutes past the hour, 
  30115.       ss represents the number of seconds. 
  30116.  
  30117.  For example, the string 18:23:44 represents 23 minutes and 44 seconds past 6 
  30118.  p.m. 
  30119.  
  30120.  The buffer must be at least 9 bytes. 
  30121.  
  30122.  Note:  The time and date functions begin at 00:00 Coordinated Universal Time, 
  30123.  January 1, 1970. 
  30124.  
  30125.  Return Value 
  30126.  _strtime returns a pointer to the buffer. There is no error return. 
  30127.  
  30128.  
  30129. ΓòÉΓòÉΓòÉ <hidden> Example of _strtime ΓòÉΓòÉΓòÉ
  30130.  
  30131. /************************************************************************
  30132.  
  30133. This example prints the current time: 
  30134.  
  30135. ************************************************************************/
  30136.  
  30137. #include <stdio.h>
  30138. #include <time.h>
  30139.  
  30140. int main(void)
  30141. {
  30142.    char buffer[9];
  30143.  
  30144.    printf("The current time is %s \n", _strtime(buffer));
  30145.    return 0;
  30146.  
  30147.    /****************************************************************************
  30148.       The output should be similar to:
  30149.  
  30150.       The current time is 16:47:22
  30151.    ****************************************************************************/
  30152. }
  30153.  
  30154.  
  30155. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30156.  
  30157. Example of _strtime 
  30158.  
  30159.      asctime - Convert Time to Character String 
  30160.      ctime - Convert Time to Character String 
  30161.      gmtime - Convert Time 
  30162.      localtime - Convert Time 
  30163.      mktime - Convert Local Time 
  30164.      time - Determine Current Time 
  30165.      tzset - Assign Values to Locale Information 
  30166.      <time.h> 
  30167.  
  30168.  
  30169. ΓòÉΓòÉΓòÉ 4.295. strtocoll - Return Collating Element for String ΓòÉΓòÉΓòÉ
  30170.  
  30171.  
  30172. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30173.  
  30174. #include <collate.h>
  30175. collel_t strtocoll(char *string);
  30176.  
  30177.  
  30178. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30179.  
  30180. Language Level:  Extension 
  30181.  
  30182. strtocoll determines the collating element (collel_t) that represents string. 
  30183.  
  30184. For a string of one character, the collating element always exists, and is the 
  30185. wchar_t of that character. For a string with more than one character, a valid 
  30186. collating element exists if the LC_COLLATE category contains the definition of 
  30187. a sequence of characters that collate as one for the purpose of 
  30188. culture-sensitive string comparison. This 
  30189. many-characters-to-one-collating-element relationship is also called 
  30190. many-to-one mapping. 
  30191.  
  30192. Return Value 
  30193.  
  30194. strtocoll returns the collating element (collel_t value) for string. strtocoll 
  30195. returns (collel_t)-1 in the following cases: 
  30196.  
  30197.      If many-to-one mapping is not defined in the LC_COLLATE category of the 
  30198.       current locale. 
  30199.      If the string is not a valid collating element . 
  30200.      If the string has zero length. 
  30201.      If the wchar_t for the first character in the string is greater than the 
  30202.       maximum wchar_t value for the characters in the charmap file for the 
  30203.       current locale.  (This error occurs when the current locale is "C" or 
  30204.       where MB_CUR_MAX is 2, and strtocoll is passed a double-byte character, 
  30205.       but only single-byte characters are defined in the charmap file for the 
  30206.       locale.) 
  30207.  
  30208.  
  30209. ΓòÉΓòÉΓòÉ <hidden> Example of strtocoll ΓòÉΓòÉΓòÉ
  30210.  
  30211. /************************************************************************
  30212.  
  30213. This example uses strtocoll to get the start and end collating-elements for the 
  30214. collrange function. 
  30215.  
  30216. ************************************************************************/
  30217.  
  30218. #include <stdio.h>
  30219. #include <locale.h>
  30220. #include <collate.h>
  30221. #include <wchar.h>
  30222.  
  30223. int main(int argc, char *argv[])
  30224. {
  30225.    collel_t s, e, *rp;
  30226.    int      i;
  30227.  
  30228.    setlocale(LC_ALL, LC_C_FRANCE);
  30229.    if ((collel_t)-1 == (s = strtocoll(argv[1]))) {
  30230.       printf("'%s' collating element not defined\n", argv[1]);
  30231.       exit(1);
  30232.    }
  30233.    if ((collel_t)-1 == (e = strtocoll(argv[2]))) {
  30234.       printf("'%s' collating element not defined\n", argv[2]);
  30235.       exit(1);
  30236.    }
  30237.    if (-1 == (i = collrange(s, e, &rp))) {
  30238.       printf("Invalid range for '%s' to '%s'\n", argv[1], argv[2]);
  30239.       exit(1);
  30240.    }
  30241.    for (; i > 0; rp++, i--) {
  30242.       if (ismccollel(*rp))
  30243.          printf("'%s' ", colltostr(*rp));
  30244.       else if (iswprint(*rp))
  30245.               printf("'%lc' ", *rp);
  30246.            else
  30247.               printf("'%x' ", *rp);
  30248.    }
  30249.    return 0;
  30250.  
  30251.    /****************************************************************************
  30252.       Assuming you enter: A z
  30253.  
  30254.       The output should be:
  30255.  
  30256.       'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R'
  30257.       'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '[' '\' ']' '^' '_' '`' 'a' 'b' 'c' 'd'
  30258.       'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v'
  30259.       'w' 'x' 'y' 'z'
  30260.    ****************************************************************************/
  30261. }
  30262.  
  30263.  
  30264. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30265.  
  30266. Example of strtocoll 
  30267.  
  30268.      cclass - Return Characters in Character Class 
  30269.      collequiv - Return List of Equivalent Collating Elements 
  30270.      collorder - Return List of Collating Elements 
  30271.      collrange - Calculate Range of Collating Elements 
  30272.      colltostr - Return String for Collating Element 
  30273.      getmccoll - Get Next Collating Element from String 
  30274.      getwmccoll - Get Next Collating Element from Wide String 
  30275.      ismccollel - Identify Multi-Character Collating Element 
  30276.      maxcoll - Return Maximum Collating Element 
  30277.      <collate.h> 
  30278.  
  30279.  
  30280. ΓòÉΓòÉΓòÉ 4.296. strtod - Convert Character String to Double ΓòÉΓòÉΓòÉ
  30281.  
  30282.  
  30283. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30284.  
  30285. #include <stdlib.h>
  30286. double strtod(const char *nptr, char **endptr);
  30287.  
  30288.  
  30289. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30290.  
  30291. Language Level:  ANSI, SAA, XPG4 
  30292.  
  30293. strtod converts a character string to a double-precision value. The parameter 
  30294. nptr points to a sequence of characters that can be interpreted as a numerical 
  30295. value of the type double.  This function stops reading the string at the first 
  30296. character that it cannot recognize as part of a number.  This character can be 
  30297. the null character at the end of the string. 
  30298.  
  30299. The strtod function expects nptr to point to a string with the following form: 
  30300.  
  30301. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  30302. Γöé                                        Γöé
  30303. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ>         Γöé
  30304. Γöé   ΓööΓöÇwhite-spaceΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ  Γö£ΓöÇdigitsΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöñ           Γöé
  30305. Γöé            ΓööΓöÇΓö┤ΓöÇΓöÿ  Γöé     ΓööΓöÇ.ΓöÇΓöÿ  ΓööΓöÇdigitsΓöÇΓöÿ Γöé           Γöé
  30306. Γöé               ΓööΓöÇ.ΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ           Γöé
  30307. Γöé                                        Γöé
  30308. Γöé >ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><                        Γöé
  30309. Γöé   ΓööΓöÇΓö¼ΓöÇeΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÿ                          Γöé
  30310. Γöé    ΓööΓöÇEΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ                               Γöé
  30311. Γöé       ΓööΓöÇΓö┤ΓöÇΓöÿ                               Γöé
  30312. Γöé                                        Γöé
  30313. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  30314.  
  30315. The first character that does not fit this form stops the scan. 
  30316.  
  30317. Return Value 
  30318. strtod returns the value of the floating-point number, except when the 
  30319. representation causes an underflow or overflow. For an overflow, it returns 
  30320. -HUGE_VAL or +HUGE_VAL; for an underflow, it returns 0. 
  30321.  
  30322. In both cases, errno is set to ERANGE, depending on the base of the value. If 
  30323. the string pointed to by nptr does not have the expected form, no conversion is 
  30324. performed and the value of nptr is stored in the object pointed to by endptr, 
  30325. provided that endptr is not a NULL pointer. 
  30326.  
  30327. strtod does not fail if a character other than a digit follows an E or e read 
  30328. in as an exponent. For example, 100elf will be converted to the floating-point 
  30329. value 100.0. 
  30330.  
  30331.  
  30332. ΓòÉΓòÉΓòÉ <hidden> Example of strtod ΓòÉΓòÉΓòÉ
  30333.  
  30334. /************************************************************************
  30335.  
  30336. This example converts the strings to a double value.  It prints out the 
  30337. converted value and the substring that stopped the conversion. 
  30338.  
  30339. ************************************************************************/
  30340.  
  30341. #include <stdlib.h>
  30342. #include <stdio.h>
  30343.  
  30344. int main(void)
  30345. {
  30346.    char *string,*stopstring;
  30347.    double x;
  30348.  
  30349.    string = "3.1415926This stopped it";
  30350.    x = strtod(string, &stopstring);
  30351.    printf("string = %s\n", string);
  30352.    printf("   strtod = %f\n", x);
  30353.    printf("   Stopped scan at %s\n\n", stopstring);
  30354.    string = "100ergs";
  30355.    x = strtod(string, &stopstring);
  30356.    printf("string = \"%s\"\n", string);
  30357.    printf("   strtod = %f\n", x);
  30358.    printf("   Stopped scan at \"%s\"\n\n", stopstring);
  30359.    return 0;
  30360.  
  30361.    /****************************************************************************
  30362.       The output should be:
  30363.  
  30364.       string = 3.1415926This stopped it
  30365.          strtod = 3.141593
  30366.          Stopped scan at This stopped it
  30367.  
  30368.       string = "100ergs"
  30369.          strtod = 100.000000
  30370.          Stopped scan at "ergs"
  30371.    ****************************************************************************/
  30372. }
  30373.  
  30374.  
  30375. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30376.  
  30377. Example of strtod 
  30378.  
  30379.      atof - Convert Character String to Float 
  30380.      atoi - Convert Character String to Integer 
  30381.      atol - Convert Character String to Long Integer 
  30382.      _atold - Convert Character String to Long Double 
  30383.      strtol - Convert Character String to Long Integer 
  30384.      strtold - Convert String to Long Double 
  30385.      strtoul - Convert String Segment to Unsigned Integer 
  30386.      wcstod - Convert Wide-Character String to Double 
  30387.      wcstol - Convert Wide-Character to Long Integer 
  30388.      wcstoul - Convert Wide-Character String to Unsigned Long 
  30389.      <stdlib.h> 
  30390.  
  30391.  
  30392. ΓòÉΓòÉΓòÉ 4.297. strtok - Tokenize String ΓòÉΓòÉΓòÉ
  30393.  
  30394.  
  30395. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30396.  
  30397. #include <string.h>
  30398. char *strtok(char *string1, const char *string2);
  30399.  
  30400.  
  30401. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30402.  
  30403. Language Level: ANSI, SAA SAA, POSIX, XPG4 
  30404.  
  30405. strtok reads string1 as a series of zero or more tokens, and string2 as the set 
  30406. of characters serving as delimiters of the tokens in string1. The tokens in 
  30407. string1 can be separated by one or more of the delimiters from string2. The 
  30408. tokens in string1 can be located by a series of calls to strtok. 
  30409.  
  30410. In the first call to strtok for a given string1, strtok searches for the first 
  30411. token in string1, skipping over leading delimiters.  A pointer to the first 
  30412. token is returned. 
  30413.  
  30414. To read the next token from string1, call strtok with a NULL string1 argument. 
  30415. A NULL string1 argument causes strtok to search for the next token in the 
  30416. previous token string. Each delimiter is replaced by a null character.  The set 
  30417. of delimiters can vary from call to call, so string2 can take any value. 
  30418.  
  30419. Return Value 
  30420. The first time strtok is called, it returns a pointer to the first token in 
  30421. string1.  In later calls with the same token string, strtok returns a pointer 
  30422. to the next token in the string.  A NULL pointer is returned when there are no 
  30423. more tokens.  All tokens are null-terminated. 
  30424.  
  30425.  
  30426. ΓòÉΓòÉΓòÉ <hidden> Example of strtok ΓòÉΓòÉΓòÉ
  30427.  
  30428. /************************************************************************
  30429.  
  30430. Using a loop, this example gathers tokens, separated by blanks or commas, from 
  30431. a string until no tokens are left.  After processing the tokens (not shown), 
  30432. the example returns the pointers to the tokens a,string, of, and tokens. The 
  30433. next call to strtok returns NULL, and the loop ends. 
  30434.  
  30435. ************************************************************************/
  30436.  
  30437. #include <stdio.h>
  30438. #include <string.h>
  30439.  
  30440. int main(void)
  30441. {
  30442.    char *token,*string = "a string, of, ,tokens\0,after null terminator";
  30443.  
  30444.     /* the string pointed to by string is broken up into the tokens
  30445.        "a string", " of", " ", and "tokens" ; the null terminator (\0)
  30446.        is encountered and execution stops after the token "tokens"            */
  30447.  
  30448.    token = strtok(string, ",");
  30449.    do {
  30450.       printf("token: %s\n", token);
  30451.    }  while (token = strtok(NULL, ","));
  30452.    return 0;
  30453.  
  30454.    /****************************************************************************
  30455.       The output should be:
  30456.  
  30457.       token: a string
  30458.       token:  of
  30459.       token:
  30460.       token: tokens
  30461.    ****************************************************************************/
  30462. }
  30463.  
  30464.  
  30465. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30466.  
  30467. Example of strtok 
  30468.  
  30469.      strcat - Concatenate Strings 
  30470.      strchr - Search for Character 
  30471.      strcmp - Compare Strings 
  30472.      strcpy - Copy Strings 
  30473.      strcspn - Compare Strings for Substrings 
  30474.      strspn - Search Strings 
  30475.      wcstok - Tokenize Wide-Character String 
  30476.      <string.h> 
  30477.  
  30478.  
  30479. ΓòÉΓòÉΓòÉ 4.298. strtol - Convert Character String to Long Integer ΓòÉΓòÉΓòÉ
  30480.  
  30481.  
  30482. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30483.  
  30484. #include <stdlib.h>
  30485. long int strtol(const char *nptr, char **endptr, int base);
  30486.  
  30487.  
  30488. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30489.  
  30490. Language Level: ANSI, SAA, XPG4 
  30491.  
  30492. strtol converts a character string to a long-integer value. The parameter nptr 
  30493. points to a sequence of characters that can be interpreted as a numerical value 
  30494. of type long int. This function stops reading the string at the first character 
  30495. that it cannot recognize as part of a number. This character can be the null 
  30496. character (\0) at the end of the string. The ending character can also be the 
  30497. first numeric character greater than or equal to the base. 
  30498.  
  30499. When you use the strtol function, nptr should point to a string with the 
  30500. following form: 
  30501.  
  30502. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  30503. Γöé                                        Γöé
  30504. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><              Γöé
  30505. Γöé   ΓööΓöÇwhite-spaceΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ  Γö£ΓöÇ0ΓöÇΓöÇΓöñ  ΓööΓöÇdigitsΓöÇΓöÿ                Γöé
  30506. Γöé            ΓööΓöÇΓö┤ΓöÇΓöÿ  Γö£ΓöÇ0xΓöÇΓöñ                      Γöé
  30507. Γöé               ΓööΓöÇ0XΓöÇΓöÿ                      Γöé
  30508. Γöé                                        Γöé
  30509. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  30510.  
  30511. If base is in the range of 2 through 36, it becomes the base of the number. If 
  30512. base is 0, the prefix determines the base (8, 16, or 10):  the prefix 0 means 
  30513. base 8 (octal);  the prefix 0x or 0X means base 16 (hexadecimal); using any 
  30514. other digit without a prefix means decimal. 
  30515.  
  30516. Return Value 
  30517. strtol returns the value represented in the string, except when the 
  30518. representation causes an overflow. For an overflow, it returns LONG_MAX or 
  30519. LONG_MIN, according to the sign of the value and errno is set to ERANGE. If 
  30520. base is not a valid number, strtol sets errno to EDOM. 
  30521.  
  30522. errno is set to ERANGE for the exceptional cases, depending on the base of the 
  30523. value.  If the string pointed to by nptr does not have the expected form, no 
  30524. conversion is performed and the value of nptr is stored in the object pointed 
  30525. to by endptr, provided that endptr is not a NULL pointer. 
  30526.  
  30527.  
  30528. ΓòÉΓòÉΓòÉ <hidden> Example of strtol ΓòÉΓòÉΓòÉ
  30529.  
  30530. /************************************************************************
  30531.  
  30532. This example converts the strings to a long value.  It prints out the converted 
  30533. value and the substring that stopped the conversion. 
  30534.  
  30535. ************************************************************************/
  30536.  
  30537. #include <stdlib.h>
  30538. #include <stdio.h>
  30539.  
  30540. int main(void)
  30541. {
  30542.    char *string,*stopstring;
  30543.    long l;
  30544.    int bs;
  30545.  
  30546.    string = "10110134932";
  30547.    printf("string = %s\n", string);
  30548.    for (bs = 2; bs <= 8; bs *= 2) {
  30549.       l = strtol(string, &stopstring, bs);
  30550.       printf("   strtol = %ld (base %d)\n", l, bs);
  30551.       printf("   Stopped scan at %s\n\n", stopstring);
  30552.    }
  30553.    return 0;
  30554.  
  30555.    /****************************************************************************
  30556.       The output should be:
  30557.  
  30558.       string = 10110134932
  30559.          strtol = 45 (base 2)
  30560.          Stopped scan at 34932
  30561.  
  30562.       strtol = 4423 (base 4)
  30563.       Stopped scan at 4932
  30564.  
  30565.       strtol = 2134108 (base 8)
  30566.       Stopped scan at 932
  30567.    ****************************************************************************/
  30568. }
  30569.  
  30570.  
  30571. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30572.  
  30573. Example of strtol 
  30574.  
  30575.      atof - Convert Character String to Float 
  30576.      atoi - Convert Character String to Integer 
  30577.      atol - Convert Character String to Long Integer 
  30578.      _atold - Convert Character String to Long Double 
  30579.      _ltoa - Convert Long Integer to String 
  30580.      strtod - Convert Character String to Double 
  30581.      strtold - Convert String to Long Double 
  30582.      strtoul - Convert String Segment to Unsigned Integer 
  30583.      wcstod - Convert Wide-Character String to Double 
  30584.      wcstol - Convert Wide-Character to Long Integer 
  30585.      wcstoul - Convert Wide-Character String to Unsigned Long 
  30586.      <stdlib.h> 
  30587.  
  30588.  
  30589. ΓòÉΓòÉΓòÉ 4.299. strtold - Convert String to Long Double ΓòÉΓòÉΓòÉ
  30590.  
  30591.  
  30592. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30593.  
  30594. #include <stdlib.h>
  30595. long double strtold(const char *nptr, char **endptr);
  30596.  
  30597.  
  30598. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30599.  
  30600. Language Level:  Extension 
  30601.  
  30602. strtold converts a character string pointed to by nptr to a long double value. 
  30603. When it reads a character it does not recognize as part of a number, strtold 
  30604. stops conversion and endptr points to the remainder of nptr.  This character 
  30605. may be the ending null character. 
  30606.  
  30607. The string pointed to by nptr must have the following format: 
  30608.  
  30609. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  30610. Γöé                                        Γöé
  30611. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ>       Γöé
  30612. Γöé   ΓööΓöÇwhitespaceΓöÇΓöÿ  ΓööΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇdigitsΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÿ        Γöé
  30613. Γöé            Γö£ΓöÇ + ΓöÇΓöñ  Γöé     ΓööΓöÇ.ΓöÇΓöÿ  ΓööΓöÇdigitsΓöÇΓöÿ Γöé         Γöé
  30614. Γöé            ΓööΓöÇ Γö┤ ΓöÇΓöÿ  ΓööΓöÇ.ΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ         Γöé
  30615. Γöé                                        Γöé
  30616. Γöé >ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><                      Γöé
  30617. Γöé   ΓööΓöÇΓö¼ΓöÇ e ΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÿ                        Γöé
  30618. Γöé    ΓööΓöÇ E ΓöÇΓöÿ  Γö£ΓöÇ + ΓöÇΓöñ                             Γöé
  30619. Γöé        ΓööΓöÇ Γö┤ ΓöÇΓöÿ                             Γöé
  30620. Γöé                                        Γöé
  30621. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  30622.  
  30623. The digits are one or more decimal digits.  If no digits appear before the 
  30624. decimal point, at least one digit must follow the decimal point.  An exponent 
  30625. expressed as a decimal integer can follow the digits.  The exponent can be 
  30626. signed. 
  30627.  
  30628. The value of nptr can also be one of the strings infinity, inf, or nan.  These 
  30629. strings are case insensitive, and can be preceded by a unary minus (-). They 
  30630. are converted to infinity and NaN values. See Infinity and NaN Support for more 
  30631. information about using infinity and NaN values. 
  30632.  
  30633. If the string pointed to by nptr does not have the expected form, no conversion 
  30634. is performed and endptr points to the value of nptr. 
  30635.  
  30636. The strtold function ignores any white-space characters, as defined by the 
  30637. isspace function. 
  30638.  
  30639. Return Value 
  30640. If successful, strtold returns the value of the long double number.  If it 
  30641. fails, strtold returns 0.  For an underflow or overflow, it returns the 
  30642. following: 
  30643.  
  30644.  Condition           Return Value 
  30645.  Underflow           0 with errno set to ERANGE 
  30646.  Positive overflow   +_LHUGE_VAL 
  30647.  Negative overflow   -_LHUGE_VAL. 
  30648.  
  30649.  
  30650. ΓòÉΓòÉΓòÉ <hidden> Example of strtold ΓòÉΓòÉΓòÉ
  30651.  
  30652. /************************************************************************
  30653.  
  30654. This example uses strtold to convert two strings, "  -001234.5678e10end of 
  30655. string" and "NaNQthis cannot be converted" to their corresponding long double 
  30656. values.  It also prints out the part of the string that cannot be converted. 
  30657.  
  30658. ************************************************************************/
  30659.  
  30660. #include <stdlib.h>
  30661. #include <stdio.h>
  30662.  
  30663. int main(void)
  30664. {
  30665.    char *nptr;
  30666.    char *endptr;
  30667.  
  30668.    nptr = "  -001234.5678e10end of string";
  30669.    printf("strtold = %.10Le\n", strtold(nptr, &endptr));
  30670.    printf("end pointer at = %s\n\n", endptr);
  30671.    nptr = "NaNthis cannot be converted";
  30672.    printf("strtold = %.10Le\n", strtold(nptr, &endptr));
  30673.    printf("end pointer at = %s\n\n", endptr);
  30674.    return 0;
  30675.  
  30676.    /****************************************************************************
  30677.       The output should be:
  30678.  
  30679.       strtold = -1.2345678000e+13
  30680.       end pointer at = end of string
  30681.  
  30682.       strtold = nan
  30683.       end pointer at = this cannot be converted
  30684.    ****************************************************************************/
  30685. }
  30686.  
  30687.  
  30688. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30689.  
  30690. Example of strtold 
  30691.  
  30692.      atof - Convert Character String to Float 
  30693.      atoi - Convert Character String to Integer 
  30694.      atol - Convert Character String to Long Integer 
  30695.      _atold - Convert Character String to Long Double 
  30696.      strtod - Convert Character String to Double 
  30697.      strtol - Convert Character String to Long Integer 
  30698.      strtoul - Convert String Segment to Unsigned Integer 
  30699.      wcstod - Convert Wide-Character String to Double 
  30700.      wcstol - Convert Wide-Character to Long Integer 
  30701.      wcstoul - Convert Wide-Character String to Unsigned Long 
  30702.      Infinity and NaN Support 
  30703.      <stdlib.h> 
  30704.  
  30705.  
  30706. ΓòÉΓòÉΓòÉ 4.300. strtoul - Convert String Segment to Unsigned Integer ΓòÉΓòÉΓòÉ
  30707.  
  30708.  
  30709. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30710.  
  30711. #include <stdlib.h>
  30712. unsigned long int strtoul(const char *string1, char **string2, int base);
  30713.  
  30714.  
  30715. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30716.  
  30717. Language Level: ANSI, SAA, XPG4 
  30718.  
  30719. strtoul converts a character string to an unsigned long integer value. The 
  30720. input string1 is a sequence of characters that can be interpreted as a 
  30721. numerical value of the type unsigned long int. strtoul stops reading the string 
  30722. at the first character that it cannot recognize as part of a number. This 
  30723. character can be the first numeric character greater than or equal to the base. 
  30724. strtoul  sets string2 to point to the resulting output string if a conversion 
  30725. is performed, and provided that string2 is not a NULL pointer. 
  30726.  
  30727. When you use strtoul, string1 should point to a string with the following form: 
  30728.  
  30729. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  30730. Γöé                                        Γöé
  30731. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><              Γöé
  30732. Γöé   ΓööΓöÇwhite-spaceΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ  Γö£ΓöÇ0ΓöÇΓöÇΓöñ  ΓööΓöÇdigitsΓöÇΓöÿ                Γöé
  30733. Γöé            ΓööΓöÇΓö┤ΓöÇΓöÿ  Γö£ΓöÇ0xΓöÇΓöñ                      Γöé
  30734. Γöé               ΓööΓöÇ0XΓöÇΓöÿ                      Γöé
  30735. Γöé                                        Γöé
  30736. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  30737.  
  30738. If base is in the range of 2 through 36, it becomes the base of the number.  If 
  30739. base is 0, the prefix determines the base (8, 16, or 10): the prefix 0 means 
  30740. base 8 (octal); the prefix 0x or 0X means base 16 (hexadecimal);  using any 
  30741. other digit without a prefix means decimal. 
  30742.  
  30743. Return Value 
  30744. strtoul returns the value represented in the string, or 0 if no conversion 
  30745. could be performed. For an overflow, strtoul returns ULONG_MAX and sets errno 
  30746. to ERANGE.  If base is not a valid number, strtoul sets errno to EDOM. 
  30747.  
  30748.  
  30749. ΓòÉΓòÉΓòÉ <hidden> Example of strtoul ΓòÉΓòÉΓòÉ
  30750.  
  30751. /************************************************************************
  30752.  
  30753. This example converts the string to an unsigned long value.  It prints out the 
  30754. converted value and the substring that stopped the conversion. 
  30755.  
  30756. ************************************************************************/
  30757.  
  30758. #include <stdio.h>
  30759. #include <stdlib.h>
  30760.  
  30761. #define  BASE          2
  30762.  
  30763. int main(void)
  30764. {
  30765.    char *string,*stopstring;
  30766.    unsigned long ul;
  30767.  
  30768.    string = "1000e13 e";
  30769.    printf("string = %s\n", string);
  30770.    ul = strtoul(string, &stopstring, BASE);
  30771.    printf("   strtoul = %ld (base %d)\n", ul, BASE);
  30772.    printf("   Stopped scan at %s\n\n", stopstring);
  30773.    return 0;
  30774.  
  30775.    /****************************************************************************
  30776.       The output should be:
  30777.  
  30778.       string = 1000e13 e
  30779.          strtoul = 8 (base 2)
  30780.          Stopped scan at e13 e
  30781.    ****************************************************************************/
  30782. }
  30783.  
  30784.  
  30785. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30786.  
  30787. Example of strtoul 
  30788.  
  30789.      atof - Convert Character String to Float 
  30790.      atoi - Convert Character String to Integer 
  30791.      atol - Convert Character String to Long Integer 
  30792.      _atold - Convert Character String to Long Double 
  30793.      strtod - Convert Character String to Double 
  30794.      strtol - Convert Character String to Long Integer 
  30795.      strtold - Convert String to Long Double 
  30796.      _ultoa - Convert Unsigned Long Integer to String 
  30797.      wcstod - Convert Wide-Character String to Double 
  30798.      wcstol - Convert Wide-Character to Long Integer 
  30799.      wcstoul - Convert Wide-Character String to Unsigned Long 
  30800.      <stdlib.h> 
  30801.  
  30802.  
  30803. ΓòÉΓòÉΓòÉ 4.301. strupr - Convert Lowercase to Uppercase ΓòÉΓòÉΓòÉ
  30804.  
  30805.  
  30806. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30807.  
  30808. #include <string.h>
  30809. char *strupr(char *string);
  30810.  
  30811.  
  30812. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30813.  
  30814. Language Level:  Extension 
  30815.  
  30816. strupr converts any lowercase letters in string to uppercase. Other characters 
  30817. are not affected. 
  30818.  
  30819. Return Value 
  30820. strupr returns a pointer to the converted string. There is no error return. 
  30821.  
  30822.  
  30823. ΓòÉΓòÉΓòÉ <hidden> Example of strupr ΓòÉΓòÉΓòÉ
  30824.  
  30825. /************************************************************************
  30826.  
  30827. This example makes a copy in all-uppercase of the string "DosWrite", and then 
  30828. prints the copy. 
  30829.  
  30830. ************************************************************************/
  30831.  
  30832. #include <string.h>
  30833. #include <stdio.h>
  30834.  
  30835. int main(void)
  30836. {
  30837.    char *string = "DosWrite";
  30838.    char *copy;
  30839.  
  30840.    copy = strupr(strdup(string));
  30841.    printf("This is a copy of the string\n");
  30842.    printf("with all letters capitalized: %s\n", copy);
  30843.    return 0;
  30844.  
  30845.    /****************************************************************************
  30846.       The output should be:
  30847.  
  30848.       This is a copy of the string
  30849.       with all letters capitalized: DOSWRITE
  30850.    ****************************************************************************/
  30851. }
  30852.  
  30853.  
  30854. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30855.  
  30856. Example of strupr 
  30857.  
  30858.      strlwr - Convert Uppercase to Lowercase 
  30859.      _toascii - _tolower - _toupper - Convert Character 
  30860.      tolower() - toupper() - Convert Character Case 
  30861.      towlower - towupper - Convert Wide Character Case 
  30862.      <string.h> 
  30863.  
  30864.  
  30865. ΓòÉΓòÉΓòÉ 4.302. strxfrm - Transform String ΓòÉΓòÉΓòÉ
  30866.  
  30867.  
  30868. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30869.  
  30870. #include <string.h>
  30871. size_t strxfrm(char *str1, const char *str2, size_t n);
  30872.  
  30873.  
  30874. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30875.  
  30876. Language Level:  ANSI, SAA, XPG4 
  30877.  
  30878. strxfrm transforms the string pointed to by str2 and places the resulting 
  30879. string into the array pointed to by str1. The transformation is determined by 
  30880. the program's locale. The transformed string is not necessarily readable, but 
  30881. can be used with the strcmp or strncmp functions. 
  30882.  
  30883. The transformation is such that, if strcmp or strncmp were applied to the two 
  30884. transformed strings, the results would be the same as applying strcoll to the 
  30885. two corresponding untransformed strings. 
  30886.  
  30887. No more than n bytes are placed into the area pointed to by str1, including the 
  30888. terminating null byte. If n is 0, str1 can be a null pointer. 
  30889.  
  30890. Return Value 
  30891. strxfrm returns the length of the transformed string (excluding the null byte). 
  30892. When n is 0 and str1 is a null pointer, the length returned is one less than 
  30893. the number of bytes required to contain the transformed string. If an error 
  30894. occurs, strxfrm function returns (size_t)-1 and sets errno to indicate the 
  30895. error. 
  30896.  
  30897. Note: 
  30898.  
  30899.    1. The string returned by strxfrm contains the weights for each order of the 
  30900.       characters within the string. As a result, the string returned may be 
  30901.       longer than the input string; it does not contain printable characters. 
  30902.  
  30903.    2. strxfrm calls malloc when the LC_COLLATE category specifies backward on 
  30904.       the order_start keyword, the substitute keyword is specified, or the 
  30905.       locale has one-to-many mapping. If malloc fails, strxfrm also fails. 
  30906.  
  30907.    3. If the locale supports double-byte characters (MB_CUR_MAX specified as 
  30908.       2), strxfrm validates the multibyte characters. (Previously it did not 
  30909.       validate the string.) strxfrm will fail if the string contains invalid 
  30910.       multibyte characters. 
  30911.  
  30912.    4. If MB_CUR_MAX is defined as 2, and no collation is defined for DBCS chars 
  30913.       in the current locale, the DBCS characters will collate after the 
  30914.       single-byte characters. 
  30915.  
  30916.  
  30917. ΓòÉΓòÉΓòÉ <hidden> Example of strxfrm ΓòÉΓòÉΓòÉ
  30918.  
  30919. /************************************************************************
  30920.  
  30921. This example uses strxfrm to transform two different strings that have the same 
  30922. collating weight. It then calls strcmp to compare the new strings. 
  30923.  
  30924. ************************************************************************/
  30925.  
  30926. #include <stdlib.h>
  30927. #include <stdio.h>
  30928. #include <locale.h>
  30929.  
  30930. int main(void)
  30931. {
  30932.    char *string1 = "stride ng1";
  30933.    char *string2 = "stri*ng1";
  30934.    char *newstring1, *newstring2;
  30935.    int  length1, length2;
  30936.  
  30937.    if (NULL == setlocale(LC_ALL, LC_C_FRANCE)) {
  30938.       printf("setlocale failed.\n");
  30939.       exit(EXIT_FAILURE);
  30940.    }
  30941.    length1=strxfrm(NULL, string1, 0);
  30942.    length2=strxfrm(NULL, string2, 0);
  30943.    if (NULL == (newstring1 = calloc(length1 + 1, 1)) ||
  30944.        NULL == (newstring2 = calloc(length2 + 1, 1))) {
  30945.       printf("insufficient memory\n");
  30946.       exit(EXIT_FAILURE);
  30947.    }
  30948.    if ((strxfrm(newstring1, string1, length1 + 1) != length1) ||
  30949.        (strxfrm(newstring2, string2, length2 + 1) != length2)) {
  30950.       printf("error in string processing\n");
  30951.       exit(EXIT_FAILURE);
  30952.    }
  30953.    if (0 != strcmp(newstring1, newstring2))
  30954.       printf("wrong results\n");
  30955.    else
  30956.       printf("correct results\n");
  30957.    return 0;
  30958.  
  30959.    /****************************************************************************
  30960.       The output should be similar to :
  30961.  
  30962.       correct results
  30963.    ****************************************************************************/
  30964. }
  30965.  
  30966.  
  30967. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  30968.  
  30969. Example of strxfrm 
  30970.  
  30971.      localeconv - Retrieve Information from the Environment 
  30972.      setlocale - Set Locale 
  30973.      strcmp - Compare Strings 
  30974.      strcoll - Compare Strings Using Collation Rules 
  30975.      strncmp - Compare Strings 
  30976.      wcsxfrm - Transform Wide-Character String 
  30977.      <string.h> 
  30978.  
  30979.  
  30980. ΓòÉΓòÉΓòÉ 4.303. swab - Swap Adjacent Bytes ΓòÉΓòÉΓòÉ
  30981.  
  30982.  
  30983. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  30984.  
  30985. #include <stdlib.h>
  30986. void swab(char *source, char *destination, int n);
  30987.  
  30988.  
  30989. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  30990.  
  30991. Language Level:  Extension 
  30992.  
  30993. swab copies n bytes from source, swaps each pair of adjacent bytes, and stores 
  30994. the result at destination.  The integer n should be an even number to allow for 
  30995. swapping. If n is an odd number, a null character (\0) is added after the last 
  30996. byte. 
  30997.  
  30998. swab is typically used to prepare binary data for transfer to a machine that 
  30999. uses a different byte order. 
  31000.  
  31001. Note:  In earlier releases of C Set ++, swab began with an underscore (_swab). 
  31002. Because it is defined by the X/Open standard, the underscore has been removed. 
  31003. For compatibility, VisualAge C++ will map _swab to swab for you. 
  31004.  
  31005. Return Value 
  31006. There is no return value. 
  31007.  
  31008.  
  31009. ΓòÉΓòÉΓòÉ <hidden> Example of swab ΓòÉΓòÉΓòÉ
  31010.  
  31011. /************************************************************************
  31012.  
  31013. This example copies n bytes from one location to another, swapping each pair of 
  31014. adjacent bytes: 
  31015.  
  31016. ************************************************************************/
  31017.  
  31018. #include <stdlib.h>
  31019. #include <stdio.h>
  31020.  
  31021. int main(void)
  31022. {
  31023.    char from[20] = "hTsii  s atsirgn..x ";
  31024.    char to[20];
  31025.  
  31026.    swab(from, to, 19);  /* swap bytes */
  31027.    printf("%s\n", to);
  31028.  
  31029.    return 0;
  31030.  
  31031.    /****************************************************************************
  31032.       The output should be:
  31033.  
  31034.       This is a string..
  31035.    ****************************************************************************/
  31036. }
  31037.  
  31038.  
  31039. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31040.  
  31041. Example of swab 
  31042.  
  31043.      fgetc - Read a Character 
  31044.      fputc - Write Character 
  31045.      <stdlib.h> 
  31046.  
  31047.  
  31048. ΓòÉΓòÉΓòÉ 4.304. swprintf - Format and Write Wide Characters to Buffer ΓòÉΓòÉΓòÉ
  31049.  
  31050.  
  31051. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31052.  
  31053. #include <wchar.h>
  31054. int swprintf(wchar_t *wcbuffer, size_t n,
  31055.              const wchar_t *format, argument-list);
  31056.  
  31057.  
  31058. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31059.  
  31060. Language Level:  ANSI 93 
  31061.  
  31062. swprintf formats and stores a series of wide characters and values into the 
  31063. wide-character buffer wcsbuffer. swprintf is equivalent to sprintf, except that 
  31064. it operates on wide characters. 
  31065.  
  31066. The value n specifies the maximum number of wide characters to be written, 
  31067. including the terminating null character. 
  31068.  
  31069. swprintf converts each entry in the argument-list according to the 
  31070. corresponding wide-character format specifier in format. The format has the 
  31071. same form and function as the format string for printf, with the following 
  31072. exceptions: 
  31073.  
  31074.      %c (without an l prefix) converts an integer argument to wchar_t, as if 
  31075.       by calling mbtowc. 
  31076.      %lc converts a wint_t to wchar_t. 
  31077.      %s (without an l prefix) converts an array of multibyte characters to an 
  31078.       array of wchar_t, as if by calling mbrtowc. The array is written up to, 
  31079.       but not including, the terminating null character, unless the precision 
  31080.       specifies a shorter output. 
  31081.      %ls writes an array of wchar_t. The array is written up to, but not 
  31082.       including, the terminating null character, unless the precision specifies 
  31083.       a shorter output. 
  31084.  
  31085.  If you specify a null string for the %s or %ls format specifier, swprintf 
  31086.  prints (null). 
  31087.  
  31088.  For a complete description of format specifiers, see printf - Print Formatted 
  31089.  Characters. 
  31090.  
  31091.  A null wide character is added to the end of the wide characters written; the 
  31092.  null wide character is not counted as part of the returned value. If copying 
  31093.  takes place between objects that overlap, the behavior is undefined. 
  31094.  
  31095.  In extended mode, swprintf also converts floating-point values of NaN and 
  31096.  infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  31097.  and sign of the string is determined by the format specifiers.  See Infinity 
  31098.  and NaN Support for more information on infinity and NaN values. 
  31099.  
  31100.  Return Value 
  31101.  swprintf returns the number of bytes written in the array, not counting the 
  31102.  terminating null wide character. 
  31103.  
  31104.  
  31105. ΓòÉΓòÉΓòÉ <hidden> Example of swprintf ΓòÉΓòÉΓòÉ
  31106.  
  31107. /************************************************************************
  31108.  
  31109. This example uses swprintf to format and print several values to buffer. 
  31110.  
  31111. ************************************************************************/
  31112.  
  31113. #include <wchar.h>
  31114. #include <stdio.h>
  31115.  
  31116. #define BUF_SIZE 100
  31117.  
  31118. int main(void)
  31119. {
  31120.    wchar_t wcsbuf[BUF_SIZE];
  31121.    wchar_t wstring[] = L"ABCDE";
  31122.    int     num;
  31123.  
  31124.    num = swprintf(wcsbuf, BUF_SIZE, L"%s", "xyz");
  31125.    num += swprintf(wcsbuf + num, BUF_SIZE - num, L"%ls", wstring);
  31126.    num += swprintf(wcsbuf + num, BUF_SIZE - num, L"%i", 100);
  31127.    printf("The array wcsbuf contains: \"%ls\"\n", wcsbuf);
  31128.    return 0;
  31129.  
  31130.    /****************************************************************************
  31131.       The output should be similar to :
  31132.  
  31133.       The array wcsbuf contains: "xyzABCDE100"
  31134.    ****************************************************************************/
  31135. }
  31136.  
  31137.  
  31138. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31139.  
  31140. Example of swprintt 
  31141.  
  31142.      printf - Print Formatted Characters 
  31143.      sprintf - Print Formatted Data to Buffer 
  31144.      swscanf - Read Wide Characters from Buffer 
  31145.      vswprintf - Format and Write Wide Characters to Buffer 
  31146.      <wchar.h> 
  31147.  
  31148.  
  31149. ΓòÉΓòÉΓòÉ 4.305. swscanf - Read Wide Characters from Buffer ΓòÉΓòÉΓòÉ
  31150.  
  31151.  
  31152. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31153.  
  31154. #include <wchar.h>
  31155. int swscanf(const wchar_t *wcsbuffer, const wchar_t *format,
  31156.             argument-list);
  31157.  
  31158.  
  31159. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31160.  
  31161. Language Level:  ANSI 93 
  31162.  
  31163. swscanf reads wide data from wcsbuffer into the locations given by 
  31164. argument-list. swscanf is equivalent to sscanf, except that it operates on wide 
  31165. characters. 
  31166.  
  31167. Each argument in the argument-list must point to a variable with a type that 
  31168. corresponds to a type specifier in format. The format has the same form and 
  31169. function as the format string for scanf, with the following exceptions: 
  31170.  
  31171.      %c (with no l prefix) converts one or more wchar_t characters (depending 
  31172.       on precision) to multibyte characters, as if by calling wcrtomb. 
  31173.      %lc converts one or more wchar_t characters (depending on precision) to 
  31174.       an array of wchar_t. 
  31175.      %s (with no l prefix) converts a sequence of non-white-space wchar_t 
  31176.       characters to multibyte characters, as if by calling wcrtomb. The array 
  31177.       includes the terminating null character. 
  31178.      %ls copies an array of wchar_t, including the terminating null wide 
  31179.       character, to an array of wchar_t. 
  31180.  
  31181.  For a complete description of format specifiers, see scanf Format 
  31182.  Specification Fields. 
  31183.  
  31184.  When swscanf reaches the end of the wide character string, it stops parsing 
  31185.  and returns a value as indicated below (this behavior is the same as sscanf). 
  31186.  If copying takes place between objects that overlap, the behavior is 
  31187.  undefined. 
  31188.  
  31189.  Return Value 
  31190.  swscanf returns the number of input items that were successfully converted and 
  31191.  assigned.  The value does not include fields that were read but not assigned. 
  31192.  If an input failure (such as the end of the string) is encountered before any 
  31193.  conversion, swscanf returns EOF. 
  31194.  
  31195.  
  31196. ΓòÉΓòÉΓòÉ <hidden> Example of swscanf ΓòÉΓòÉΓòÉ
  31197.  
  31198. /************************************************************************
  31199.  
  31200. This example uses swscanf to scan in wide characters, and then prints them. 
  31201.  
  31202. ************************************************************************/
  31203.  
  31204. #include <wchar.h>
  31205. #include <stdio.h>
  31206.  
  31207. int main(void)
  31208. {
  31209.    wchar_t *tokenstring = L"xyz ╨ôA╨ôB╨ôC╨ôD╨ôEΓöÇa 1234";
  31210.    char    string[20];
  31211.    wchar_t wstring[20];
  31212.    wchar_t wc;
  31213.    int     i;
  31214.    int     num;
  31215.  
  31216.    num = swscanf(tokenstring, L"%s %ls %lc %d", string, wstring, &wc, &i);
  31217.    printf("string   = %s\n",  string );
  31218.    printf("wstring  = %ls\n", wstring );
  31219.    printf("wc       = %lc\n", wc );
  31220.    printf("i        = %d\n",  i );
  31221.    printf("total number of fields scanned: %i\n", num);
  31222.    return 0;
  31223.  
  31224.    /****************************************************************************
  31225.       The output should be similar to :
  31226.  
  31227.       string   = xyz
  31228.       wstring  = ╨ôA╨ôB╨ôC╨ôD╨ôEΓöÇa
  31229.       wc       = 1
  31230.       i        = 234
  31231.       total number of fields scanned: 4
  31232.    ****************************************************************************/
  31233. }
  31234.  
  31235.  
  31236. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31237.  
  31238. Example of swscanf 
  31239.  
  31240.      scanf - Read Data 
  31241.      scanf Format Specification Fields 
  31242.      sscanf - Read Data 
  31243.      swprintf - Format and Write Wide Characters to Buffer 
  31244.      <wchar.h> 
  31245.  
  31246.  
  31247. ΓòÉΓòÉΓòÉ 4.306. system - Invoke the Command Processor ΓòÉΓòÉΓòÉ
  31248.  
  31249.  
  31250. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31251.  
  31252. #include <stdlib.h>
  31253. int system(char *string);
  31254.  
  31255.  
  31256. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31257.  
  31258. Language Level:  ANSI, SAA, XPG4, Extension 
  31259.  
  31260. system passes the command string to a command processor to be run. The command 
  31261. processor specified in the COMSPEC environment variable is first searched for. 
  31262. If it does not exist or is not a valid executable file, the default command 
  31263. processor, CMD.EXE, is searched for in the current directory and in all the 
  31264. directories specified in the PATH environment variable. 
  31265.  
  31266. If the specified command is the name of an executable file created from a C 
  31267. program, full initialization and termination are performed, including automatic 
  31268. flushing of buffers and closing of files.  To pass information across a system 
  31269. function, use a method of interprocess communication like pipes or shared 
  31270. memory. 
  31271.  
  31272. You can also use system to redirect standard streams using the redirection 
  31273. operators (the angle brackets), for example: 
  31274.  
  31275.    rc = system("cprogram < in.file");
  31276.  
  31277. The defaults for the standard streams will be whatever the standard streams are 
  31278. at the point of the system call;  for example, if the root program redirects 
  31279. stdout to file.txt, a printf call in a C module invoked by a system call will 
  31280. append to file.txt. 
  31281.  
  31282. Return Value 
  31283. If the argument is a null pointer, system returns nonzero if a command 
  31284. processor exists, and 0 if it does not. system returns the the return value 
  31285. from the command processor if it is successfully called. If system cannot call 
  31286. the command processor successfully, the return value is -1 and errno is set to 
  31287. one of the following values: 
  31288.  
  31289.  Value         Meaning 
  31290.  ENOCMD        No valid command processor found. 
  31291.  ENOMEM        Insufficient memory to complete the function. 
  31292.  EOS2ERR       A system error occurred.  Check _doserrno for the specific OS/2 
  31293.                error code. 
  31294.  
  31295.  
  31296. ΓòÉΓòÉΓòÉ <hidden> Example of system ΓòÉΓòÉΓòÉ
  31297.  
  31298. /************************************************************************
  31299.  
  31300. This example shows how to use system to execute the OS/2 command dir c:\. 
  31301.  
  31302. ************************************************************************/
  31303.  
  31304. #include <stdlib.h>
  31305.  
  31306. int main(void)
  31307. {
  31308.    int rc;
  31309.  
  31310.    rc = system("dir c:\\");
  31311.    return rc;
  31312.  
  31313.    /* The output should be a listing of the root directory on the c: drive    */
  31314. }
  31315.  
  31316.  
  31317. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31318.  
  31319. Example of system 
  31320.  
  31321.      exit - End Program 
  31322.      _exit - End Process 
  31323.      <process.h> 
  31324.      <stdlib.h> 
  31325.  
  31326.  
  31327. ΓòÉΓòÉΓòÉ 4.307. __sxchg - Exchange Integer Value with Memory ΓòÉΓòÉΓòÉ
  31328.  
  31329.  
  31330. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31331.  
  31332. #include <builtin.h>
  31333. short _Builtin __sxchg(volatile short*lockptr, short value);
  31334.  
  31335.  
  31336. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31337.  
  31338. Language Level:  Extension 
  31339.  
  31340. __sxchg puts the specified value in the memory location pointed to by lockptr, 
  31341. and returns the value that was previously in that location. 
  31342.  
  31343. Use this function to implement fast-RAM semaphores to serialize access to a 
  31344. critical resource (so that only one thread can use it at a time). You can also 
  31345. use OS/2 semaphores to serialize resource access, but they are slower. 
  31346. Typically you would create both a fast-RAM semaphore and an OS/2 semaphore for 
  31347. the resource. For more details about OS/2 semaphores and how to use them, see 
  31348. the Control Program Guide and Reference. 
  31349.  
  31350. To implement a fast-RAM semaphore, allocate a volatile memory location lockptr 
  31351. (for __sxchg, it must be a short), and statically initialize it to 0 to 
  31352. indicate that the resource is free (not being used). To give a thread access to 
  31353. the resource, call __sxchg from the thread to exchange a non-zero value with 
  31354. that memory location. If __sxchg returns 0, the thread can access the resource; 
  31355. it has also set the memory location so that other threads can tell the resource 
  31356. is in use. When your thread no longer needs the resource, call __sxchg again to 
  31357. reset the memory location to 0. 
  31358.  
  31359. If __sxchg returns a non-zero value, another thread is already using the 
  31360. resource, and the calling thread must wait for access. You could then use the 
  31361. OS/2 semaphore to inform your waiting thread when the resource is unlocked by 
  31362. the thread currently using it. 
  31363.  
  31364. It is important that you set the memory to a non-zero value when you are using 
  31365. the resource.  You can use the same non-zero value for all threads, or a unique 
  31366. value for each. 
  31367.  
  31368. Note:  __sxchg is a built-in function, which means it is implemented as an 
  31369. inline instruction and has no backing code in the library.  For this reason: 
  31370.  
  31371.      You cannot take the address of __sxchg. 
  31372.      You cannot parenthesize a call to __sxchg. (Parentheses specify a call to 
  31373.       the function's backing code, and __sxchg has none.) 
  31374.  
  31375.  Return Value 
  31376.  __sxchg returns the previous value stored in the memory location pointed to by 
  31377.  lockptr. 
  31378.  
  31379.  
  31380. ΓòÉΓòÉΓòÉ <hidden> Example of __sxchg ΓòÉΓòÉΓòÉ
  31381.  
  31382. /************************************************************************
  31383.  
  31384. This example creates five separate threads, each associated with a State. At 
  31385. most two threads can have a State of Eating at the same time. When a thread 
  31386. calls PickUpChopSticks, that function checks the states of the preceding 
  31387. threads to make sure they are not already Eating, If the call to __sxchg is 
  31388. successful, the thread has locked the Lock semaphore and can change its State 
  31389. to Eating. It then calls __sxchg a second time to unlock the semaphore, and 
  31390. returns. 
  31391.  
  31392. If __sxchg cannot lock the semaphore, another thread has it locked.  The 
  31393. current thread then suspends itself briefly with DosSleep and tries again. The 
  31394. semaphore is used to ensure that two threads cannot simultaneously change their 
  31395. State to Eating, which would cause a deadlock. (Note that although the 
  31396. semaphore solves the problem of deadlock, it is not an optimal solution; some 
  31397. threads may never get the semaphore or the State of Eating.) 
  31398.  
  31399. Note:  You must compile this example with the multithread (/Gm) option. The 
  31400. example runs in an infinite loop; press Ctrl-C to end it. 
  31401.  
  31402. ************************************************************************/
  31403.  
  31404. #pragma strings(readonly)
  31405.  
  31406. #define INCL_DOS
  31407. #include <os2.h>
  31408. #include <stdlib.h>
  31409. #include <stdio.h>
  31410. #include <builtin.h>
  31411.  
  31412. typedef enum {
  31413.    Thinking,
  31414.    Eating,
  31415.    Hungry
  31416. } States;
  31417.  
  31418. #define UNLOCKED 0
  31419. #define LOCKED   1
  31420. #define NUM_PHILOSOPHERS 5
  31421.  
  31422. static volatile short Lock;
  31423. static States State[NUM_PHILOSOPHERS];
  31424. static const int NameMap[NUM_PHILOSOPHERS] = {0, 1, 2, 3, 4};
  31425. static const char * const Names[NUM_PHILOSOPHERS] = {"Plato",
  31426.                                                      "Socrates",
  31427.                                                      "Kant",
  31428.                                                      "Hegel",
  31429.                                                      "Nietsche"};
  31430.  
  31431. void PickUpChopSticks(int Ident);
  31432. void PutDownChopSticks(int Ident);
  31433. void Think(int Ident);
  31434. void Eat(int Ident);
  31435. void _Optlink StartPhilosopher(void *pIdent);
  31436.  
  31437. void _Optlink StartPhilosopher(void *pIdent)
  31438. {
  31439.    int Ident = *(int *)pIdent;
  31440.    while (1) {
  31441.       State[Ident] = Hungry;
  31442.       printf("%s hungry.\n", Names[Ident]);
  31443.       PickUpChopSticks(Ident);
  31444.       Eat(Ident);
  31445.       PutDownChopSticks(Ident);
  31446.       Think(Ident);
  31447.    }
  31448. }
  31449.  
  31450. int main(int argc, char *argv[], char *envp[])
  31451. {
  31452.    int           i;
  31453.    unsigned long tid;
  31454.  
  31455.    for (i = 0; i < NUM_PHILOSOPHERS; i++) {
  31456.       tid = _beginthread(StartPhilosopher, NULL, 8192, (void *)&NameMap[i]);
  31457.       if (tid == -1) {
  31458.          printf("Unable to start %s.\n", Names[i]);
  31459.       }
  31460.       else {
  31461.          printf("%s started with Thread Id = %d.\n", Names[i], tid);
  31462.       }
  31463.    }
  31464.    DosWaitThread(&tid, DCWW_WAIT);
  31465.  
  31466.    return 0;
  31467. }
  31468.  
  31469. void PickUpChopSticks(int Ident)
  31470. {
  31471.    while (1) {
  31472.       if (State[(Ident + NUM_PHILOSOPHERS - 1) % NUM_PHILOSOPHERS] != Eating &&
  31473.           State[(Ident + 1) % NUM_PHILOSOPHERS] != Eating                    &&
  31474.           !__sxchg(&Lock, LOCKED)) {
  31475.             State[Ident] = Eating;
  31476.             __sxchg(&Lock, UNLOCKED);
  31477.             return;
  31478.       }
  31479.       else {
  31480.          DosSleep(1);
  31481.       }
  31482.    }
  31483. }
  31484.  
  31485. void PutDownChopSticks(int Ident)
  31486. {
  31487.    State[Ident] = Thinking;
  31488. }
  31489.  
  31490. void Eat(int Ident)
  31491. {
  31492.    printf("%s eating.\n", Names[Ident]);
  31493.    DosSleep(1);
  31494. }
  31495.  
  31496. void Think(int Ident)
  31497. {
  31498.    printf("%s thinking.\n", Names[Ident]);
  31499.    DosSleep(1);
  31500. }
  31501.  
  31502.    /****************************************************************************
  31503.       The output should be similar to :
  31504.  
  31505.       Plato started with Thread Id = 2.
  31506.       Socrates started with Thread Id = 3.
  31507.       Kant started with Thread Id = 4.
  31508.       Hegel started with Thread Id = 5.
  31509.       Nietsche started with Thread Id = 6.
  31510.       Plato hungry.
  31511.       Plato eating.
  31512.       Socrates hungry.
  31513.       Kant hungry.
  31514.       Kant eating.
  31515.       Hegel hungry.
  31516.       Nietsche hungry.
  31517.       Kant thinking.
  31518.       Plato thinking.
  31519.       Plato hungry.
  31520.       Plato eating.
  31521.       Kant hungry.
  31522.       Kant eating.
  31523.         :
  31524.    ****************************************************************************/
  31525.  
  31526.  
  31527. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31528.  
  31529. Example of __sxchg 
  31530.  
  31531.      __cxchg - Exchange Character Value with Memory 
  31532.      __lxchg - Exchange Integer Value with Memory 
  31533.      <builtin.h> 
  31534.  
  31535.  
  31536. ΓòÉΓòÉΓòÉ 4.308. tan - Calculate Tangent ΓòÉΓòÉΓòÉ
  31537.  
  31538.  
  31539. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31540.  
  31541. #include <math.h>
  31542. double tan(double x);
  31543.  
  31544.  
  31545. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31546.  
  31547. Language Level: ANSI, SAA, POSIX, XPG4 
  31548.  
  31549. tan calculates the tangent of x, where x is expressed in radians. If x is too 
  31550. large, a partial loss of significance in the result can occur. 
  31551.  
  31552. Return Value 
  31553. tan returns the value of the tangent of x. 
  31554.  
  31555.  
  31556. ΓòÉΓòÉΓòÉ <hidden> Example of tan ΓòÉΓòÉΓòÉ
  31557.  
  31558. /************************************************************************
  31559.  
  31560. This example computes x as the tangent of pi/4. 
  31561.  
  31562. ************************************************************************/
  31563.  
  31564. #include <math.h>
  31565.  
  31566. int main(void)
  31567. {
  31568.    double pi,x;
  31569.  
  31570.    pi = 3.1415926;
  31571.    x = tan(pi/4.0);
  31572.    printf("tan( %lf ) is %lf\n", pi/4, x);
  31573.    return 0;
  31574.  
  31575.    /****************************************************************************
  31576.       The output should be:
  31577.  
  31578.       tan( 0.785398 ) is 1.000000
  31579.    ****************************************************************************/
  31580. }
  31581.  
  31582.  
  31583. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31584.  
  31585. Example of tan 
  31586.  
  31587.      atan - atan2 - Calculate Arctangent 
  31588.      cos - Calculate Cosine 
  31589.      _fpatan - Calculate Arctangent 
  31590.      _fptan - Calculate Tangent 
  31591.      sin - Calculate Sine 
  31592.      tanh - Calculate Hyperbolic Tangent 
  31593.      <math.h> 
  31594.  
  31595.  
  31596. ΓòÉΓòÉΓòÉ 4.309. tanh - Calculate Hyperbolic Tangent ΓòÉΓòÉΓòÉ
  31597.  
  31598.  
  31599. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31600.  
  31601. #include <math.h>
  31602. double tanh(double x);
  31603.  
  31604.  
  31605. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31606.  
  31607. Language Level: ANSI, SAA, POSIX, XPG4 
  31608.  
  31609. tanh calculates the hyperbolic tangent of x, where x is expressed in radians. 
  31610.  
  31611. Return Value 
  31612. tanh returns the value of the hyperbolic tangent of x. The result of tanh 
  31613. cannot have a range error. 
  31614.  
  31615.  
  31616. ΓòÉΓòÉΓòÉ <hidden> Example of tanh ΓòÉΓòÉΓòÉ
  31617.  
  31618. /************************************************************************
  31619.  
  31620. This example computes x as the hyperbolic tangent of pi/4. 
  31621.  
  31622. ************************************************************************/
  31623.  
  31624. #include <math.h>
  31625.  
  31626. int main(void)
  31627. {
  31628.    double pi,x;
  31629.  
  31630.    pi = 3.1415926;
  31631.    x = tanh(pi/4);
  31632.    printf("tanh( %lf ) = %lf\n", pi/4, x);
  31633.    return 0;
  31634.  
  31635.    /****************************************************************************
  31636.       The output should be:
  31637.  
  31638.       tanh( 0.785398 ) = 0.655794
  31639.  
  31640.    ****************************************************************************/
  31641. }
  31642.  
  31643.  
  31644. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31645.  
  31646. Example of tanh 
  31647.  
  31648.      atan - atan2 - Calculate Arctangent 
  31649.      cosh - Calculate Hyperbolic Cosine 
  31650.      _fpatan - Calculate Arctangent 
  31651.      _fptan - Calculate Tangent 
  31652.      sinh - Calculate Hyperbolic Sine 
  31653.      tan - Calculate Tangent 
  31654.      <math.h> 
  31655.  
  31656.  
  31657. ΓòÉΓòÉΓòÉ 4.310. _tcalloc - Reserve Tiled Storage Block ΓòÉΓòÉΓòÉ
  31658.  
  31659.  
  31660. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31661.  
  31662. #include <stdlib.h>  /* also in <malloc.h> */
  31663. void *_tcalloc(size_t number, size_t size)
  31664.  
  31665.  
  31666. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31667.  
  31668. Language Level:  Extension 
  31669.  
  31670. _tcalloc allocates tiled memory for an array of number elements, each of length 
  31671. size bytes, and initializes all bits of each element to 0. 
  31672.  
  31673. To use _tcalloc, you must compile with the /Gt compiler option. This option 
  31674. maps all calloc calls to _tcalloc (you can also call _tcalloc explicitly). 
  31675.  
  31676. Note:  The /Gt option maps all calls to regular memory management functions to 
  31677. their tiled versions. To prevent a call from being mapped, parenthesize the 
  31678. function name. 
  31679.  
  31680. _tcalloc works just like calloc except that it allocates tiled memory instead 
  31681. of regular memory. Tiled memory will not cross 64K boundaries, as long as the 
  31682. object is less than 64K in size. Objects larger than 64K in size will cross 64K 
  31683. boundaries. If you have objects that may be accessed by 16-bit code, you should 
  31684. store them in tiled memory. Tiled memory is limited to 512 MB per process. 
  31685.  
  31686. You can also create your own heaps of tiled memory. See "Memory Management" in 
  31687. the Programming Guide for more information. 
  31688.  
  31689. A debug version of this function, _debug_tcalloc, is also available. Use the 
  31690. /Tm compiler option to map _tcalloc calls to _debug_tcalloc. 
  31691.  
  31692. Return Value 
  31693. _tcalloc returns a pointer to the allocated tiled memory. If not enough storage 
  31694. is available, or if num or size is 0, _tcalloc returns NULL. 
  31695.  
  31696.  
  31697. ΓòÉΓòÉΓòÉ <hidden> Example of _tcalloc ΓòÉΓòÉΓòÉ
  31698.  
  31699. /************************************************************************
  31700.  
  31701. This example allocates tiled memory for an array of 100 elements of size char. 
  31702.  
  31703. Note:  You must compile this example with the /Gt option to enable tiled 
  31704. memory. 
  31705.  
  31706. ************************************************************************/
  31707.  
  31708. #include <stdlib.h>
  31709.  
  31710. int main(void)
  31711. {
  31712.    char *memoryPtr;
  31713.  
  31714.    if (NULL != (memoryPtr = calloc(100, sizeof(char))))
  31715.       puts("Successfully allocated 100 char of tiled memory.");
  31716.    else
  31717.       puts("Could not allocate tiled memory.");
  31718.    free(memoryPtr);
  31719.    return 0;
  31720.  
  31721.    /****************************************************************************
  31722.       The output should be similar to :
  31723.  
  31724.       Successfully allocated 100 char of tiled memory.
  31725.    ****************************************************************************/
  31726. }
  31727.  
  31728.  
  31729. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31730.  
  31731. Example of _tcalloc 
  31732.  
  31733.      calloc - Reserve and Initialize Storage 
  31734.      _debug_calloc - Allocate and Initialize Memory 
  31735.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  31736.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  31737.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  31738.      _tfree - Free Tiled Storage Block 
  31739.      _theapmin - Release Unused Tiled Memory 
  31740.      _tmalloc - Reserve Tiled Storage Block 
  31741.      _trealloc - Reallocate Tiled Storage Block 
  31742.      _ucalloc - Reserve and Initialize Memory from User Heap 
  31743.      Differentiating between Memory Management Functions 
  31744.      Managing Memory in the Programming Guide 
  31745.      <malloc.h> 
  31746.      <stdlib.h> 
  31747.  
  31748.  
  31749. ΓòÉΓòÉΓòÉ 4.311. _tdump_allocated - Get Information about Allocated Tiled Memory ΓòÉΓòÉΓòÉ
  31750.  
  31751.  
  31752. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31753.  
  31754. #include <stdlib.h>   /* also in <malloc.h> */
  31755. void _tdump_allocated(int nbytes);
  31756.  
  31757.  
  31758. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31759.  
  31760. Language Level:  Extension 
  31761.  
  31762. _tdump_allocated prints information to stderr about each tiled memory block 
  31763. that is currently allocated and was allocated using the tiled debug memory 
  31764. management functions (_debug_tcalloc, _debug_tmalloc, and so on). 
  31765.  
  31766. _tdump_allocated works just like _dump_allocated, but displays information 
  31767. about tiled memory instead of regular memory. 
  31768.  
  31769. Use nbytes to specify how many bytes of each memory block are to be printed. If 
  31770. nbytes is: 
  31771.  
  31772.  Negative value  Prints all bytes of each block. 
  31773.  0               Prints no bytes. 
  31774.  Positive value  Prints the specified number of bytes or the entire block, 
  31775.                  whichever is smaller. 
  31776.  
  31777.  _tdump_allocated prints the information to stderr by default. You can change 
  31778.  the destination with the _set_crt_msg_handle function. 
  31779.  
  31780.  Call _tdump_allocated at points in your code where you want a report of the 
  31781.  currently allocated memory. For example, a good place to call _tdump_allocated 
  31782.  is a point where most of the memory is already freed and you want to find a 
  31783.  memory leak, such as at the end of a program. 
  31784.  
  31785.  You can also use _tdump_allocated_delta to display information about only the 
  31786.  tiled memory that was allocated since the previous call to _tdump_allocated or 
  31787.  _tdump_allocated_delta. 
  31788.  
  31789.  To use _tdump_allocated and the tiled debug versions of the memory management 
  31790.  functions, specify the /Tm /Gt compiler options. the debug memory and tiled 
  31791.  memory compiler options (/Tm /Gt). 
  31792.  
  31793.  Note:  The /Tm /Gt options map all calls to regular memory management 
  31794.  functions to their tiled debug versions. To prevent a call from being mapped, 
  31795.  parenthesize the function name. 
  31796.  
  31797.  Return Value: 
  31798.  There is no return value. 
  31799.  
  31800.  
  31801. ΓòÉΓòÉΓòÉ <hidden> Example of _tdump_allocated ΓòÉΓòÉΓòÉ
  31802.  
  31803. /************************************************************************
  31804.  
  31805. This example allocates some memory and then calls _tdump_allocated to display 
  31806. information about the allocated blocks. 
  31807.  
  31808. Note:  You must compile this example with the /Tm /Gt options. 
  31809.  
  31810. ************************************************************************/
  31811.  
  31812. #include <stdlib.h>
  31813. #include <stdio.h>
  31814. #include <string.h>
  31815.  
  31816. int main(void)
  31817. {
  31818.    char *ptr1;
  31819.  
  31820.    if (NULL == (ptr1 = malloc(10))) {
  31821.       puts("Could not allocate memory block.");
  31822.       exit(EXIT_FAILURE);
  31823.    }
  31824.    memset(ptr1, 'a', 5);
  31825.    _tdump_allocated(10);
  31826.    free(ptr1);
  31827.    return 0;
  31828.  
  31829.    /****************************************************************************
  31830.       The output should be similar to :
  31831.  
  31832.       -------------------------------------------------------------------------------
  31833.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  31834.       -------------------------------------------------------------------------------
  31835.       Address: 0x00080120      Size: 0x0000000A (10)
  31836.       This memory block was (re)allocated at line number 9 in _tdump_alloc.c.
  31837.       Memory contents:  61616161 61AAAAAA AAAA                 [aaaaa╨ÿ╨ÿ╨ÿ╨ÿ╨ÿ      ]
  31838.       -------------------------------------------------------------------------------
  31839.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  31840.       -------------------------------------------------------------------------------
  31841.    ****************************************************************************/
  31842. }
  31843.  
  31844.  
  31845. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31846.  
  31847. Example of _tdump_allocated 
  31848.  
  31849.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  31850.      _debug_tfree - Release Tiled Memory 
  31851.      _debug_theapmin - Release Unused Tiled Memory 
  31852.      _debug_tmalloc - Reserve Tiled Memory 
  31853.      _debug_trealloc - Reallocate Tiled Memory Block 
  31854.      _dump_allocated - Get Information about Allocated Memory 
  31855.      _set_crt_msg_handle - Change Runtime Message Output Destination 
  31856.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  31857.      _udump_allocated - Get Information about Allocated Memory in Heap 
  31858.      Differentiating between Memory Management Functions 
  31859.      "Managing Memory" in the Programming Guide 
  31860.      "Debugging Your Heaps" in the Programming Guide 
  31861.      <malloc.h> 
  31862.      <stdlib.h> 
  31863.  
  31864.  
  31865. ΓòÉΓòÉΓòÉ 4.312. _tdump_allocated_delta - Get Information about Allocated Tiled Memory ΓòÉΓòÉΓòÉ
  31866.  
  31867.  
  31868. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31869.  
  31870. #include <stdlib.h>  /* also in <malloc.h> */
  31871. void _tdump_allocated_delta(int nbytes);
  31872.  
  31873.  
  31874. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  31875.  
  31876. Language Level:  Extension 
  31877.  
  31878. For the heap you specify, _tdump_allocated_delta prints information to stderr 
  31879. about each tiled memory block allocated by a tiled debug memory management 
  31880. function (_debug_tmalloc and so on) since the last call to 
  31881. _tdump_allocated_delta or _tdump_allocated. 
  31882.  
  31883. _tdump_allocated_delta and _tdump_allocated print the same type of information 
  31884. to stderr, but _tdump_allocated displays information about all blocks that have 
  31885. been allocated since the start of your program. 
  31886.  
  31887. _tdump_allocated_delta works just like _dump_allocated_delta, except that it 
  31888. displays information about tiled memory instead of regular memory. 
  31889.  
  31890. Use nbytes to specify how many bytes of each memory block are to be printed. If 
  31891. nbytes is: 
  31892.  
  31893.  Negative value  Prints all bytes of each block. 
  31894.  0               Prints no bytes. 
  31895.  Positive value  Prints the specified number of bytes or the entire block, 
  31896.                  whichever is smaller. 
  31897.  
  31898.  _tdump_allocated_delta prints the information to stderr by default. You can 
  31899.  change the destination with the _set_crt_msg_handle function. 
  31900.  
  31901.  To use _tdump_allocated_delta and the tiled debug versions of the memory 
  31902.  management functions, specify the debug memory and tiled memory compiler 
  31903.  options (/Tm /Gt). 
  31904.  
  31905.  Note:  The /Tm /Gt options map all calls to regular memory management 
  31906.  functions to their tiled debug versions. To prevent a call from being mapped, 
  31907.  parenthesize the function name. 
  31908.  
  31909.  Return Value: 
  31910.  There is no return value. 
  31911.  
  31912.  
  31913. ΓòÉΓòÉΓòÉ <hidden> Example of _tdump_allocated_delta ΓòÉΓòÉΓòÉ
  31914.  
  31915. /************************************************************************
  31916.  
  31917. This example allocates some memory and calls _tdump_allocated to print 
  31918. information about the allocated blocks. It then allocates more memory, and 
  31919. calls _tdump_allocated_delta to print information about the blocks allocated 
  31920. since the call to _tdump_allocated. 
  31921.  
  31922. Note:  You must compile this example with the /Tm /Gt options. 
  31923.  
  31924. ************************************************************************/
  31925.  
  31926. #include <stdlib.h>
  31927. #include <stdio.h>
  31928.  
  31929. int main(void)
  31930. {
  31931.    char *ptr1, *ptr2;
  31932.  
  31933.    if (NULL == (ptr1 = malloc(10))) {
  31934.       puts("Could not allocate memory block.");
  31935.       exit(EXIT_FAILURE);
  31936.    }
  31937.    memset(ptr1, 'a', 5);
  31938.    _tdump_allocated(10);
  31939.  
  31940.    if (NULL == (ptr2 = malloc(20))) {
  31941.       puts("Could not allocate memory block.");
  31942.       exit(EXIT_FAILURE);
  31943.    }
  31944.    memset(ptr2, 'b', 5);
  31945.    _tdump_allocated_delta(10);
  31946.  
  31947.    free(ptr1);
  31948.    free(ptr2);
  31949.    return 0;
  31950.  
  31951.    /****************************************************************************
  31952.       The output should be similar to :
  31953.  
  31954.       -------------------------------------------------------------------------------
  31955.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  31956.       -------------------------------------------------------------------------------
  31957.       Address: 0x00080120      Size: 0x0000000A (10)
  31958.       This memory block was (re)allocated at line number 8 in _tdump_all_d.c.
  31959.       Memory contents:  61616161 61AAAAAA AAAA                 [aaaaa╨ÿ╨ÿ╨ÿ╨ÿ╨ÿ      ]
  31960.       -------------------------------------------------------------------------------
  31961.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  31962.       -------------------------------------------------------------------------------
  31963.       -------------------------------------------------------------------------------
  31964.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  31965.       -------------------------------------------------------------------------------
  31966.       Address: 0x00080160      Size: 0x00000014 (20)
  31967.       This memory block was (re)allocated at line number 15 in _tdump_all_d.c.
  31968.       Memory contents:  62626262 62AAAAAA AAAA                 [bbbbb╨ÿ╨ÿ╨ÿ╨ÿ╨ÿ      ]
  31969.       -------------------------------------------------------------------------------
  31970.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  31971.       -------------------------------------------------------------------------------
  31972.    ****************************************************************************/
  31973. }
  31974.  
  31975.  
  31976. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  31977.  
  31978. Example of _tdump_allocated_delta 
  31979.  
  31980.      _dump_allocated_delta - Get Information about Allocated Memory 
  31981.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  31982.      _debug_tfree - Release Tiled Memory 
  31983.      _debug_theapmin - Release Unused Tiled Memory 
  31984.      _debug_tmalloc - Reserve Tiled Memory 
  31985.      _debug_trealloc - Reallocate Tiled Memory Block 
  31986.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  31987.      Differentiating between Memory Management Functions 
  31988.      "Managing Memory" in the Programming Guide 
  31989.      "Debugging Your Heaps" in the Programming Guide 
  31990.      <malloc.h> 
  31991.      <stdlib.h> 
  31992.  
  31993.  
  31994. ΓòÉΓòÉΓòÉ 4.313. _tell - Get Pointer Position ΓòÉΓòÉΓòÉ
  31995.  
  31996.  
  31997. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  31998.  
  31999. #include <io.h>
  32000. long _tell(int handle);
  32001.  
  32002.  
  32003. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32004.  
  32005. Language Level:  Extension 
  32006.  
  32007. _tell gets the current position of the file pointer associated with handle. The 
  32008. position is the number of bytes from the beginning of the file. 
  32009.  
  32010. Return Value 
  32011. _tell returns the current position. A return value of -1L indicates an error, 
  32012. and errno is set to one of the following values: 
  32013.  
  32014.  Value          Meaning 
  32015.  EBADF          The file handle is not valid. 
  32016.  EOS2ERR        The call to the operating system was not successful. 
  32017.  
  32018.  On devices incapable of seeking (such as screens and printers), the return 
  32019.  value is -1L. 
  32020.  
  32021.  
  32022. ΓòÉΓòÉΓòÉ <hidden> Example of _tell ΓòÉΓòÉΓòÉ
  32023.  
  32024. /************************************************************************
  32025.  
  32026. This example opens the file tell.dat. It then calls _tell to get the current 
  32027. position of the file pointer and report whether the operation is successful. 
  32028. The program then closes tell.dat. 
  32029.  
  32030. ************************************************************************/
  32031.  
  32032. #include <io.h>
  32033. #include <stdio.h>
  32034. #include <stdlib.h>
  32035. #include <fcntl.h>
  32036.  
  32037. #define FILENAME  "tell.dat"
  32038.  
  32039. int main(void)
  32040. {
  32041.    long filePtrPos;
  32042.    int fh;
  32043.  
  32044.    printf("Creating file.\n");
  32045.    system("echo Sample Program > " FILENAME);
  32046.    if (-1 == (fh = open(FILENAME, O_RDWR|O_APPEND))) {
  32047.       perror("Unable to open " FILENAME);
  32048.       remove(FILENAME);
  32049.       return EXIT_FAILURE;
  32050.    }
  32051.    /* Get the current file pointer position.                                 */
  32052.    if (-1 == (filePtrPos = _tell(fh))) {
  32053.       perror("Unable to tell");
  32054.       close(fh);
  32055.       remove(FILENAME);
  32056.       return EXIT_FAILURE;
  32057.    }
  32058.    printf("File pointer is at position %d.\n", filePtrPos);
  32059.    close(fh);
  32060.    remove(FILENAME);
  32061.    return 0;
  32062.  
  32063.    /****************************************************************************
  32064.       The output should be:
  32065.  
  32066.       Creating file.
  32067.       File pointer is at position 0.
  32068.    ****************************************************************************/
  32069. }
  32070.  
  32071.  
  32072. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32073.  
  32074. Example of _tell 
  32075.  
  32076.      fseek - Reposition File Position 
  32077.      ftell - Get Current Position 
  32078.      lseek - Move File Pointer 
  32079.      <io.h> 
  32080.  
  32081.  
  32082. ΓòÉΓòÉΓòÉ 4.314. tempnam - Produce Temporary File Name ΓòÉΓòÉΓòÉ
  32083.  
  32084.  
  32085. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32086.  
  32087. #include <stdio.h>
  32088. char *tempnam(char *dir, char *prefix);
  32089.  
  32090.  
  32091. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32092.  
  32093. Language Level:  XGG4, Extension 
  32094.  
  32095. tempnam creates a temporary file name in another directory.  The prefix is the 
  32096. prefix to the file name. tempnam tests for the existence of the file with the 
  32097. given name in the following directories, listed in order of precedence: 
  32098.  
  32099.      If the TMP environment variable is set and the directory specified by TMP 
  32100.       exists, the directory is specified by TMP. 
  32101.  
  32102.      If the TMP environment variable is not set or the directory specified by 
  32103.       TMP does not exist, the directory is specified by the dir argument to 
  32104.       tempnam. 
  32105.  
  32106.      If the dir argument is NULL, or dir is the name of nonexistent directory, 
  32107.       the directory is pointed to by P_tmpdir (defined in <stdio.h>). 
  32108.  
  32109.      If P_tmpdir does not exist, the directory is the current working 
  32110.       directory. 
  32111.  
  32112.  Notes: 
  32113.  
  32114.    1. Because tempnam uses malloc to reserve space for the created file name, 
  32115.       you must free this space when you no longer need it. 
  32116.    2. In earlier releases of C Set ++, tempnam began with an underscore 
  32117.       (_tempnam). Because it is defined by the X/Open standard, the underscore 
  32118.       has been removed. For compatibility, VisualAge C++ will map _tempnam to 
  32119.       tempnam for you. 
  32120.  
  32121.  Return Value 
  32122.  tempnam returns a pointer to the temporary name, if successful. If the name 
  32123.  cannot be created or it already exists, tempnam returns the value NULL. 
  32124.  
  32125.  
  32126. ΓòÉΓòÉΓòÉ <hidden> Example of tempnam ΓòÉΓòÉΓòÉ
  32127.  
  32128. /***************************************************************************
  32129.  
  32130. This example creates a temporary file name using the directory a:\tmp: 
  32131.  
  32132. ************************************************************************/
  32133.  
  32134. #include <stdio.h>
  32135. #include <stdlib.h>
  32136.  
  32137. int main(void)
  32138. {
  32139.    char *name1;
  32140.  
  32141.    if ((name1 = tempnam("d:\\tmp", "stq")) != NULL)
  32142.       printf("%s is safe to use as a temporary file.\n", name1);
  32143.    else {
  32144.       printf("Cannot create unique filename\n");
  32145.       return EXIT_FAILURE;
  32146.    }
  32147.    return 0;
  32148.  
  32149.    /****************************************************************************
  32150.       The output should be similar to:
  32151.  
  32152.       D:\tmp\stqU3CP2.C2T is safe to use as a temporary file.
  32153.    ****************************************************************************/
  32154. }
  32155.  
  32156.  
  32157. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32158.  
  32159. Example of tempnam 
  32160.  
  32161.      malloc - Reserve Storage Block 
  32162.      _rmtmp - Remove Temporary Files 
  32163.      tmpfile - Create Temporary File 
  32164.      tmpnam - Produce Temporary File Name 
  32165.      <stdio.h> 
  32166.  
  32167.  
  32168. ΓòÉΓòÉΓòÉ 4.315. _tfree - Free Tiled Storage Block ΓòÉΓòÉΓòÉ
  32169.  
  32170.  
  32171. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32172.  
  32173. #include <stdlib.h>  /* also in <malloc.h> */
  32174. void _tfree(void *ptr);
  32175.  
  32176.  
  32177. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32178.  
  32179. Language Level:  Extension 
  32180.  
  32181. _tfree frees the tiled memory pointed to by ptr that has been allocated by one 
  32182. of the memory management functions. If ptr is NULL, then no action occurs. 
  32183.  
  32184. _tfree works just like free except that it frees tiled memory instead of 
  32185. regular memory. The _tfree function can only be used to free memory allocated 
  32186. by the tiled memory management functions (_tcalloc and so on). 
  32187.  
  32188. To use _tfree, you must compile with the /Gt compiler option. This option maps 
  32189. all free calls to _tfree (you can also call _tfree explicitly). 
  32190.  
  32191. Note:  The /Gt option maps all calls to regular memory management functions to 
  32192. their tiled versions. To prevent a call from being mapped, parenthesize the 
  32193. function name. 
  32194.  
  32195. A debug version of this function, _debug_tfree is also available. Use the /Tm 
  32196. option to map _tfree calls to _debug_tfree. 
  32197.  
  32198. For more information about memory management, see "Managing Memory" in the 
  32199. Programming Guide. 
  32200.  
  32201. Return Value 
  32202. There is no return value. 
  32203.  
  32204.  
  32205. ΓòÉΓòÉΓòÉ <hidden> Example of _tfree ΓòÉΓòÉΓòÉ
  32206.  
  32207. /************************************************************************
  32208.  
  32209. This example uses _tfree to free a block of tiled memory previously allocated 
  32210. by _tmalloc. 
  32211.  
  32212. Note:  You must compile this example with the /Gt option to enable tiled 
  32213. memory. 
  32214.  
  32215. ************************************************************************/
  32216.  
  32217. #include <stdlib.h>
  32218.  
  32219. int main(void)
  32220. {
  32221.    char *memoryPtr;
  32222.  
  32223.    if (NULL != (memoryPtr = malloc(100)))
  32224.       puts("Successfully allocated 100 bytes of tiled memory.");
  32225.    else
  32226.       puts("Could not allocate tiled memory.");
  32227.    free(memoryPtr);
  32228.    return 0;
  32229.  
  32230.    /****************************************************************************
  32231.       The output should be similar to :
  32232.  
  32233.       Successfully allocated 100 bytes of tiled memory.
  32234.    ****************************************************************************/
  32235. }
  32236.  
  32237.  
  32238. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32239.  
  32240. Example of _tfree 
  32241.  
  32242.      free - Release Storage Blocks 
  32243.      _debug_free - Release Memory 
  32244.      _debug_tfree - Release Tiled Memory 
  32245.      _tcalloc - Reserve Tiled Storage Block 
  32246.      _theapmin - Release Unused Tiled Memory 
  32247.      _tmalloc - Reserve Tiled Storage Block 
  32248.      _trealloc - Reallocate Tiled Storage Block 
  32249.      Differentiating between Memory Management Functions 
  32250.      "Managing Memory" in the Programming Guide 
  32251.      <malloc.h> 
  32252.      <stdlib.h> 
  32253.  
  32254.  
  32255. ΓòÉΓòÉΓòÉ 4.316. _theap_check - Validate User Memory Heap ΓòÉΓòÉΓòÉ
  32256.  
  32257.  
  32258. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32259.  
  32260. #include <stdlib.h>  /* also in <malloc.h> */
  32261. void _theap_check(void);
  32262.  
  32263.  
  32264. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32265.  
  32266. Language Level:  Extension 
  32267.  
  32268. _theap_check checks all tiled memory blocks in the tiled runtime heap that have 
  32269. been allocated or freed using the tiled debug memory management functions 
  32270. (_debug_tcalloc, _debug_tmalloc, and so on). _theap_check checks that your 
  32271. program has not overwritten tiled memory that has been freed or that is outside 
  32272. the bounds of allocated tiled memory blocks. 
  32273.  
  32274. _theap_check works just like _heap_check except that it checks tiled memory 
  32275. instead of regular memory. 
  32276.  
  32277. When you call a tiled debug memory management function (such as 
  32278. _debug_tmalloc), it calls _theap_check automatically. You can also call 
  32279. _theap_check explicitly. Place calls to _theap_check throughout your code, 
  32280. especially in areas that you suspect have memory problems. 
  32281.  
  32282. Calling _theap_check frequently (explicitly or through the tiled debug memory 
  32283. functions) can increase your program's memory requirements and decrease its 
  32284. execution speed.  To reduce the overhead of heap-checking, you can use the 
  32285. DDE4_HEAP_SKIP environment variable to control how often the functions check 
  32286. the heap. For example: 
  32287.  
  32288.   SET DDE4_HEAP_SKIP=10
  32289. specifies that every tenth call to any debug memory function (regardless of the 
  32290. type or heap) checks the heap. Explicit calls to _theap_check are always 
  32291. performed. For more details on DDE4_HEAP_SKIP, see "Skipping Heap Checks" in 
  32292. the Programming Guide. 
  32293.  
  32294. To use _theap_check and the tiled debug versions of the memory management 
  32295. functions, specify the debug memory and tiled memory compiler options (/Tm 
  32296. /Gt). 
  32297.  
  32298. Note:  The /Tm /Gt options map all calls to regular memory management functions 
  32299. to their tiled debug versions. To prevent a call from being mapped, 
  32300. parenthesize the function name. 
  32301.  
  32302. Return Value 
  32303. There is no return value. 
  32304.  
  32305.  
  32306. ΓòÉΓòÉΓòÉ <hidden> Example of _theap_check ΓòÉΓòÉΓòÉ
  32307.  
  32308. /************************************************************************
  32309.  
  32310. This example allocates and frees memory from the tiled runtime heap, and then 
  32311. calls _theap_check to check the heap. 
  32312.  
  32313. Note:  You must compile this example with the /Gt /Tm options to map the memory 
  32314. management functions to their tiled debug versions. 
  32315.  
  32316. ************************************************************************/
  32317.  
  32318. #include <stdlib.h>
  32319. #include <stdio.h>
  32320.  
  32321. int main(void)
  32322. {
  32323.    char *ptr;
  32324.  
  32325.    if (NULL == (ptr = malloc(10))) {
  32326.       puts("Could not allocate memory block.\n");
  32327.       exit(EXIT_FAILURE);
  32328.    }
  32329.    *(ptr - 1) = 'x';      /* overwrites storage that was not allocated */
  32330.  
  32331.    _theap_check();
  32332.  
  32333.    free(ptr);
  32334.    return 0;
  32335.  
  32336.    /****************************************************************************
  32337.       The output should be similar to :
  32338.  
  32339.       Header information of object 0x00080120 was overwritten at 0x0008011c.
  32340.       The first eight bytes of the memory block (in hex) are: AAAAAAAAAAAAAAAA.
  32341.       This memory block was (re)allocated at line number 8 in _theap_chec.c.
  32342.       Heap state was valid at line 8 of _theap_check.c.
  32343.    ****************************************************************************/
  32344. }
  32345.  
  32346.  
  32347. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32348.  
  32349. Example of _theap_check 
  32350.  
  32351.      _heap_check - Validate Default Memory Heap 
  32352.      _debug_tcalloc - Reserve and Initialize Tiled Memory 
  32353.      _debug_tfree - Release Tiled Memory 
  32354.      _debug_theapmin - Release Unused Tiled Memory 
  32355.      _debug_tmalloc - Reserve Tiled Memory 
  32356.      _debug_trealloc - Reallocate Tiled Memory Block 
  32357.      Differentiating between Memory Management Functions 
  32358.      "Managing Memory" in the Programming Guide 
  32359.      "Debugging Your Heaps" in the Programming Guide 
  32360.      <malloc.h> 
  32361.      <stdlib.h> 
  32362.  
  32363.  
  32364. ΓòÉΓòÉΓòÉ 4.317. _theapmin - Release Unused Tiled Memory ΓòÉΓòÉΓòÉ
  32365.  
  32366.  
  32367. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32368.  
  32369. #include <stdlib.h>  /* also in <malloc.h> */
  32370. int _theapmin(void);
  32371.  
  32372.  
  32373. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32374.  
  32375. Language Level:  Extension 
  32376.  
  32377. _theapmin returns all unused tiled memory from the runtime heap to the 
  32378. operating system. _theapmin works just like _heapmin, except that it returns 
  32379. only tiled memory; _heapmin returns only regular memory. 
  32380.  
  32381. You can call _theapmin explicitly, or specify the /Gt compiler option to map 
  32382. all _heapmin calls to _theapmin. 
  32383.  
  32384. Note:  When you specify /Gt, all calls to regular debug memory management 
  32385. functions (calloc and so on) are mapped to their tiled equivalents. However, if 
  32386. you parenthesize the function calls, they are not mapped. 
  32387.  
  32388. A debug version of this function, _debug_theapmin, is also available.  Use the 
  32389. /Tm option to map _theapmin calls to _debug_theapmin.  For more information 
  32390. about memory management, see "Managing Memory" in the Programming Guide. 
  32391.  
  32392. Return Value 
  32393. If successful, _theapmin returns 0; otherwise, it returns -1. 
  32394.  
  32395.  
  32396. ΓòÉΓòÉΓòÉ <hidden> Example of _theapmin ΓòÉΓòÉΓòÉ
  32397.  
  32398. /************************************************************************
  32399.  
  32400. This example allocates and frees memory from the tiled runtime heap, and then 
  32401. uses _theapmin to return any unused memory to the tiled heap. 
  32402.  
  32403. Note:  You must compile this example with the /Gt option to enable tiled 
  32404. memory. 
  32405.  
  32406. ************************************************************************/
  32407.  
  32408. #include <stdlib.h>
  32409. #include <stdio.h>
  32410.  
  32411. int main(void)
  32412. {
  32413.    char *ptr;
  32414.  
  32415.    /* Allocate a large object from the system. */
  32416.    if (NULL == (ptr = malloc(60000))) {
  32417.       puts("Could not allocate memory block.\n");
  32418.       exit(EXIT_FAILURE);
  32419.    }
  32420.    memset(ptr, 'x', 60000);
  32421.  
  32422.    /* The free will keep large object in runtime. */
  32423.    free(ptr);
  32424.  
  32425.    /* _theapmin will attempt to return the freed object to the system. */
  32426.    if (0 != _theapmin()) {
  32427.       puts("_debug_theapmin returns failed.\n");
  32428.       exit(EXIT_FAILURE);
  32429.    }
  32430.    return 0;
  32431. }
  32432.  
  32433.  
  32434. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32435.  
  32436. Example of _theapmin 
  32437.  
  32438.      _debug_heapmin - Release Unused Memory in the Default Heap 
  32439.      _debug_theapmin - Release Unused Tiled Memory 
  32440.      _heapmin - Release Unused Memory from Default Heap 
  32441.      _tcalloc - Reserve Tiled Storage Block 
  32442.      _tfree - Free Tiled Storage Block 
  32443.      _tmalloc - Reserve Tiled Storage Block 
  32444.      _trealloc - Reallocate Tiled Storage Block 
  32445.      _uheapmin - Release Unused Memory in User Heap 
  32446.      Differentiating between Memory Management Functions 
  32447.      Memory Management in the Programming Guide 
  32448.      <malloc.h> 
  32449.      <stdlib.h> 
  32450.  
  32451.  
  32452. ΓòÉΓòÉΓòÉ 4.318. _threadstore - Access Thread-Specific Storage ΓòÉΓòÉΓòÉ
  32453.  
  32454.  
  32455. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32456.  
  32457. #include <stdlib.h>
  32458. void *_threadstore(void);
  32459.  
  32460.  
  32461. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32462.  
  32463. Language Level:  Extension 
  32464.  
  32465. _threadstore provides access to a private thread pointer that is initialized to 
  32466. NULL. You can assign any thread-specific data structure to this pointer. 
  32467.  
  32468. You can only use _threadstore in multithread programs (compiled with the /Gm+ 
  32469. option). 
  32470.  
  32471. Return Value 
  32472.  
  32473. _threadstore returns the address of the pointer to the defined thread storage 
  32474. space. 
  32475.  
  32476.  
  32477. ΓòÉΓòÉΓòÉ <hidden> Example of _threadstore ΓòÉΓòÉΓòÉ
  32478.  
  32479. /************************************************************************
  32480.  
  32481. This example uses _threadstore to point to storage that is local to the thread. 
  32482. It prints the address pointed to by _threadstore. 
  32483.  
  32484. Note:  You must compile this example with the multithread option (/Gm+). 
  32485.  
  32486. ************************************************************************/
  32487.  
  32488. #include <stdlib.h>
  32489. #include <stdio.h>
  32490.  
  32491. #define  privateStore   (*_threadstore())
  32492.  
  32493. void thread(void *dummy)
  32494. {
  32495.    privateStore = malloc(100);
  32496.    printf("The starting address of the storaged space is %p\n", privateStore);
  32497.  
  32498.    /* user must free storage before exiting thread */
  32499.    free (privateStore);
  32500.    _endthread();
  32501. }
  32502.  
  32503. int main(void)
  32504. {
  32505.    int i;
  32506.  
  32507.    for (i = 0; i < 10; i++)
  32508.       _beginthread(thread, NULL, (unsigned) 32096, NULL);
  32509.    DosSleep(5000L);
  32510.    return 0;
  32511. }
  32512.  
  32513.  
  32514. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32515.  
  32516. Example of _threadstore 
  32517.  
  32518.      _beginthread - Create New Thread 
  32519.      _endthread - Terminate Current Thread 
  32520.      <stdlib.h> 
  32521.  
  32522.  
  32523. ΓòÉΓòÉΓòÉ 4.319. time - Determine Current Time ΓòÉΓòÉΓòÉ
  32524.  
  32525.  
  32526. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32527.  
  32528. #include <time.h>
  32529. time_t time(time_t *timeptr);
  32530.  
  32531.  
  32532. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32533.  
  32534. Language Level: ANSI, SAA, POSIX, XPG4 
  32535.  
  32536. time determines the current calendar time, which is not necessarily the local 
  32537. time localtime. 
  32538.  
  32539. Note:  The time and date functions begin at 00:00 Universal Time, January 1, 
  32540. 1970. 
  32541.  
  32542. Return Value 
  32543. time returns the current calendar time. The return value is also stored in the 
  32544. location given by timeptr. If timeptr is NULL, the return value is not stored. 
  32545. If the calendar time is not available, the value (time_t)(-1) is returned. 
  32546.  
  32547.  
  32548. ΓòÉΓòÉΓòÉ <hidden> Example of time ΓòÉΓòÉΓòÉ
  32549.  
  32550. /************************************************************************
  32551.  
  32552. This example gets the time and assigns it to ltime. ctime then converts the 
  32553. number of seconds to the current date and time. This example then prints a 
  32554. message giving the current time. 
  32555.  
  32556. ************************************************************************/
  32557.  
  32558. #include <time.h>
  32559. #include <stdio.h>
  32560.  
  32561. int main(void)
  32562. {
  32563.    time_t ltime;
  32564.  
  32565.    time(<ime);
  32566.    printf("The time is %s\n", ctime(<ime));
  32567.    return 0;
  32568.  
  32569.    /****************************************************************************
  32570.       The output should be similar to:
  32571.  
  32572.       The time is Thu Jan 12 11:38:37 1995
  32573.    ****************************************************************************/
  32574. }
  32575.  
  32576.  
  32577. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32578.  
  32579. Example of time 
  32580.  
  32581.      asctime - Convert Time to Character String 
  32582.      ctime - Convert Time to Character String 
  32583.      gmtime - Convert Time 
  32584.      localtime - Convert Time 
  32585.      mktime - Convert Local Time 
  32586.      _strtime - Copy Time 
  32587.      <time.h> 
  32588.  
  32589.  
  32590. ΓòÉΓòÉΓòÉ 4.320. _tmalloc - Reserve Tiled Storage Block ΓòÉΓòÉΓòÉ
  32591.  
  32592.  
  32593. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32594.  
  32595. #include <stdlib.h>  /* also in <malloc.h> */
  32596. void _tmalloc(size_t size);
  32597.  
  32598.  
  32599. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32600.  
  32601. Language Level:  Extension 
  32602.  
  32603. _tmalloc allocates tiled memory for an object of size size, the value of which 
  32604. is indeterminate. 
  32605.  
  32606. To use _tmalloc, you must compile with the /Gt compiler option. This option 
  32607. maps all malloc calls to _tmalloc (you can also call _tmalloc explicitly). 
  32608.  
  32609. Note:  The /Gt option maps all calls to regular memory management functions to 
  32610. their tiled versions. To prevent a call from being mapped, parenthesize the 
  32611. function name. 
  32612.  
  32613. _tmalloc works just like malloc except that it allocates tiled memory instead 
  32614. of regular memory. Tiled memory will not cross 64K boundaries, as long as the 
  32615. object is less than 64K in size. Objects larger than 64K in size are aligned on 
  32616. 64K boundaries, but will also cross 64K boundaries. If you have objects that 
  32617. may be accessed by 16-bit code, you should store them in tiled memory. 
  32618.  
  32619. Tiled memory from the VisualAge C++ runtime heap is limited to 512 MB per 
  32620. process. You can also create your own heaps of tiled memory, which can be 
  32621. larger in size.  See Memory Management in the Programming Guide for more 
  32622. information. 
  32623.  
  32624. Memory allocated by _tmalloc can only be freed using _tfree. 
  32625.  
  32626. A debug version of this function, _debug_tmalloc, is also available. Use the 
  32627. /Tm option to map all _tmalloc calls to _debug_tmalloc. 
  32628.  
  32629. Return Value 
  32630. _tmalloc returns a pointer to the allocated tiled memory. If not enough storage 
  32631. is available, or if size is 0, _tmalloc returns NULL. 
  32632.  
  32633.  
  32634. ΓòÉΓòÉΓòÉ <hidden> Example of _tmalloc ΓòÉΓòÉΓòÉ
  32635.  
  32636. /************************************************************************
  32637.  
  32638. This example uses _tmalloc to allocate 100 bytes of tiled memory. 
  32639.  
  32640. Note:  You must compile this example with the /Gt option to enable tiled 
  32641. memory. 
  32642.  
  32643. ************************************************************************/
  32644.  
  32645. #include <stdlib.h>
  32646.  
  32647. int main(void)
  32648. {
  32649.    char *memoryPtr;
  32650.  
  32651.    if (NULL != (memoryPtr = malloc(100)))
  32652.       puts("Successfully allocated 100 bytes of tiled memory.");
  32653.    else
  32654.       puts("Could not allocate tiled memory.");
  32655.    free(memoryPtr);
  32656.    return 0;
  32657.  
  32658.    /****************************************************************************
  32659.       The output should be similar to:
  32660.  
  32661.       Successfully allocated 100 bytes of tiled memory.
  32662.    ****************************************************************************/
  32663. }
  32664.  
  32665.  
  32666. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32667.  
  32668. Example of _tmalloc 
  32669.  
  32670.      _debug_malloc - Allocate Memory 
  32671.      _debug_tmalloc - Reserve Tiled Memory 
  32672.      malloc - Reserve Storage Block 
  32673.      _tcalloc - Reserve Tiled Storage Block 
  32674.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  32675.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  32676.      _tfree - Free Tiled Storage Block 
  32677.      _trealloc - Reallocate Tiled Storage Block 
  32678.      _umalloc - Reserve Memory Blocks from User Heap 
  32679.      Differentiating between Memory Management Functions 
  32680.      "Managing Memory in the Programming Guide 
  32681.      <malloc.h> 
  32682.      <stdlib.h> 
  32683.  
  32684.  
  32685. ΓòÉΓòÉΓòÉ 4.321. _tmem_init - Initialize Memory Functions for Subsystem DLL ΓòÉΓòÉΓòÉ
  32686.  
  32687.  
  32688. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32689.  
  32690. int _tmem_init(void);
  32691. /* no header file - defined in runtime startup code */
  32692.  
  32693.  
  32694. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32695.  
  32696. Language Level:  Extension 
  32697.  
  32698. _tmem_init initializes the tiled memory functions for subsystem DLLs. (If your 
  32699. subsystem DLL does not use tiled memory, call _rmem_init instead of 
  32700. _tmem_init.) Although subsystems do not require a runtime environment (and 
  32701. therefore do not call _CRT_init), they do require the library memory functions. 
  32702. For DLLs that do use a runtime environment, the memory functions are 
  32703. initialized with the environment by _CRT_init. 
  32704.  
  32705. By default, all DLLs call the VisualAge C++ _DLL_InitTerm function, which in 
  32706. turn initializes the tiled memory functions for you. However, if you are 
  32707. writing your own subsystem _DLL_InitTerm function (for example, to perform 
  32708. actions other than memory initialization and termination), you must call 
  32709. _tmem_init from your version of _DLL_InitTerm before you can call any other 
  32710. library functions. 
  32711.  
  32712. If your DLL contains C++ code, you must also call __ctordtorInit after 
  32713. _tmem_init to ensure that static constructors and destructors are initialized 
  32714. properly.  __ctordtorInit is defined in the runtime startup code as: 
  32715.  
  32716.    void __ctordtorInit(void);
  32717.  
  32718. Return Value 
  32719. If the memory functions were successfully initialized, _tmem_init returns 0. A 
  32720. return code of -1 indicates an error. If an error occurs, an error message is 
  32721. written to file handle 2, which is the usual destination of stderr. 
  32722.  
  32723.  
  32724. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32725.  
  32726.      Building Subsystem DLLs in the Programming Guide 
  32727.      _CRT_init - Initialize DLL Runtime Environment 
  32728.      _CRT_term - Terminate DLL Runtime Environment 
  32729.      _DLL_InitTerm - Initialize and Terminate DLL Environment 
  32730.      _rmem_init - Initialize Memory Functions for Subsystem DLL 
  32731.      _rmem_term - Terminate Memory Functions for Subsystem DLL 
  32732.      _tmem_term - Terminate Memory Functions for Subsystem DLL 
  32733.  
  32734.  
  32735. ΓòÉΓòÉΓòÉ 4.322. _tmem_term - Terminate Memory Functions for Subsystem DLL ΓòÉΓòÉΓòÉ
  32736.  
  32737.  
  32738. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32739.  
  32740. int _tmem_term(void);
  32741. /* no header file - defined in runtime startup code */
  32742.  
  32743.  
  32744. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32745.  
  32746. Language Level:  Extension 
  32747.  
  32748. _tmem_term terminates the tiled memory functions for subsystem DLLs.  It is 
  32749. only needed for DLLs that used tiled memory and that statically link to the 
  32750. runtime library. 
  32751.  
  32752. By default, all DLLs call the VisualAge C++ _DLL_InitTerm function, which in 
  32753. turn calls the termination functions for you. However, if you are writing your 
  32754. own _DLL_InitTerm function (for example, to perform actions other than memory 
  32755. initialization and termination), and your DLL statically links to the C runtime 
  32756. libraries, you need to call _rmem_term from your subsystem _DLL_InitTerm 
  32757. function. (For DLLs with a runtime environment, this termination is done by 
  32758. _CRT_term. If your subsystem DLL does not use tiled memory, call _rmem_term 
  32759. instead of _tmem_term.) 
  32760.  
  32761. If your DLL contains C++ code, you must also call __ctordtorTerm before you 
  32762. call _tmem_term to ensure that static constructors and destructors are 
  32763. terminated correctly. __ctordtorTerm is defined in the runtime startup code as: 
  32764.  
  32765.    void __ctordtorTerm(void);
  32766.  
  32767. Once you have called _tmem_term, you cannot call any other library functions. 
  32768.  
  32769. If your DLL is dynamically linked, you cannot call library functions in the 
  32770. termination section of your _DLL_InitTerm function. If your termination routine 
  32771. requires calling library functions, you must register the termination routine 
  32772. with DosExitList. Note that all DosExitList routines are called before DLL 
  32773. termination routines. 
  32774.  
  32775. Return Value 
  32776. _tmem_term returns 0 if the memory functions were successfully terminated. A 
  32777. return value of -1 indicates an error. 
  32778.  
  32779.  
  32780. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32781.  
  32782.      Building Subsystem DLLs in the Programming Guide 
  32783.      _CRT_init - Initialize DLL Runtime Environment 
  32784.      _CRT_term - Terminate DLL Runtime Environment 
  32785.      _DLL_InitTerm - Initialize and Terminate DLL Environment 
  32786.      _rmem_init - Initialize Memory Functions for Subsystem DLL 
  32787.      _rmem_term - Terminate Memory Functions for Subsystem DLL 
  32788.      _tmem_init - Initialize Memory Functions for Subsystem DLL 
  32789.  
  32790.  
  32791. ΓòÉΓòÉΓòÉ 4.323. tmpfile - Create Temporary File ΓòÉΓòÉΓòÉ
  32792.  
  32793.  
  32794. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32795.  
  32796. #include <stdio.h>
  32797. FILE *tmpfile(void);
  32798.  
  32799.  
  32800. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32801.  
  32802. Language Level: ANSI, SAA, POSIX, XPG4 
  32803.  
  32804. tmpfile creates a temporary binary file.  The file is automatically removed 
  32805. when it is closed or when the program is terminated. 
  32806.  
  32807. tmpfile opens the temporary file in wb+ mode. 
  32808.  
  32809. Return Value 
  32810.  
  32811. tmpfile returns a stream pointer, if successful. If it cannot open the file, it 
  32812. returns a NULL pointer. On normal termination (exit), these temporary files are 
  32813. removed. 
  32814.  
  32815.  
  32816. ΓòÉΓòÉΓòÉ <hidden> Example of tmpfile ΓòÉΓòÉΓòÉ
  32817.  
  32818. /************************************************************************
  32819.  
  32820. This example creates a temporary file, and if successful, writes tmpstring to 
  32821. it. At program termination, the file is removed. 
  32822.  
  32823. ************************************************************************/
  32824.  
  32825. #include <stdio.h>
  32826. #include <stdlib.h>
  32827.  
  32828. FILE *stream;
  32829. char tmpstring[] = "This is the string to be temporarily written";
  32830.  
  32831. int main(void)
  32832. {
  32833.    if (NULL == (stream = tmpfile())) {
  32834.       perror("Cannot make a temporary file");
  32835.       return EXIT_FAILURE;
  32836.    }
  32837.    else
  32838.       fprintf(stream, "%s", tmpstring);
  32839.    return 0;
  32840. }
  32841.  
  32842.  
  32843. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32844.  
  32845. Example of tmpfile 
  32846.  
  32847.      fopen - Open Files 
  32848.      tmpnam - Produce Temporary File Name 
  32849.      tempnam - Produce Temporary File Name 
  32850.      _rmtmp - Remove Temporary Files 
  32851.      <stdio.h> 
  32852.  
  32853.  
  32854. ΓòÉΓòÉΓòÉ 4.324. tmpnam - Produce Temporary File Name ΓòÉΓòÉΓòÉ
  32855.  
  32856.  
  32857. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32858.  
  32859. #include <stdio.h>
  32860. char *tmpnam(char *string);
  32861.  
  32862.  
  32863. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32864.  
  32865. Language Level: ANSI, SAA, POSIX, XPG4 
  32866.  
  32867. tmpnam produces a valid file name that is not the same as the name of any 
  32868. existing file. It stores this name in string. If string is NULL, tmpnam leaves 
  32869. the result in an internal static buffer.  Any subsequent calls destroy this 
  32870. value.  If string is not NULL, it must point to an array of at least L_tmpnam 
  32871. bytes.  The value of L_tmpnam is defined in <stdio.h>. 
  32872.  
  32873. tmpnam produces a different name each time it is called within a module up to 
  32874. at least TMP_MAX (a value of at least 25) names.  Note that files created using 
  32875. names returned by tmpnam are not automatically discarded at the end of the 
  32876. program. Files can be removed by the remove function. 
  32877.  
  32878. Return Value 
  32879. tmpnam returns a pointer to the name. If it cannot create a unique name; it 
  32880. returns NULL. 
  32881.  
  32882.  
  32883. ΓòÉΓòÉΓòÉ <hidden> Example of tmpnam ΓòÉΓòÉΓòÉ
  32884.  
  32885. /************************************************************************
  32886.  
  32887. This example calls tmpnam to produce a valid file name. 
  32888.  
  32889. ************************************************************************/
  32890.  
  32891. #include <stdio.h>
  32892.  
  32893. int main(void)
  32894. {
  32895.    char *name1;
  32896.  
  32897.    if ((name1 = tmpnam(NULL)) != NULL)
  32898.       printf("%s can be used as a file name.\n", name1);
  32899.    else
  32900.       printf("Cannot create a unique file name\n");
  32901.  
  32902.    return 0;
  32903.  
  32904.    /****************************************************************************
  32905.       The output should be similar to:
  32906.  
  32907.       d:\tmp\acc00000.CTN can be used as a file name.
  32908.  
  32909.    ****************************************************************************/
  32910. }
  32911.  
  32912.  
  32913. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  32914.  
  32915. Example of tmpnam 
  32916.  
  32917.      fopen - Open Files 
  32918.      remove - Delete File 
  32919.      tempnam - Produce Temporary File Name 
  32920.      <stdio.h> 
  32921.  
  32922.  
  32923. ΓòÉΓòÉΓòÉ 4.325. _toascii - _tolower - _toupper - Convert Character ΓòÉΓòÉΓòÉ
  32924.  
  32925.  
  32926. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  32927.  
  32928. #include <ctype.h>
  32929. int _toascii(int c);
  32930. int _tolower(int c);
  32931. int _toupper(int c);
  32932.  
  32933.  
  32934. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  32935.  
  32936. Language Level:  Extension 
  32937.  
  32938. _toascii converts c to a character in the ASCII character set, by setting all 
  32939. but the low-order 7 bits to 0. If c already represents an ASCII character, 
  32940. _toascii does not change it. 
  32941.  
  32942. _tolower converts c to the corresponding lowercase letter, if possible. 
  32943.  
  32944. _toupper converts c to the corresponding uppercase letter, if possible. 
  32945.  
  32946. Important  Use _tolower and _toupper only when you know that c is uppercase A 
  32947. to Z or lowercase a to z, respectively. Otherwise the results are undefined. 
  32948. These functions are not affected by the current locale. 
  32949.  
  32950. These are all macros, and do not correctly handle arguments with side effects. 
  32951.  
  32952. For portability, use the tolower and toupper functions defined by the ANSI/ISO 
  32953. standard, instead of the _tolower and _toupper macros. 
  32954.  
  32955. Return Value 
  32956. _toascii, _tolower, and _toupper return the possibly converted character c. If 
  32957. the character passed to _toascii is an ASCII character, _toascii returns the 
  32958. character unchanged. There is no error return. 
  32959.  
  32960.  
  32961. ΓòÉΓòÉΓòÉ <hidden> Example of _toascii - _tolower - _toupper ΓòÉΓòÉΓòÉ
  32962.  
  32963. /************************************************************************
  32964.  
  32965. This example prints four sets of characters.  The first set is the ASCII 
  32966. characters having graphic images, which range from 0x21 through 0x7e. The 
  32967. second set takes integers 0x7f21 through 0x7f7e and applies the _toascii macro 
  32968. to them, yielding the same set of printable characters. The third set is the 
  32969. characters with all lowercase letters converted to uppercase.  The fourth set 
  32970. is the characters with all uppercase letters converted to lowercase. 
  32971.  
  32972. ************************************************************************/
  32973.  
  32974. #include <stdio.h>
  32975. #include <ctype.h>
  32976.  
  32977. int main(void)
  32978. {
  32979.    int ch;
  32980.  
  32981.    printf("Characters 0x01 to 0x03, and integers 0x7f01 to 0x7f03 mapped to\n");
  32982.    printf("ASCII by _toascii() both yield the same graphic characters.\n\n");
  32983.    for (ch = 0x01; ch <= 0x03; ch++) {
  32984.       printf("char 0x%.4X: %c    ", ch, ch);
  32985.       printf("char _toascii(0x%.4X): %c\n", ch+0x7f00, ch+0x7f00);
  32986.    }
  32987.    printf("\nCharacters A, B and C converted to lower case and\n");
  32988.    printf("Characters a, b and c converted to upper case.\n\n");
  32989.    for (ch = 0x41; ch <= 0x43; ch++) {
  32990.       printf("_tolower(%c) = %c   ", ch, _tolower(ch));
  32991.       printf("_toupper(%c) = %c\n", ch+0x20, _toupper(ch+0x20));
  32992.    }
  32993.    return 0;
  32994.  
  32995.    /****************************************************************************
  32996.       The output should be:
  32997.  
  32998.       Characters 0x01 to 0x03, and integers 0x7f01 to 0x7f03 mapped to
  32999.       ASCII by _toascii() both yield the same graphic characters.
  33000.  
  33001.       char 0x0001:     char _toascii(0x7F01): 
  33002.       char 0x0002:     char _toascii(0x7F02): 
  33003.       char 0x0003:     char _toascii(0x7F03): 
  33004.  
  33005.       Characters A, B and C converted to lower case and
  33006.       Characters a, b and c converted to upper case.
  33007.  
  33008.       _tolower(A) = a   _toupper(a) = A
  33009.       _tolower(B) = b   _toupper(b) = B
  33010.       _tolower(C) = c   _toupper(c) = C
  33011.    ****************************************************************************/
  33012. }
  33013.  
  33014.  
  33015. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33016.  
  33017. Example of _toascii - _tolower - _toupper 
  33018.  
  33019.      isalnum to isxdigit - Test Integer Value 
  33020.      isascii - Test Integer Values 
  33021.      _iscsym - _iscsymf - Test Integer 
  33022.      tolower() - toupper() - Convert Character Case 
  33023.      towlower - towupper - Convert Wide Character Case 
  33024.      <ctype.h> 
  33025.  
  33026.  
  33027. ΓòÉΓòÉΓòÉ 4.326. tolower() - toupper() - Convert Character Case ΓòÉΓòÉΓòÉ
  33028.  
  33029.  
  33030. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33031.  
  33032. #include <ctype.h>
  33033. int tolower(int C);
  33034. int toupper(int c);
  33035.  
  33036.  
  33037. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33038.  
  33039. Language Level: ANSI, SAA, POSIX, XPG4 
  33040.  
  33041. tolower converts the uppercase letter C to the corresponding lowercase letter. 
  33042.  
  33043. toupper converts the lowercase letter c to the corresponding uppercase letter. 
  33044.  
  33045. The character mapping is determined by the LC_CTYPE category of the current 
  33046. locale. 
  33047.  
  33048. Return Value 
  33049. Both functions return the converted character. If the character c does not have 
  33050. a corresponding lowercase of uppercase character, the functions return c 
  33051. unchanged. 
  33052.  
  33053.  
  33054. ΓòÉΓòÉΓòÉ <hidden> Example of tolower - toupper ΓòÉΓòÉΓòÉ
  33055.  
  33056. /************************************************************************
  33057.  
  33058. This example uses toupper and tolower to modify characters between code 0 and 
  33059. code 7f. 
  33060.  
  33061. ************************************************************************/
  33062.  
  33063. #include <stdio.h>
  33064. #include <ctype.h>
  33065.  
  33066. int main(void)
  33067. {
  33068.    int ch;
  33069.  
  33070.    /* print hex values of characters */
  33071.    for (ch = 0; ch <= 0x7f; ch++) {
  33072.       printf("toupper=%#04x\n", toupper(ch));
  33073.       printf("tolower=%#04x\n", tolower(ch));
  33074.       putchar('\n');
  33075.    }
  33076.    return 0;
  33077. }
  33078.  
  33079.  
  33080. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33081.  
  33082. Example of tolower - toupper 
  33083.  
  33084.      isalnum to isxdigit - Test Integer Value 
  33085.      isascii - Test Integer Values 
  33086.      _iscsym - _iscsymf - Test Integer 
  33087.      _toascii - _tolower - _toupper - Convert Character 
  33088.      towlower - towupper - Convert Wide Character Case 
  33089.      <ctype.h> 
  33090.  
  33091.  
  33092. ΓòÉΓòÉΓòÉ 4.327. towlower - towupper - Convert Wide Character Case ΓòÉΓòÉΓòÉ
  33093.  
  33094.  
  33095. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33096.  
  33097. #include <wctype.h>
  33098. wint_t towlower(wint_t wc);
  33099. wint_t towupper(wint_t wc);
  33100.  
  33101.  
  33102. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33103.  
  33104. Language Level:  ANSI 93, POSIX 
  33105.  
  33106. towlower converts the uppercase letter wc to the corresponding lowercase 
  33107. letter. 
  33108.  
  33109. towupper converts the lowercase letter wc to the corresponding uppercase 
  33110. letter. 
  33111.  
  33112. The character mapping is determined by the LC_CTYPE category of current locale. 
  33113.  
  33114. Return Value 
  33115. Both functions return the converted character. If the wide character wc does 
  33116. not have a corresponding lowercase or uppercase character, the functions return 
  33117. wc unchanged. 
  33118.  
  33119.  
  33120. ΓòÉΓòÉΓòÉ <hidden> Example of towlower and towupper ΓòÉΓòÉΓòÉ
  33121.  
  33122. /************************************************************************
  33123.  
  33124. This example uses towlower and towupper to convert characters between 0 and 
  33125. 0x7f. 
  33126.  
  33127. ************************************************************************/
  33128.  
  33129. #include <wchar.h>
  33130. #include <stdio.h>
  33131.  
  33132. int main(void)
  33133. {
  33134.    wint_t w_ch;
  33135.  
  33136.    for (w_ch = 0; w_ch <= 0x7f; w_ch++) {
  33137.       printf ("towupper : %#04x %#04x, ", w_ch, towupper(w_ch));
  33138.       printf ("towlower : %#04x %#04x\n", w_ch, towlower(w_ch));
  33139.    }
  33140.    return 0;
  33141.  
  33142.    /****************************************************************************
  33143.       The output should be similar to :
  33144.       .
  33145.       :
  33146.       towupper : 0x41 0x41, towlower : 0x41 0x61
  33147.       towupper : 0x42 0x42, towlower : 0x42 0x62
  33148.       towupper : 0x43 0x43, towlower : 0x43 0x63
  33149.       towupper : 0x44 0x44, towlower : 0x44 0x64
  33150.       towupper : 0x45 0x45, towlower : 0x45 0x65
  33151.       .
  33152.       :
  33153.       towupper : 0x61 0x41, towlower : 0x61 0x61
  33154.       towupper : 0x62 0x42, towlower : 0x62 0x62
  33155.       towupper : 0x63 0x43, towlower : 0x63 0x63
  33156.       towupper : 0x64 0x44, towlower : 0x64 0x64
  33157.       towupper : 0x65 0x45, towlower : 0x65 0x65
  33158.       :
  33159.    ****************************************************************************/
  33160. }
  33161.  
  33162.  
  33163. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33164.  
  33165. Example of towlower - towupper 
  33166.  
  33167.      <wctype.h> 
  33168.      tolower() - toupper() - Convert Character Case 
  33169.      _toascii - _tolower - _toupper - Convert Character 
  33170.  
  33171.  
  33172. ΓòÉΓòÉΓòÉ 4.328. _trealloc - Reallocate Tiled Storage Block ΓòÉΓòÉΓòÉ
  33173.  
  33174.  
  33175. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33176.  
  33177. #include <stdlib.h>  /* also in <malloc.h> */
  33178. void _trealloc(void *ptr, size_t size);
  33179.  
  33180.  
  33181. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33182.  
  33183. Language Level:  Extension 
  33184.  
  33185. _trealloc changes the size of the tiled memory pointed to ptr to the specified 
  33186. size, in bytes. The contents of the tiled memory are unchanged up to the 
  33187. smaller of the new and old sizes. Any new tiled memory that is allocated is 
  33188. uninitialized. 
  33189.  
  33190. To use _trealloc, you must compile with the /Gt compiler option. This option 
  33191. maps all realloc calls to _trealloc (you can also call _trealloc explicitly). 
  33192.  
  33193. Note:  The /Gt option maps all calls to regular memory management functions to 
  33194. their tiled versions. To prevent a call from being mapped, parenthesize the 
  33195. function name. 
  33196.  
  33197. _trealloc works just like realloc except that it reallocates tiled memory 
  33198. instead of regular memory. Tiled memory will not to cross 64K boundaries, as 
  33199. long as the object is less than 64K in size. Objects larger than 64K in size 
  33200. are aligned on 64K boundaries, but will also cross 64K boundaries. If you have 
  33201. objects that may be accessed by 16-bit code, you should store them in tiled 
  33202. memory. 
  33203.  
  33204. Tiled memory from the VisualAge C++ runtime heap is limited to 512 MB per 
  33205. process. You can also create your own heaps of tiled memory, which can be 
  33206. larger in size.  See Memory Management in the Programming Guide for more 
  33207. information. 
  33208.  
  33209. _trealloc can only reallocate memory allocated by the _tmalloc, _tcalloc, or 
  33210. _trealloc functions. If the memory was not allocated by one of these functions 
  33211. or was previously freed, a message appears and the program ends. 
  33212.  
  33213. A debug version of this function, _debug_trealloc, is also available.  Use the 
  33214. /Tm compiler option to map all _trealloc calls to _debug_trealloc. 
  33215.  
  33216. Return Value 
  33217. _trealloc returns a pointer to the reallocated tiled memory. If not enough 
  33218. storage is available or if size is 0, _trealloc returns NULL and the original 
  33219. block does not change. 
  33220.  
  33221.  
  33222. ΓòÉΓòÉΓòÉ <hidden> Example of _trealloc ΓòÉΓòÉΓòÉ
  33223.  
  33224. /************************************************************************
  33225.  
  33226. This example uses _trealloc to reallocate a block of tiled memory previously 
  33227. allocated by _tmalloc. 
  33228.  
  33229. Note:  You must compile this example with the /Gt option to enable tiled 
  33230. memory. 
  33231.  
  33232. ************************************************************************/
  33233.  
  33234. #include <stdlib.h>
  33235.  
  33236. int main(void)
  33237. {
  33238.    char *memoryPtr;
  33239.  
  33240.    if (NULL == (memoryPtr = malloc(100))) {
  33241.       puts("Could not allocate tiled memory.");
  33242.       exit(EXIT_FAILURE);
  33243.    }
  33244.    if (NULL == (memoryPtr = realloc(memoryPtr, 1000))) {
  33245.       puts("Unable to reallocate tiled memory.");
  33246.       exit(EXIT_FAILURE);
  33247.    }
  33248.    else
  33249.        puts("Successfully reallocated 1000 bytes of tiled memory.");
  33250.    free(memoryPtr);
  33251.    return 0;
  33252.  
  33253.    /****************************************************************************
  33254.       The output should be similar to:
  33255.  
  33256.       Successfully reallocated 1000 bytes of tiled memory.
  33257.    ****************************************************************************/
  33258. }
  33259.  
  33260.  
  33261. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33262.  
  33263. Example of _trealloc 
  33264.  
  33265.      _debug_calloc - Allocate and Initialize Memory 
  33266.      _debug_trealloc - Reallocate Tiled Memory Block 
  33267.      _msize - Return Number of Bytes Allocated 
  33268.      realloc - Change Reserved Storage Block Size 
  33269.      _tcalloc - Reserve Tiled Storage Block 
  33270.      _tmalloc - Reserve Tiled Storage Block 
  33271.      _tfree - Free Tiled Storage Block 
  33272.      Differentiating between Memory Management Functions 
  33273.      "Managing Memory" in the Programming Guide 
  33274.      <malloc.h> 
  33275.      <stdlib.h> 
  33276.  
  33277.  
  33278. ΓòÉΓòÉΓòÉ 4.329. tzset - Assign Values to Locale Information ΓòÉΓòÉΓòÉ
  33279.  
  33280.  
  33281. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33282.  
  33283. #include <time.h>
  33284. void tzset(void);
  33285.  
  33286.  
  33287. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33288.  
  33289. Language Level:  XPG4, Extension 
  33290.  
  33291. tzset uses the environment variable TZ to change the time zone and daylight 
  33292. saving time (DST) zone values of your current locale. These values are used by 
  33293. the gmtime and localtime functions to make corrections from Coordinated 
  33294. Universal Time (formerly GMT) to local time. 
  33295.  
  33296. To use tzset, set the TZ variable to the appropriate values. (For the possible 
  33297. values for TZ, see the chapter on runtime environment variables in the 
  33298. Programming Guide.) Then call tzset to incorporate the changes in the time zone 
  33299. information into your current locale. 
  33300.  
  33301. To set TZ from within a program, use putenv before calling tzset. 
  33302.  
  33303. Notes: 
  33304.  
  33305.      In earlier releases of C Set ++, tzset began with an underscore (_tzset). 
  33306.       Because it is defined by the X/Open standard, the underscore has been 
  33307.       removed. For compatibility, VisualAge C++ will map _tzset to tzset for 
  33308.       you. 
  33309.      The time and date functions begin at 00:00 Coordinated Universal Time, 
  33310.       January 1, 1970. 
  33311.  
  33312.  Return Value 
  33313.  There is no return value. 
  33314.  
  33315.  
  33316. ΓòÉΓòÉΓòÉ <hidden> Example of tzset ΓòÉΓòÉΓòÉ
  33317.  
  33318. /************************************************************************
  33319.  
  33320. This example uses putenv and tzset to set the time zone to Central Time. 
  33321.  
  33322. ************************************************************************/
  33323.  
  33324. #include <time.h>
  33325. #include <stdio.h>
  33326. #include <stdlib.h>
  33327.  
  33328. int main(void)
  33329. {
  33330.    time_t currentTime;
  33331.    struct tm *ts;
  33332.  
  33333.    /* Get the current time                                                    */
  33334.  
  33335.    (void)time(¤tTime);
  33336.    printf("The GMT time is %s", asctime(gmtime(¤tTime)));
  33337.    ts = localtime(¤tTime);
  33338.    if (ts->tm_isdst > 0)  /* check if Daylight Saving Time is in effect       */
  33339.       {
  33340.       printf("The local time is %s", asctime(ts));
  33341.       printf("Daylight Saving Time is in effect.\n");
  33342.    }
  33343.    else {
  33344.       printf("The local time is %s", asctime(ts));
  33345.       printf("Daylight Saving Time is not in effect.\n");
  33346.    }
  33347.    printf("**** Changing to Central Time ****\n");
  33348.    putenv("TZ=CST6CDT");
  33349.    tzset();
  33350.    ts = localtime(¤tTime);
  33351.    if (ts->tm_isdst > 0)  /* check if Daylight Saving Time is in effect       */
  33352.       {
  33353.       printf("The local time is %s", asctime(ts));
  33354.       printf("Daylight Saving Time is in effect.\n");
  33355.    }
  33356.    else {
  33357.       printf("The local time is %s", asctime(ts));
  33358.       printf("Daylight Saving Time is not in effect.\n");
  33359.    }
  33360.  
  33361.    return 0;
  33362.  
  33363.    /****************************************************************************
  33364.       The output should be similar to:
  33365.  
  33366.       The GMT time is Fri Jan 13 21:49:26 1995
  33367.       The local time is Fri Jan 13 16:49:26 1995
  33368.       Daylight Saving Time is not in effect.
  33369.       **** Changing to Central Time ****
  33370.       The local time is Fri Jan 13 15:49:26 1995
  33371.       Daylight Saving Time is not in effect.
  33372.    ****************************************************************************/
  33373. }
  33374.  
  33375.  
  33376. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33377.  
  33378. Example of tzset 
  33379.  
  33380.      asctime - Convert Time to Character String 
  33381.      _ftime - Store Current Time 
  33382.      gmtime - Convert Time 
  33383.      localtime - Convert Time 
  33384.      mktime - Convert Local Time 
  33385.      putenv - Modify Environment Variables 
  33386.      strftime - Convert to Formatted Time 
  33387.      time - Determine Current Time 
  33388.      <time.h> 
  33389.  
  33390.  
  33391. ΓòÉΓòÉΓòÉ 4.330. _uaddmem - Add Memory to a Heap ΓòÉΓòÉΓòÉ
  33392.  
  33393.  
  33394. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33395.  
  33396. #include <umalloc.h>
  33397. Heap_t _uaddmem(Heap_t heap, void *block, size_t size, int clean);
  33398.  
  33399.  
  33400. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33401.  
  33402. Language Level:  Extension 
  33403.  
  33404. _uaddmem adds a block of memory of size bytes into the specified user heap 
  33405. (created with _ucreate). Before calling _uaddmem, you must first get the block 
  33406. from the operating system, typically by using an OS/2 API like DosAllocMem or 
  33407. by allocating it statically. (See the Control Program Guide and Reference for 
  33408. details on OS/2 APIs for memory management.) 
  33409.  
  33410. If the memory block has been initialized to 0, specify _BLOCK_CLEAN for the 
  33411. clean parameter.  If not, specify !_BLOCK_CLEAN. (This information makes calloc 
  33412. and _ucalloc more efficient). 
  33413.  
  33414. Note:  Memory returned by DosAllocMem is initialized to 0. 
  33415.  
  33416. For fixed-size heaps, you must return all the blocks you added with _uaddmem to 
  33417. the system. (For expandable heaps, these blocks are returned by your release_fn 
  33418. when you call _udestroy.) 
  33419.  
  33420. For more information about creating and using heaps, see "Managing Memory" in 
  33421. the Programming Guide. 
  33422.  
  33423. Note:  For every block of memory you add, a small number of bytes from it are 
  33424. used to store internal information. To reduce the total amount of overhead, it 
  33425. is better to add a few large blocks of memory than many small blocks. 
  33426.  
  33427. Return Value 
  33428. _uaddmem returns a pointer to the heap the memory was added to. If the heap 
  33429. specified is not valid, _uaddmem returns NULL. 
  33430.  
  33431.  
  33432. ΓòÉΓòÉΓòÉ <hidden> Example of _uaddmem ΓòÉΓòÉΓòÉ
  33433.  
  33434. /************************************************************************
  33435.  
  33436. The following example creates a heap myheap, and then uses _uaddmem to add 
  33437. memory to it. 
  33438.  
  33439. ************************************************************************/
  33440.  
  33441. #define  INCL_DOSMEMMGR             /* Memory Manager values */
  33442. #include <os2.h>
  33443. #include <bsememf.h>                /* Get flags for memory management  */
  33444. #include <stdlib.h>
  33445. #include <stdio.h>
  33446. #include <umalloc.h>
  33447.  
  33448. int main(void)
  33449. {
  33450.    void    *initial_block, *extra_chunk;
  33451.    APIRET  rc;
  33452.    Heap_t  myheap;
  33453.    char    *p1, *p2;
  33454.  
  33455.    /* Call DosAllocMem to get the initial block of memory */
  33456.    if (0 != (rc = DosAllocMem(&initial_block, 65536,
  33457.                               PAG_WRITE | PAG_READ | PAG_COMMIT))) {
  33458.       printf("DosAllocMem for initial block failed: return code = %ld\n", rc);
  33459.       exit(EXIT_FAILURE);
  33460.    }
  33461.    /* Create a fixed size heap starting with the block declared earlier */
  33462.    if (NULL == (myheap = _ucreate(initial_block, 65536, _BLOCK_CLEAN,
  33463.                                   _HEAP_REGULAR, NULL, NULL))) {
  33464.       puts("_ucreate failed.");
  33465.       exit(EXIT_FAILURE);
  33466.    }
  33467.    if (0 != _uopen(myheap)) {
  33468.       puts("_uopen failed.");
  33469.       exit(EXIT_FAILURE);
  33470.    }
  33471.    p1 = _umalloc(myheap, 100);
  33472.    /* Call DosAllocMem to get another block of memory */
  33473.    if (0 != (rc = DosAllocMem(&extra_chunk, 10 * 65536,
  33474.                               PAG_WRITE | PAG_READ | PAG_COMMIT))) {
  33475.       printf("DosAllocMem for extra chunk failed: return code = %ld\n", rc);
  33476.       exit(EXIT_FAILURE);
  33477.    }
  33478.    /* Add the second chunk of memory to user heap */
  33479.    if (myheap != _uaddmem(myheap, extra_chunk, 10 * 65536, _BLOCK_CLEAN)) {
  33480.       puts("_uaddmem failed.");
  33481.       exit(EXIT_FAILURE);
  33482.    }
  33483.    p2 = _umalloc(myheap, 100000);
  33484.    free(p1);
  33485.    free(p2);
  33486.    if (0 != _uclose(myheap)) {
  33487.       puts("_uclose failed");
  33488.       exit(EXIT_FAILURE);
  33489.    }
  33490.    if (0 != DosFreeMem(initial_block) || 0 != DosFreeMem(extra_chunk)) {
  33491.       puts("DosFreeMem error.");
  33492.       exit(EXIT_FAILURE);
  33493.    }
  33494.    return 0;
  33495. }
  33496.  
  33497.  
  33498. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33499.  
  33500. Example of _uaddmem 
  33501.  
  33502.      _ucreate - Create a Memory Heap 
  33503.      _udestroy - Destroy a Heap 
  33504.      _uheapmin - Release Unused Memory in User Heap 
  33505.      Differentiating between Memory Management Functions 
  33506.      "Managing Memory" in the Programming Guide 
  33507.      <umalloc.h> 
  33508.  
  33509.  
  33510. ΓòÉΓòÉΓòÉ 4.331. _ucalloc - Reserve and Initialize Memory from User Heap ΓòÉΓòÉΓòÉ
  33511.  
  33512.  
  33513. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33514.  
  33515. #include <umalloc.h>
  33516. void *_ucalloc(Heap_t heap, size_t num, size_t size);
  33517.  
  33518.  
  33519. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33520.  
  33521. Language Level:  Extension 
  33522.  
  33523. _ucalloc allocates memory for an array of num elements, each of length size 
  33524. bytes, from the heap you specify. It then initializes all bits of each element 
  33525. to 0. 
  33526.  
  33527. _ucalloc works just like calloc except that you specify the heap to use; calloc 
  33528. always allocates from the default heap. A debug version of this function, 
  33529. _debug_ucalloc, is also provided. 
  33530.  
  33531. If the heap does not have enough memory for the request, _ucalloc calls the 
  33532. getmore_fn that you specified when you created the heap with _ucreate. 
  33533.  
  33534. To reallocate or free memory allocated with _ucalloc, use the non-heap-specific 
  33535. realloc and free. These functions always check what heap the memory was 
  33536. allocated from. 
  33537.  
  33538. Return Value 
  33539. _ucalloc returns a pointer to the reserved space. If size or num was specified 
  33540. as zero, or if your getmore_fn cannot provide enough memory, _ucalloc returns 
  33541. NULL. Passing _ucalloc a heap that is not valid results in undefined behavior. 
  33542.  
  33543.  
  33544. ΓòÉΓòÉΓòÉ <hidden> Example of _ucalloc ΓòÉΓòÉΓòÉ
  33545.  
  33546. /************************************************************************
  33547.  
  33548. This example creates a heap myheap and then uses _ucalloc to allocate memory 
  33549. from it. 
  33550.  
  33551. ************************************************************************/
  33552.  
  33553. #include <stdlib.h>
  33554. #include <stdio.h>
  33555. #include <umalloc.h>
  33556. #include <string.h>
  33557.  
  33558. int main(void)
  33559. {
  33560.    Heap_t  myheap;
  33561.    char    *ptr;
  33562.  
  33563.    /* Use default heap as user heap */
  33564.    myheap = _udefault(NULL);
  33565.  
  33566.    if (NULL == (ptr = _ucalloc(myheap, 100, 1))) {
  33567.       puts("Cannot allocate memory from user heap.");
  33568.       exit(EXIT_FAILURE);
  33569.    }
  33570.    memset(ptr, 'x', 10);
  33571.    free(ptr);
  33572.    return 0;
  33573. }
  33574.  
  33575.  
  33576. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33577.  
  33578. Example of _ucalloc 
  33579.  
  33580.      calloc - Reserve and Initialize Storage 
  33581.      _debug_ucalloc - Reserve and Initialize Memory from User Heap 
  33582.      free - Release Storage Blocks 
  33583.      realloc - Change Reserved Storage Block Size 
  33584.      _ucreate - Create a Memory Heap 
  33585.      _umalloc - Reserve Memory Blocks from User Heap 
  33586.      Differentiating between Memory Management Functions 
  33587.      "Managing Memory" in the Programming Guide 
  33588.      <umalloc.h> 
  33589.  
  33590.  
  33591. ΓòÉΓòÉΓòÉ 4.332. _uclose - Close Heap from Use ΓòÉΓòÉΓòÉ
  33592.  
  33593.  
  33594. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33595.  
  33596. #include <umalloc.h>
  33597. int _uclose(Heap_t heap);
  33598.  
  33599.  
  33600. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33601.  
  33602. Language Level:  Extension 
  33603.  
  33604. _uclose closes a heap when a process will not use it again.  After you close a 
  33605. heap, any attempt in the current process to allocate or return memory to it 
  33606. will have undefined results. _uclose affects only the current process; if the 
  33607. heap is shared, other processes may still be able to access it. 
  33608.  
  33609. Once you have closed the heap, use _udestroy to destroy it and return all its 
  33610. memory to the operating system. 
  33611.  
  33612. Note:  If the heap is shared, you must close it in all processes that share it 
  33613. before you destroy it, or undefined results will occur. 
  33614.  
  33615. You cannot close the VisualAge C++ runtime heap (_RUNTIME_HEAP). 
  33616.  
  33617. For more information about creating and using heaps, see "Managing Memory" in 
  33618. the Programming Guide. 
  33619.  
  33620. Return Value: 
  33621. If successful, _uclose returns 0. A nonzero return value indicates failure. 
  33622. Passing _uclose a heap that is not valid results in undefined behavior. 
  33623.  
  33624.  
  33625. ΓòÉΓòÉΓòÉ <hidden> Example of _uclose ΓòÉΓòÉΓòÉ
  33626.  
  33627. /************************************************************************
  33628.  
  33629. This example creates and opens a heap, and then performs operations on it.  It 
  33630. then calls _uclose to close the heap before destroying it. 
  33631.  
  33632. ************************************************************************/
  33633.  
  33634. #define  INCL_DOSMEMMGR             /* Memory Manager values */
  33635. #include <os2.h>
  33636. #include <bsememf.h>                /* Get flags for memory management  */
  33637. #include <stdlib.h>
  33638. #include <stdio.h>
  33639. #include <umalloc.h>
  33640.  
  33641. int main(void)
  33642. {
  33643.    void    *initial_block;
  33644.    APIRET  rc;
  33645.    Heap_t  myheap;
  33646.    char    *p;
  33647.  
  33648.    /* Call DosAllocMem to get the initial block of memory */
  33649.    if (0 != (rc = DosAllocMem(&initial_block, 65536,
  33650.                               PAG_WRITE | PAG_READ | PAG_COMMIT))) {
  33651.       printf("DosAllocMem error: return code = %ld\n", rc);
  33652.       exit(EXIT_FAILURE);
  33653.    }
  33654.    /* Create a fixed size heap starting with the block declared earlier */
  33655.    if (NULL == (myheap = _ucreate(initial_block, 65536, _BLOCK_CLEAN,
  33656.                                   _HEAP_REGULAR, NULL, NULL))) {
  33657.       puts("_ucreate failed.");
  33658.       exit(EXIT_FAILURE);
  33659.    }
  33660.    if (0 != _uopen(myheap)) {
  33661.       puts("_uopen failed.");
  33662.       exit(EXIT_FAILURE);
  33663.    }
  33664.    p = _umalloc(myheap, 100);
  33665.    memset(p, 'x', 10);
  33666.    free(p);
  33667.  
  33668.    if (0 != _uclose(myheap)) {
  33669.       puts("_uclose failed");
  33670.       exit(EXIT_FAILURE);
  33671.    }
  33672.    if (0 != (rc = DosFreeMem(initial_block))) {
  33673.       printf("DosFreeMem error: return code = %ld\n", rc);
  33674.       exit(EXIT_FAILURE);
  33675.    }
  33676.    return 0;
  33677. }
  33678.  
  33679.  
  33680. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33681.  
  33682. Example of _uclose 
  33683.  
  33684.      _uopen - Open Heap for Use 
  33685.      _udestroy - Destroy a Heap 
  33686.      _ucreate - Create a Memory Heap 
  33687.      Differentiating between Memory Management Functions 
  33688.      "Managing Memory" in the Programming Guide 
  33689.      <umalloc.h> 
  33690.  
  33691.  
  33692. ΓòÉΓòÉΓòÉ 4.333. _ucreate - Create a Memory Heap ΓòÉΓòÉΓòÉ
  33693.  
  33694.  
  33695. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33696.  
  33697. #include <umalloc.h>
  33698. Heap_t _ucreate(void *block, size_t initsz, int clean, int memtype,
  33699.                  void *(*getmore_fn)(Heap_t, size_t *, int *)
  33700.                  void  (*release_fn)(Heap_t, void *, size_t);
  33701.  
  33702.  
  33703. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33704.  
  33705. Language Level:  Extension 
  33706.  
  33707. _ucreate creates your own memory heap that you can allocate and free memory 
  33708. from, just like the VisualAge C++ runtime heap. 
  33709.  
  33710. Before you call _ucreate, you must first get the initial block of memory for 
  33711. the heap.  You can get this block by calling an OS/2 API (such as DosAllocMem 
  33712. or or DosAllocSharedMem) or by statically allocating it. (See the CP 
  33713. Programming Guide and Reference for more information on the OS/2 APIs.) 
  33714.  
  33715. Note:  You must also return this initial block of memory to the system after 
  33716. you destroy the heap. 
  33717.  
  33718. When you call _ucreate, you pass it the following parameters: 
  33719.  
  33720.  block         The pointer to the initial block you obtained. 
  33721.  
  33722.  initsz        The size of the initial block, which must be at least 
  33723.                _HEAP_MIN_SIZE bytes (defined in <malloc.h>). If you are 
  33724.                creating a fixed-size heap, the size must be large enough to 
  33725.                satisfy all memory requests your program will make of it. 
  33726.  
  33727.  clean         The macro _BLOCK_CLEAN, if the memory in the block has been 
  33728.                initialized to 0, or !_BLOCK_CLEAN, if the memory has not been 
  33729.                touched.  This improves the efficiency of _ucalloc; if the 
  33730.                memory is already initialized to 0, _ucalloc does not need to 
  33731.                initialize it. 
  33732.  
  33733.                Note:  DosAllocMem initializes memory to 0 for you.  You can 
  33734.                also use memset to initialize the memory; however, memset also 
  33735.                commits all the memory at once, an action that could slow 
  33736.                overall performance. 
  33737.  
  33738.  memtype       A macro indicating the type of memory in your heap: 
  33739.                _HEAP_REGULAR (regular) or _HEAP_TILED (tiled). If you want the 
  33740.                memory to be shared, specify _HEAP_SHARED as well (for example, 
  33741.                _HEAP_REGULAR | _HEAP_SHARED). Tiled memory blocks will not 
  33742.                cross 64K boundaries, so the data in them can be used in 16-bit 
  33743.                programs. Shared memory can be shared between different 
  33744.                processes. For more information on different types of memory, 
  33745.                see the Programming Guide and the Control Program Guide and 
  33746.                Reference. 
  33747.  
  33748.                Note:  Make sure that when you get the initial block, you 
  33749.                request the same type of memory that you specify for memtype. 
  33750.  
  33751.  getmore_fn    A function you provide to get more memory from the system 
  33752.                (typically using OS/2 APIs or static allocation). To create a 
  33753.                fixed-size heap, specify NULL for this parameter. 
  33754.  
  33755.  release_fn    A function you provide to return memory to the system (typically 
  33756.                using DosFreeMem). To create a fixed-size heap, specify NULL for 
  33757.                this parameter. 
  33758.  
  33759.  If you create a fixed-size heap, the initial block of memory must be large 
  33760.  enough to satisfy all allocation requests made to it. Once the block is fully 
  33761.  allocated, further allocation requests to the heap will fail.  If you create 
  33762.  an expandable heap, the getmore_fn and release_fn allow your heap to expand 
  33763.  and shrink dynamically. 
  33764.  
  33765.  When you call _umalloc (or a similar function) for your heap, if not enough 
  33766.  memory is available in the block, it calls the getmore_fn you provide. Your 
  33767.  getmore_fn then gets more memory from the system and adds it to the heap, 
  33768.  using any method you choose. 
  33769.  
  33770.  Your getmore_fn must have the following prototype: 
  33771.  
  33772.      void *(*getmore_fn)(Heap_t uh, size_t *size, int *clean);
  33773.  where: 
  33774.  
  33775.  uh      Is the heap to get memory for. 
  33776.  size    Is the size of the allocation request passed by _umalloc. You probably 
  33777.          want to return enough memory at a time to satisfy several allocations; 
  33778.          otherwise, every subsequent allocation has to call getmore_fn. You 
  33779.          should return multiples of 64K (the smallest size that DosAllocMem 
  33780.          returns). Make sure you update the size parameter if you return more 
  33781.          than the original request. 
  33782.  clean   Within getmore_fn, you must set this variable either to _BLOCK_CLEAN, 
  33783.          to indicate that you initialized the memory to 0, or to !_BLOCK_CLEAN, 
  33784.          to indicate that the memory is untouched. 
  33785.  
  33786.  Note:  Make sure your getmore_fn allocates the right type of memory for the 
  33787.  heap. 
  33788.  
  33789.  When you call _uheapmin to coalesce the heap or _udestroy to destroy it, these 
  33790.  functions call the release_fn you provide to return the memory to the system. 
  33791.  function. 
  33792.  
  33793.  Your release_fn must have the following prototype: 
  33794.  
  33795.      void (*release_fn)(Heap_t uh, void *block, size_t size);
  33796.  
  33797.  The heap uh the block is from, the block to be returned, and its size are 
  33798.  passed to release_fn by _uheapmin or _udestroy. 
  33799.  
  33800.  For more information about creating and using heaps, see the "Managing Memory" 
  33801.  in the Programming Guide. 
  33802.  
  33803.  Return Value: 
  33804.  If successful, _ucreate returns a pointer to the heap created. If errors 
  33805.  occur, _ucreate returns NULL. 
  33806.  
  33807.  
  33808. ΓòÉΓòÉΓòÉ <hidden> Example of _ucreate ΓòÉΓòÉΓòÉ
  33809.  
  33810. /************************************************************************
  33811.  
  33812. This example uses _ucreate to create an expandable heap. The functions for 
  33813. expanding and shrinking the heap are get_fn and release_fn. The program then 
  33814. opens the heap and performs operations on it, and then closes and destroys the 
  33815. heap. 
  33816.  
  33817. ************************************************************************/
  33818.  
  33819. #define  INCL_DOSMEMMGR             /* Memory Manager values */
  33820. #include <os2.h>
  33821. #include <bsememf.h>                /* Get flags for memory management  */
  33822. #include <stdlib.h>
  33823. #include <stdio.h>
  33824. #include <umalloc.h>
  33825.  
  33826. static void *get_fn(Heap_t usrheap, size_t *length, int *clean)
  33827. {
  33828.    void *p;
  33829.  
  33830.    /* Round up to the next chunk size */
  33831.    *length = ((*length) / 65536) * 65536 + 65536;
  33832.    *clean = _BLOCK_CLEAN;
  33833.    DosAllocMem(&p, *length, PAG_COMMIT | PAG_READ | PAG_WRITE);
  33834.    return (p);
  33835. }
  33836.  
  33837. static void release_fn(Heap_t usrheap, void *p, size_t size)
  33838. {
  33839.    DosFreeMem(p);
  33840.    return;
  33841. }
  33842.  
  33843. int main(void)
  33844. {
  33845.    void    *initial_block;
  33846.    APIRET  rc;
  33847.    Heap_t  myheap;
  33848.    char    *ptr;
  33849.  
  33850.    /* Call DosAllocMem to get the initial block of memory */
  33851.    if (0 != (rc = DosAllocMem(&initial_block, 65536,
  33852.                               PAG_WRITE | PAG_READ | PAG_COMMIT))) {
  33853.       printf("DosAllocMem error: return code = %ld\n", rc);
  33854.       exit(EXIT_FAILURE);
  33855.    }
  33856.    /* Create an expandable heap starting with the block declared earlier */
  33857.    if (NULL == (myheap = _ucreate(initial_block, 65536, _BLOCK_CLEAN,
  33858.                                   _HEAP_REGULAR, get_fn, release_fn))) {
  33859.       puts("_ucreate failed.");
  33860.       exit(EXIT_FAILURE);
  33861.    }
  33862.    if (0 != _uopen(myheap)) {
  33863.       puts("_uopen failed.");
  33864.       exit(EXIT_FAILURE);
  33865.    }
  33866.  
  33867.    /* Force user heap to grow */
  33868.    ptr = _umalloc(myheap, 100000);
  33869.  
  33870.    _uclose(myheap);
  33871.  
  33872.    if (0 != _udestroy(myheap, _FORCE)) {
  33873.       puts("_udestroy failed.");
  33874.       exit(EXIT_FAILURE);
  33875.    }
  33876.    if (0 != (rc = DosFreeMem(initial_block))) {
  33877.       printf("DosFreeMem error: return code = %ld\n", rc);
  33878.       exit(EXIT_FAILURE);
  33879.    }
  33880.    return 0;
  33881. }
  33882.  
  33883.  
  33884. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  33885.  
  33886. Example of _ucreate 
  33887.  
  33888.      _uaddmem - Add Memory to a Heap 
  33889.      _ucalloc - Reserve and Initialize Memory from User Heap 
  33890.      _uclose - Close Heap from Use 
  33891.      _udestroy - Destroy a Heap 
  33892.      _uheapmin - Release Unused Memory in User Heap 
  33893.      _umalloc - Reserve Memory Blocks from User Heap 
  33894.      _uopen - Open Heap for Use 
  33895.      Differentiating between Memory Management Functions 
  33896.      "Managing Memory" in the Programming Guide 
  33897.      <umalloc.h> 
  33898.  
  33899.  
  33900. ΓòÉΓòÉΓòÉ 4.334. _udefault - Change the Default Heap ΓòÉΓòÉΓòÉ
  33901.  
  33902.  
  33903. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  33904.  
  33905. #include <umalloc.h>
  33906. Heap_t _udefault(Heap_t heap);
  33907.  
  33908.  
  33909. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  33910.  
  33911. Language Level:  Extension 
  33912.  
  33913. _udefault makes the heap you specify become the default heap. All calls to 
  33914. memory management functions that do not specify a heap (including malloc and 
  33915. calloc) then allocate memory from the heap. 
  33916.  
  33917. This change affects only the thread where you called _udefault. 
  33918.  
  33919. The initial default heap is the VisualAge C++ runtime heap. To restore or 
  33920. explicitly set the VisualAge C++ runtime heap as the default, call _udefault 
  33921. with the argument _RUNTIME_HEAP. 
  33922.  
  33923. You can also use _udefault to find out which heap is being used as the default 
  33924. by specifying NULL for the heap parameter. The default heap remains the same. 
  33925.  
  33926. For more information about creating and using heaps, see "Managing Memory" in 
  33927. the Programming Guide. 
  33928.  
  33929. Return Value: 
  33930. _udefault returns a pointer to the former default heap. You can save this 
  33931. pointer and use it later to restore the original heap. If the call is 
  33932. unsuccessful, _udefault returns NULL. Passing _udefault a heap that is not 
  33933. valid results in undefined behavior. 
  33934.  
  33935.  
  33936. ΓòÉΓòÉΓòÉ <hidden> Example of _udefault ΓòÉΓòÉΓòÉ
  33937.  
  33938. /************************************************************************
  33939.  
  33940. This example creates a fixed-size heap myheap and uses _udefault to make it the 
  33941. default heap. The call to malloc then allocates memory from myheap. The second 
  33942. call to _udefault restores the original default heap. 
  33943.  
  33944. ************************************************************************/
  33945.  
  33946. #define  INCL_DOSMEMMGR             /* Memory Manager values */
  33947. #include <os2.h>
  33948. #include <bsememf.h>                /* Get flags for memory management  */
  33949. #include <stdlib.h>
  33950. #include <stdio.h>
  33951. #include <umalloc.h>
  33952.  
  33953. int main(void)
  33954. {
  33955.    void    *initial_block;
  33956.    APIRET  rc;
  33957.    Heap_t  myheap, old_heap;
  33958.    char    *p;
  33959.  
  33960.    /* Call DosAllocMem to get the initial block of memory */
  33961.    if (0 != (rc = DosAllocMem(&initial_block, 65536,
  33962.                               PAG_WRITE | PAG_READ | PAG_COMMIT))) {
  33963.       printf("DosAllocMem error: return code = %ld\n", rc);
  33964.       exit(EXIT_FAILURE);
  33965.    }
  33966.    /* Create a fixed size heap starting with the block declared earlier */
  33967.    if (NULL == (myheap = _ucreate(initial_block, 65536, _BLOCK_CLEAN,
  33968.                                   _HEAP_REGULAR, NULL, NULL))) {
  33969.       puts("_ucreate failed.");
  33970.       exit(EXIT_FAILURE);
  33971.    }
  33972.    if (0 != _uopen(myheap)) {
  33973.       puts("_uopen failed.");
  33974.       exit(EXIT_FAILURE);
  33975.    }
  33976.  
  33977.    /* myheap is used as default heap */
  33978.    old_heap = _udefault(myheap);
  33979.  
  33980.    /* malloc will allocate memory from myheap */
  33981.    p = malloc(100);
  33982.    memset(p, 'x', 10);
  33983.  
  33984.    /* Restore original default heap */
  33985.    _udefault(old_heap);
  33986.  
  33987.    free(p);
  33988.    if (0 != _uclose(myheap)) {
  33989.       puts("_uclose failed");
  33990.       exit(EXIT_FAILURE);
  33991.    }
  33992.    if (0 != (rc = DosFreeMem(initial_block))) {
  33993.       printf("DosFreeMem error: return code = %ld\n", rc);
  33994.       exit(EXIT_FAILURE);
  33995.    }
  33996.    return 0;
  33997. }
  33998.  
  33999.  
  34000. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34001.  
  34002. Example of _udefault 
  34003.  
  34004.      calloc - Reserve and Initialize Storage 
  34005.      malloc - Reserve Storage Block 
  34006.      _mheap - Query Memory Heap for Allocated Object 
  34007.      _ucreate - Create a Memory Heap 
  34008.      Differentiating between Memory Management Functions 
  34009.      "Managing Memory" in the Programming Guide 
  34010.      <umalloc.h> 
  34011.  
  34012.  
  34013. ΓòÉΓòÉΓòÉ 4.335. _udestroy - Destroy a Heap ΓòÉΓòÉΓòÉ
  34014.  
  34015.  
  34016. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34017.  
  34018. #include <umalloc.h>
  34019. int _udestroy(Heap_t heap, int force);
  34020.  
  34021.  
  34022. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34023.  
  34024. Language Level:  Extension 
  34025.  
  34026. _udestroy destroys the heap you specify. It also returns the heap's memory to 
  34027. the system by calling the release_fn you supplied to _ucreate when you created 
  34028. the heap. If you did not supply a release_fn, _udestroy simply marks the heap 
  34029. as destroyed so no further operations can be performed. You must then return 
  34030. all the memory in the heap to the system. 
  34031.  
  34032. Note:  Whether or not you provide a release_fn, you must always return the 
  34033. initial block of memory (that you provided to _ucreate) to the system. 
  34034.  
  34035. The force parameter controls the behavior of _udestroy if all allocated objects 
  34036. from the heap have not been freed. If you specify _FORCE for this parameter, 
  34037. _udestroy destroys the heap regardless of whether allocated objects remain in 
  34038. that process or in any other process that shares the heap. If you specify 
  34039. !_FORCE, the heap will not be destroyed if any objects are still allocated from 
  34040. it. 
  34041.  
  34042. Typically, you call _uclose to close the heap before you destroy it. After you 
  34043. have destroyed a heap, any attempt to access it will have undefined results. 
  34044.  
  34045. You cannot destroy the VisualAge C++ runtime heap (_RUNTIME_HEAP). 
  34046.  
  34047. Return Value 
  34048. _udestroy returns 0 whether the heap was destroyed or not. If the heap passed 
  34049. to it is not valid, _udestroy returns a nonzero value. 
  34050.  
  34051.  
  34052. ΓòÉΓòÉΓòÉ <hidden> Example of _udestroy ΓòÉΓòÉΓòÉ
  34053.  
  34054. /************************************************************************
  34055.  
  34056. This example creates and opens a heap, performs operations on it, and then 
  34057. closes it. The program then calls _udestroy with the _FORCE parameter to force 
  34058. the destruction of the heap. _udestroy calls release_fn to return the memory to 
  34059. the system. 
  34060.  
  34061. ************************************************************************/
  34062.  
  34063. #define  INCL_DOSMEMMGR             /* Memory Manager values */
  34064. #include <os2.h>
  34065. #include <bsememf.h>                /* Get flags for memory management  */
  34066. #include <stdlib.h>
  34067. #include <stdio.h>
  34068. #include <umalloc.h>
  34069.  
  34070. static void *get_fn(Heap_t usrheap, size_t *length, int *clean)
  34071. {
  34072.    void *p;
  34073.  
  34074.    /* Round up to the next chunk size */
  34075.    *length = ((*length) / 65536) * 65536 + 65536;
  34076.    *clean = _BLOCK_CLEAN;
  34077.    DosAllocMem(&p, *length, PAG_COMMIT | PAG_READ | PAG_WRITE);
  34078.    return (p);
  34079. }
  34080.  
  34081. static void release_fn(Heap_t usrheap, void *p, size_t size)
  34082. {
  34083.    DosFreeMem(p);
  34084.    return;
  34085. }
  34086.  
  34087. int main(void)
  34088. {
  34089.    void    *initial_block;
  34090.    APIRET  rc;
  34091.    Heap_t  myheap;
  34092.    char    *ptr;
  34093.  
  34094.    /* Call DosAllocMem to get the initial block of memory */
  34095.    if (0 != (rc = DosAllocMem(&initial_block, 65536,
  34096.                               PAG_WRITE | PAG_READ | PAG_COMMIT))) {
  34097.       printf("DosAllocMem error: return code = %ld\n", rc);
  34098.       exit(EXIT_FAILURE);
  34099.    }
  34100.    /* Create an expandable heap starting with the block declared earlier */
  34101.    if (NULL == (myheap = _ucreate(initial_block, 65536, _BLOCK_CLEAN,
  34102.                                   _HEAP_REGULAR, get_fn, release_fn))) {
  34103.       puts("_ucreate failed.");
  34104.       exit(EXIT_FAILURE);
  34105.    }
  34106.    if (0 != _uopen(myheap)) {
  34107.       puts("_uopen failed.");
  34108.       exit(EXIT_FAILURE);
  34109.    }
  34110.  
  34111.    /* Force user heap to grow */
  34112.    ptr = _umalloc(myheap, 100000);
  34113.  
  34114.    _uclose(myheap);
  34115.  
  34116.    if (0 != _udestroy(myheap, _FORCE)) {
  34117.       puts("_udestroy failed.");
  34118.       exit(EXIT_FAILURE);
  34119.    }
  34120.    if (0 != (rc = DosFreeMem(initial_block))) {
  34121.       printf("DosFreeMem error: return code = %ld\n", rc);
  34122.       exit(EXIT_FAILURE);
  34123.    }
  34124.    return 0;
  34125. }
  34126.  
  34127.  
  34128. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34129.  
  34130. Example of _udestroy 
  34131.  
  34132.      _uaddmem - Add Memory to a Heap 
  34133.      _ucreate - Create a Memory Heap 
  34134.      _uopen - Open Heap for Use 
  34135.      _uclose - Close Heap from Use 
  34136.      Differentiating between Memory Management Functions 
  34137.      "Managing Memory" in the Programming Guide 
  34138.      <umalloc.h> 
  34139.  
  34140.  
  34141. ΓòÉΓòÉΓòÉ 4.336. _udump_allocated - Get Information about Allocated Memory in Heap ΓòÉΓòÉΓòÉ
  34142.  
  34143.  
  34144. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34145.  
  34146. #include <umalloc.h>
  34147. void _udump_allocated(Heap_t heap, int nbytes);
  34148.  
  34149.  
  34150. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34151.  
  34152. Language Level:  Extension 
  34153.  
  34154. For the heap you specify, _udump_allocated prints information to stderr about 
  34155. each memory block that is currently allocated and was allocated using the debug 
  34156. memory management functions (_debug_ucalloc, _debug_umalloc, and so on). 
  34157.  
  34158. _udump_allocated works just like _dump_allocated, except that you specify the 
  34159. heap to use; _dump_allocated always displays information about the default 
  34160. heap. 
  34161.  
  34162. Use nbytes to specify how many bytes of each memory block are to be printed. If 
  34163. nbytes is: 
  34164.  
  34165.  Negative value  Prints all bytes of each block. 
  34166.  0               Prints no bytes. 
  34167.  Positive value  Prints the specified number of bytes or the entire block, 
  34168.                  whichever is smaller. 
  34169.  
  34170.  _udump_allocated prints the information to stderr by default.  You can change 
  34171.  the destination with the _set_crt_msg_handle function. 
  34172.  
  34173.  Call _udump_allocated at points in your code where you want a report of the 
  34174.  currently allocated memory. For example, a good place to call _udump_allocated 
  34175.  is a point where most of the memory is already freed and you want to find a 
  34176.  memory leak, such as at the end of a program. 
  34177.  
  34178.  You can also use _udump_allocated_delta to display information about only the 
  34179.  memory that was allocated since the previous call to _udump_allocated or 
  34180.  _udump_allocated_delta. 
  34181.  
  34182.  To use _udump_allocated and the debug versions of the memory management 
  34183.  functions, specify the debug memory (/Tm) compiler option. 
  34184.  
  34185.  Note:  The /Tm option maps all calls to memory management functions (including 
  34186.  tiled and heap-specific versions) to their debug counterparts. To prevent a 
  34187.  call from being mapped, parenthesize the function name. 
  34188.  
  34189.  Return Value: 
  34190.  There is no return value. Passing _udump_allocated a heap that is not valid 
  34191.  results in undefined behavior. 
  34192.  
  34193.  
  34194. ΓòÉΓòÉΓòÉ <hidden> Example of _udump_allocated ΓòÉΓòÉΓòÉ
  34195.  
  34196. /************************************************************************
  34197.  
  34198. This example creates a heap, performs some operations on it, and then calls 
  34199. _udump_allocated to print out information about the allocated memory blocks. 
  34200.  
  34201. Note:  You must compile this example with the /Tm option to enable the debug 
  34202. memory management functions. 
  34203.  
  34204. ************************************************************************/
  34205.  
  34206. #include <stdlib.h>
  34207. #include <stdio.h>
  34208. #include <umalloc.h>
  34209. #include <string.h>
  34210.  
  34211. int main(void)
  34212. {
  34213.    Heap_t  myheap;
  34214.    char    *ptr;
  34215.  
  34216.    /* Use default heap as user heap */
  34217.    myheap = _udefault(NULL);
  34218.  
  34219.    if (NULL == (ptr = _umalloc(myheap, 10))) {
  34220.       puts("Cannot allocate memory from user heap.");
  34221.       exit(EXIT_FAILURE);
  34222.    }
  34223.    memset(ptr, 'a', 5);
  34224.  
  34225.    _udump_allocated(myheap, 10);
  34226.  
  34227.    free(ptr);
  34228.    return 0;
  34229.  
  34230.    /****************************************************************************
  34231.       The output should be similar to :
  34232.  
  34233.       -------------------------------------------------------------------------------
  34234.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  34235.       -------------------------------------------------------------------------------
  34236.       Address: 0x00073890      Size: 0x0000000A (10)
  34237.       This memory block was (re)allocated at line number 14 in _udump_alloc.c.
  34238.       Memory contents:  61616161 61AAAAAA AAAA                 [aaaaa╨ÿ╨ÿ╨ÿ╨ÿ╨ÿ      ]
  34239.       -------------------------------------------------------------------------------
  34240.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  34241.       -------------------------------------------------------------------------------
  34242.    ****************************************************************************/
  34243. }
  34244.  
  34245.  
  34246. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34247.  
  34248. Example of _udump_allocated 
  34249.  
  34250.      _debug_ucalloc - Reserve and Initialize Memory from User Heap 
  34251.      _debug_umalloc - Reserve Memory Blocks from User Heap 
  34252.      _debug_realloc - Reallocate Memory Block 
  34253.      _debug_free - Release Memory 
  34254.      _dump_allocated - Get Information about Allocated Memory 
  34255.      _dump_allocated_delta - Get Information about Allocated Memory 
  34256.      _set_crt_msg_handle - Change Runtime Message Output Destination 
  34257.      _tdump_allocated - Get Information about Allocated Tiled Memory 
  34258.      _udump_allocated_delta - Get Information about Allocated Memory in Heap 
  34259.      Differentiating between Memory Management Functions 
  34260.      "Managing Memory" in the Programming Guide 
  34261.      "Debugging Your Heaps" in the Programming Guide 
  34262.      <umalloc.h> 
  34263.  
  34264.  
  34265. ΓòÉΓòÉΓòÉ 4.337. _udump_allocated_delta - Get Information about Allocated Memory in Heap ΓòÉΓòÉΓòÉ
  34266.  
  34267.  
  34268. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34269.  
  34270. #include <umalloc.h>
  34271. void _udump_allocated_delta(Heap_t heap, int nbytes);
  34272.  
  34273.  
  34274. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34275.  
  34276. Language Level:  Extension 
  34277.  
  34278. For the heap you specify, _udump_allocated_delta prints information to stderr 
  34279. about each memory block allocated by a debug memory management function 
  34280. (_debug_umalloc and so on) since the last call to _udump_allocated_delta or 
  34281. _udump_allocated. 
  34282.  
  34283. _udump_allocated_delta and _udump_allocated print the same type of information 
  34284. to stderr, but _udump_allocated displays information about all blocks that have 
  34285. been allocated since the start of your program. 
  34286.  
  34287. _udump_allocated_delta works just like _dump_allocated_delta, except that you 
  34288. specify the heap to use; _dump_allocated_delta always displays information 
  34289. about the default heap. 
  34290.  
  34291. Use nbytes to specify how many bytes of each memory block are to be printed. If 
  34292. nbytes is: 
  34293.  
  34294.  Negative value  Prints all bytes of each block. 
  34295.  0               Prints no bytes. 
  34296.  Positive value  Prints the specified number of bytes or the entire block, 
  34297.                  whichever is smaller. 
  34298.  
  34299.  _udump_allocated_delta prints the information to stderr by default.  You can 
  34300.  change the destination with the _set_crt_msg_handle function. 
  34301.  
  34302.  To use _udump_allocated_delta and the debug versions of the memory management 
  34303.  functions, specify the debug memory (/Tm) compiler option. 
  34304.  
  34305.  Note:  The /Tm option maps all calls to memory management functions (including 
  34306.  tiled and heap-specific versions) to their debug counterparts. To prevent a 
  34307.  call from being mapped, parenthesize the function name. 
  34308.  
  34309.  Return Value: 
  34310.  There is no return value. Passing _udump_allocated_delta a heap that is not 
  34311.  valid results in undefined behavior. 
  34312.  
  34313.  
  34314. ΓòÉΓòÉΓòÉ <hidden> Example of _udump_allocated_delta ΓòÉΓòÉΓòÉ
  34315.  
  34316. /************************************************************************
  34317.  
  34318. This example creates a heap and allocates memory from it. It then calls 
  34319. _udump_allocated to display information about the allocated memory.  After 
  34320. performing more memory operations, it calls _udump_allocated_delta to display 
  34321. information about the memory allocated since the call to _udump_allocated 
  34322.  
  34323. Note:  You must compile this example with the /Tm option to enable the debug 
  34324. memory management functions. 
  34325.  
  34326. ************************************************************************/
  34327.  
  34328. #include <stdlib.h>
  34329. #include <stdio.h>
  34330. #include <string.h>
  34331. #include <umalloc.h>
  34332.  
  34333. int main(void)
  34334. {
  34335.    Heap_t  myheap;
  34336.    char    *ptr1, *ptr2;
  34337.  
  34338.    /* Use default heap as user heap */
  34339.    myheap = _udefault(NULL);
  34340.  
  34341.    if (NULL == (ptr1 = _umalloc(myheap, 10))) {
  34342.       puts("Cannot allocate first memory block from user heap.");
  34343.       exit(EXIT_FAILURE);
  34344.    }
  34345.    memset(ptr1, 'a', 5);
  34346.    _udump_allocated(myheap, 10);
  34347.  
  34348.    if (NULL == (ptr2 = _umalloc(myheap, 20))) {
  34349.       puts("Cannot allocate second memory block from user heap.");
  34350.       exit(EXIT_FAILURE);
  34351.    }
  34352.    memset(ptr2, 'b', 5);
  34353.    printf("\nResults of _udump_allocated_delta are:\n");
  34354.    _udump_allocated_delta(myheap, 10);
  34355.  
  34356.    free(ptr1);
  34357.    free(ptr2);
  34358.    return 0;
  34359.  
  34360.    /****************************************************************************
  34361.       The output should be similar to :
  34362.  
  34363.       -------------------------------------------------------------------------------
  34364.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  34365.       -------------------------------------------------------------------------------
  34366.       Address: 0x00073890      Size: 0x0000000A (10)
  34367.       This memory block was (re)allocated at line number 14 in _udump_alloc_d.c.
  34368.       Memory contents:  61616161 61AAAAAA AAAA                 [aaaaa╨ÿ╨ÿ╨ÿ╨ÿ╨ÿ      ]
  34369.       -------------------------------------------------------------------------------
  34370.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  34371.       -------------------------------------------------------------------------------
  34372.  
  34373.       Results of _udump_allocated_delta are:
  34374.       -------------------------------------------------------------------------------
  34375.                        START OF DUMP OF ALLOCATED MEMORY BLOCKS
  34376.       -------------------------------------------------------------------------------
  34377.       Address: 0x000738D0      Size: 0x00000014 (20)
  34378.       This memory block was (re)allocated at line number 21 in _udump_alloc_d.c.
  34379.       Memory contents:  62626262 62AAAAAA AAAA                 [bbbbb╨ÿ╨ÿ╨ÿ╨ÿ╨ÿ      ]
  34380.       -------------------------------------------------------------------------------
  34381.                        END OF DUMP OF ALLOCATED MEMORY BLOCKS
  34382.       -------------------------------------------------------------------------------
  34383.    ****************************************************************************/
  34384. }
  34385.  
  34386.  
  34387. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34388.  
  34389. Example of _udump_allocated_delta 
  34390.  
  34391.      _dump_allocated - Get Information about Allocated Memory 
  34392.      _dump_allocated_delta - Get Information about Allocated Memory 
  34393.      _debug_umalloc - Reserve Memory Blocks from User Heap 
  34394.      _debug_ucalloc - Reserve and Initialize Memory from User Heap 
  34395.      _debug_realloc - Reallocate Memory Block 
  34396.      _set_crt_msg_handle - Change Runtime Message Output Destination 
  34397.      _tdump_allocated_delta - Get Information about Allocated Tiled Memory 
  34398.      _udump_allocated - Get Information about Allocated Memory in Heap 
  34399.      Differentiating between Memory Management Functions 
  34400.      "Managing Memory" in the Programming Guide 
  34401.      "Debugging Your Heaps" in the Programming Guide 
  34402.      <umalloc.h> 
  34403.  
  34404.  
  34405. ΓòÉΓòÉΓòÉ 4.338. _uheap_check - Validate User Memory Heap ΓòÉΓòÉΓòÉ
  34406.  
  34407.  
  34408. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34409.  
  34410. #include <umalloc.h>
  34411. void _uheap_check(Heap_t heap);
  34412.  
  34413.  
  34414. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34415.  
  34416. Language Level:  Extension 
  34417.  
  34418. _uheap_check checks all memory blocks in the heap  you specify that have been 
  34419. allocated or freed using the heap-specific debug versions of the memory 
  34420. management functions (_debug_ucalloc, _debug_umalloc, and so on). _uheap_check 
  34421. checks that your program has not overwritten freed memory blocks or memory 
  34422. outside the bounds of allocated blocks. 
  34423.  
  34424. _uheap_check works just like _heap_check, except that you specify the heap to 
  34425. check; _heap_check always checks the default heap. 
  34426.  
  34427. When you call a heap-specific debug memory management function (such as 
  34428. _debug_umalloc), it calls _uheap_check automatically. You can also call 
  34429. _uheap_check explicitly. Place calls to _uheap_check throughout your code, 
  34430. especially in areas that you suspect have memory problems. 
  34431.  
  34432. Calling _uheap_check frequently (explicitly or through the tiled debug memory 
  34433. functions) can increase your program's memory requirements and decrease its 
  34434. execution speed.  To reduce the overhead of heap-checking, you can use the 
  34435. DDE4_HEAP_SKIP environment variable to control how often the functions check 
  34436. the heap. For example: 
  34437.  
  34438.   SET DDE4_HEAP_SKIP=10
  34439. specifies that every tenth call to any debug memory function (regardless of the 
  34440. type or heap) checks the heap. Explicit calls to _uheap_check are always 
  34441. performed. For more details on DDE4_HEAP_SKIP, see "Skipping Heap Checks" in 
  34442. the Programming Guide. 
  34443.  
  34444. To use _uheap_check and the debug versions of the memory management functions, 
  34445. specify the debug memory (/Tm) compiler option. 
  34446.  
  34447. Note:  The /Tm option maps all calls to memory management functions (including 
  34448. tiled and heap-specific versions) to their debug counterparts. To prevent a 
  34449. call from being mapped, parenthesize the function name. 
  34450.  
  34451. Return Value 
  34452. There is no return value. 
  34453.  
  34454.  
  34455. ΓòÉΓòÉΓòÉ <hidden> Example of _uheap_check ΓòÉΓòÉΓòÉ
  34456.  
  34457. /************************************************************************
  34458.  
  34459. This example creates a heap and allocates memory from it.  It then calls 
  34460. _uheap_check to check the the memory in the heap. 
  34461.  
  34462. Note:  You must compile this example with the /Tm option to map the _ucalloc 
  34463. calls to _debug_ucalloc. 
  34464.  
  34465. ************************************************************************/
  34466.  
  34467. #include <stdlib.h>
  34468. #include <stdio.h>
  34469. #include <umalloc.h>
  34470.  
  34471. int main(void)
  34472. {
  34473.    Heap_t  myheap;
  34474.    char    *ptr;
  34475.  
  34476.    /* Use default heap as user heap */
  34477.    myheap = _udefault(NULL);
  34478.  
  34479.    if (NULL == (ptr = _ucalloc(myheap, 100, 1))) {
  34480.       puts("Cannot allocate memory from user heap.");
  34481.       exit(EXIT_FAILURE);
  34482.    }
  34483.    memset(ptr, 'x', 105);     /* overwrite storage that was not allocated */
  34484.  
  34485.    _uheap_check(myheap);
  34486.  
  34487.    free(ptr);
  34488.    return 0;
  34489.  
  34490.    /****************************************************************************
  34491.       The output should be similar to :
  34492.  
  34493.       End of allocated object 0x00073890 was overwritten at 0x000738f4.
  34494.       The first eight bytes of the memory block (in hex) are: 7878787878787878.
  34495.       This memory block was (re)allocated at line number 13 in _uheap_check.c.
  34496.       Heap state was valid at line 13 of _uheap_check.c.
  34497.       Memory error detected at line 19 of _uheap_check.c.
  34498.    ****************************************************************************/
  34499. }
  34500.  
  34501.  
  34502. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34503.  
  34504. Example of _uheap_check 
  34505.  
  34506.      _heap_check - Validate Default Memory Heap 
  34507.      _debug_ucalloc - Reserve and Initialize Memory from User Heap 
  34508.      _debug_umalloc - Reserve Memory Blocks from User Heap 
  34509.      _debug_realloc - Reallocate Memory Block 
  34510.      _debug_free - Release Memory 
  34511.      _uheapchk - Validate Memory Heap 
  34512.      _uheapset - Validate and Set Memory Heap 
  34513.      _uheap_walk - Return Information about Memory Heap 
  34514.      "Managing Memory" in the Programming Guide 
  34515.      "Debugging Your Heaps" in the Programming Guide 
  34516.      <umalloc.h> 
  34517.  
  34518.  
  34519. ΓòÉΓòÉΓòÉ 4.339. _uheapchk - Validate Memory Heap ΓòÉΓòÉΓòÉ
  34520.  
  34521.  
  34522. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34523.  
  34524. #include <umalloc.h>
  34525. int _uheapchk(Heap_t heap);
  34526.  
  34527.  
  34528. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34529.  
  34530. Language Level:  Extension 
  34531.  
  34532. _uheapchk checks the heap you specify for minimal consistency by checking all 
  34533. allocated and freed objects on the heap. 
  34534.  
  34535. _uheapchk works just like _heapchk, except that you specify the heap to check; 
  34536. _heapchk always checks the default heap. 
  34537.  
  34538. Note:  Using the _uheapchk, _uheapset, and _uheap_walk functions (and their 
  34539. equivalents for the default heap) may add overhead to each object allocated 
  34540. from the heap. 
  34541.  
  34542. Return Value 
  34543. _uheapchk returns one of the following values, defined in both <umalloc.h> and 
  34544. <malloc.h>: 
  34545.  
  34546.  _HEAPBADBEGIN     The heap specifed is not valid.  It may have been closed or 
  34547.                    destroyed. 
  34548.  _HEAPBADNODE      A memory node is corrupted, or the heap is damaged. 
  34549.  _HEAPEMPTY        The heap has not been initialized. 
  34550.  _HEAPOK           The heap appears to be consistent. 
  34551.  
  34552.  
  34553. ΓòÉΓòÉΓòÉ <hidden> Example of _uheapchk ΓòÉΓòÉΓòÉ
  34554.  
  34555. /************************************************************************
  34556.  
  34557. This example creates a heap and performs memory operations on it.  It then 
  34558. calls _uheapchk to validate the heap. 
  34559.  
  34560. ************************************************************************/
  34561.  
  34562. #include <stdlib.h>
  34563. #include <stdio.h>
  34564. #include <umalloc.h>
  34565.  
  34566. int main(void)
  34567. {
  34568.    Heap_t  myheap;
  34569.    char    *ptr;
  34570.    int     rc;
  34571.  
  34572.    /* Use default heap as user heap */
  34573.    myheap = _udefault(NULL);
  34574.  
  34575.    if (NULL == (ptr = _ucalloc(myheap, 100, 1))) {
  34576.       puts("Cannot allocate memory from user heap.");
  34577.       exit(EXIT_FAILURE);
  34578.    }
  34579.    *(ptr - 1) = 'x';     /* overwrite storage that was not allocated */
  34580.  
  34581.    if (_HEAPOK != (rc = _uheapchk(myheap))) {
  34582.       switch(rc) {
  34583.          case _HEAPEMPTY:
  34584.             puts("The heap has not been initialized.");
  34585.             break;
  34586.          case _HEAPBADNODE:
  34587.             puts("A memory node is corrupted or the heap is damaged.");
  34588.             break;
  34589.          case _HEAPBADBEGIN:
  34590.             puts("The heap specified is not valid.");
  34591.             break;
  34592.       }
  34593.       exit(rc);
  34594.    }
  34595.    free(ptr);
  34596.    return 0;
  34597.  
  34598.    /****************************************************************************
  34599.       The output should be similar to :
  34600.  
  34601.       A memory node is corrupted or the heap is damaged.
  34602.    ****************************************************************************/
  34603. }
  34604.  
  34605.  
  34606. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34607.  
  34608. Example of _uheapchk 
  34609.  
  34610.      _heapchk - Validate Default Memory Heap 
  34611.      _heapmin - Release Unused Memory from Default Heap 
  34612.      _uheapset - Validate and Set Memory Heap 
  34613.      _uheap_walk - Return Information about Memory Heap 
  34614.      "Managing Memory" in the Programming Guide 
  34615.      "Debugging Your Heaps" in the Programming Guide 
  34616.      <umalloc.h> 
  34617.  
  34618.  
  34619. ΓòÉΓòÉΓòÉ 4.340. _uheapmin - Release Unused Memory in User Heap ΓòÉΓòÉΓòÉ
  34620.  
  34621.  
  34622. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34623.  
  34624. #include <umalloc.h>
  34625. int _uheapmin(Heap_t heap);
  34626.  
  34627.  
  34628. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34629.  
  34630. Language Level:  Extension 
  34631.  
  34632. _uheapmin returns all unused memory blocks from the heap you specify to the 
  34633. operating system. 
  34634.  
  34635. _uheapmin works just like _heapmin, except that you specify the heap to use; 
  34636. _heapmin always uses the default heap. A debug version of this function, 
  34637. _debug_uheapmin, is also provided. 
  34638.  
  34639. To return the memory, _uheapmin calls the release_fn you supplied when you 
  34640. created the heap with _ucreate. If you did not supply a release_fn, _uheapmin 
  34641. has no effect and simply returns 0. 
  34642.  
  34643. Return Value 
  34644. If successful, _uheapmin returns 0. A nonzero return value indicates failure. 
  34645. Passing _uheapmin a heap that is not valid has undefined results. 
  34646.  
  34647.  
  34648. ΓòÉΓòÉΓòÉ <hidden> Example of _uheapmin ΓòÉΓòÉΓòÉ
  34649.  
  34650. /************************************************************************
  34651.  
  34652. This example creates a heap and then allocates and frees a large block of 
  34653. memory from it. It then calls _uheapmin to return free blocks of memory to the 
  34654. system. 
  34655.  
  34656. ************************************************************************/
  34657.  
  34658. #include <stdio.h>
  34659. #include <stdlib.h>
  34660.  
  34661. int main(void)
  34662. {
  34663.    if (_heapmin())
  34664.       printf("_heapmin failed.\n");
  34665.    else
  34666.       printf("_heapmin was successful.\n");
  34667.    return 0;
  34668.  
  34669.    /****************************************************************************
  34670.       The output should be:
  34671.  
  34672.      _heapmin was successful.
  34673.    ****************************************************************************/
  34674. }
  34675.  
  34676.  
  34677. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34678.  
  34679. Example of _heapmin 
  34680.  
  34681.      _heapmin - Release Unused Memory from Default Heap 
  34682.      _debug_uheapmin - Release Unused Memory in User Heap 
  34683.      _theapmin - Release Unused Tiled Memory 
  34684.      _ucreate - Create a Memory Heap 
  34685.      Differentiating between Memory Management Functions 
  34686.      "Managing Memory" in the Programming Guide 
  34687.      "Debugging Your Heaps" in the Programming Guide 
  34688.      <umalloc.h> 
  34689.  
  34690.  
  34691. ΓòÉΓòÉΓòÉ 4.341. _uheapset - Validate and Set Memory Heap ΓòÉΓòÉΓòÉ
  34692.  
  34693.  
  34694. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34695.  
  34696. #include <umalloc.h>
  34697. int _heapset(Heap_t heap, unsigned int fill);
  34698.  
  34699.  
  34700. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34701.  
  34702. Language Level:  Extension 
  34703.  
  34704. _uheapset checks the heap you specify for minimal consistency by checking all 
  34705. allocated and freed objects on the heap (similar to _uheapchk). It then sets 
  34706. each byte of the heap's free objects to the value of fill. 
  34707.  
  34708. Using _uheapset can help you locate problems where your program continues to 
  34709. use a freed pointer to an object.  After you set the free heap to a specific 
  34710. value, when your program tries to interpret the set values in the freed object 
  34711. as data, unexpected results occur, indicating a problem. 
  34712.  
  34713. _uheapset works just like _heapset, except that you specify the heap to check; 
  34714. _heapset always checks the default heap. 
  34715.  
  34716. Note:  Using the _uheapchk, _uheapset, and _uheap_walk functions (and their 
  34717. equivalents for the default heap) may add overhead to each object allocated 
  34718. from the heap. 
  34719.  
  34720. Return Value 
  34721. _uheapset returns one of the following values, defined in both <umalloc.h> and 
  34722. <malloc.h>: 
  34723.  
  34724.  _HEAPBADBEGIN     The heap specified is not valid.  It may have been closed or 
  34725.                    destroyed. 
  34726.  _HEAPBADNODE      A memory node is corrupted, or the heap is damaged. 
  34727.  _HEAPEMPTY        The heap has not been initialized. 
  34728.  _HEAPOK           The heap appears to be consistent. 
  34729.  
  34730.  
  34731. ΓòÉΓòÉΓòÉ <hidden> Example of _uheapset ΓòÉΓòÉΓòÉ
  34732.  
  34733. /************************************************************************
  34734.  
  34735. This example creates a heap and allocates and frees memory from it.  It then 
  34736. calls _uheapset to set the freed memory to a value. 
  34737.  
  34738. ************************************************************************/
  34739.  
  34740. #include <stdlib.h>
  34741. #include <stdio.h>
  34742. #include <malloc.h>
  34743.  
  34744. int main (void)
  34745. {
  34746.    char  *ptr;
  34747.    int   rc;
  34748.  
  34749.    if (NULL == (ptr = malloc(10))) {
  34750.       puts("Could not allocate memory block.");
  34751.       exit(EXIT_FAILURE);
  34752.    }
  34753.    memset(ptr,'A',5);
  34754.    free(ptr);
  34755.  
  34756.    if (_HEAPOK != (rc = _heapset('X'))) {
  34757.       switch(rc) {
  34758.          case _HEAPEMPTY:
  34759.             puts("The heap has not been initialized.");
  34760.             break;
  34761.          case _HEAPBADNODE:
  34762.             puts("A memory node is corrupted or the heap is damaged.");
  34763.             break;
  34764.          case _HEAPBADBEGIN:
  34765.             puts("The heap specified is not valid.");
  34766.             break;
  34767.       }
  34768.       exit(rc);
  34769.    }
  34770.    return 0;
  34771. }
  34772.  
  34773.  
  34774. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34775.  
  34776. Example of _heapset 
  34777.  
  34778.      _heapmin - Release Unused Memory from Default Heap 
  34779.      _heapset - Validate and Set Default Heap 
  34780.      _uheapchk - Validate Memory Heap 
  34781.      _uheap_walk - Return Information about Memory Heap 
  34782.      "Managing Memory" in the Programming Guide 
  34783.      "Debugging Your Heaps" in the Programming Guide 
  34784.      <umalloc.h> 
  34785.  
  34786.  
  34787. ΓòÉΓòÉΓòÉ 4.342. _uheap_walk - Return Information about Memory Heap ΓòÉΓòÉΓòÉ
  34788.  
  34789.  
  34790. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34791.  
  34792. #include <umalloc.h>
  34793. int _uheap_walk(Heap_t heap, int (*callback_fn)(const void *object,
  34794.                      size_t size, int flag, int status,
  34795.                      const char* file, int line) );
  34796.  
  34797.  
  34798. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34799.  
  34800. Language Level:  Extension 
  34801.  
  34802. _uheap_walk traverses the heap you specify, and, for each allocated or freed 
  34803. object, it calls the callback_fn function that you provide. _uheap_walk works 
  34804. just like _heap_walk, except that you specify the heap to be traversed; 
  34805. _heap_walk always traverses the default heap. 
  34806.  
  34807. For each object, _uheap_walk passes your function: 
  34808.  
  34809.  object    A pointer to the object. 
  34810.  size      The size of the object. 
  34811.  flag      The value _USEDENTRY, if the object is currently allocated, or 
  34812.            _FREEENTRY, if the object has been freed.  (Both values are defined 
  34813.            in <malloc.h>.) 
  34814.  status    One of the following values, defined in both <umalloc.h> and 
  34815.            <malloc.h>, depending on the status of the object: 
  34816.            _HEAPBADBEGIN          The heap specified is not valid.  It may have 
  34817.                                   been closed or destroyed. 
  34818.            _HEAPBADNODE           A memory node is corrupted, or the heap is 
  34819.                                   damaged. 
  34820.            _HEAPEMPTY             The heap has not been initialized. 
  34821.            _HEAPOK                The heap appears to be consistent. 
  34822.  file      The name of the file where the object was allocated or freed. 
  34823.  line      The line where the object was allocated or freed. 
  34824.  
  34825.  _uheap_walk provides information about all objects, regardless of which memory 
  34826.  management functions were used to allocate them. However, the file and line 
  34827.  information are only available if the object was allocated and freed using the 
  34828.  debug versions of the memory management functions.  Otherwise, file is NULL 
  34829.  and line is 0. 
  34830.  
  34831.  _uheap_walk calls callback_fn for each object until one of the following 
  34832.  occurs: 
  34833.  
  34834.      All objects have been traversed. 
  34835.      callback_fn returns a nonzero value to _heap_walk. 
  34836.      It cannot continue because of a problem with the heap. 
  34837.  
  34838.  You may want to code your callback_fn to return a nonzero value if the status 
  34839.  of the object is not _HEAPOK. Even if callback_fn returns 0 for an object that 
  34840.  is corrupted, _heap_walk cannot continue because of the state of the heap and 
  34841.  returns to its caller. 
  34842.  
  34843.  You can use callback_fn to process information from _uheap_walk in various 
  34844.  ways. For example, you may want to print the information to a file, or use it 
  34845.  to generate your own error messages. You can use the information to look for 
  34846.  memory leaks and objects incorrectly allocated or freed from the heap. It can 
  34847.  be especially useful to call _uheap_walk when _uheapchk returns an error. 
  34848.  
  34849.  Note: 
  34850.  
  34851.    1. Using the _uheapchk, _uheapset, and _uheap_walk functions (and their 
  34852.       equivalents for the default heap) may add overhead to each object 
  34853.       allocated from the heap 
  34854.  
  34855.    2. _uheap_walk locks the heap while it traverses it, to ensure that no other 
  34856.       operations use the heap until _uheap_walk finishes. As a result, in your 
  34857.       callback_fn, you cannot call any critical functions in the runtime 
  34858.       library, either explicitly or by calling another function that calls a 
  34859.       critical function. See the Programming Guide for a list of critical 
  34860.       functions. 
  34861.  
  34862.  Return Value 
  34863.  _uheap_walk returns the last value of status to the caller. 
  34864.  
  34865.  
  34866. ΓòÉΓòÉΓòÉ <hidden> Example of _uheap_walk ΓòÉΓòÉΓòÉ
  34867.  
  34868. /************************************************************************
  34869.  
  34870. This example creates a heap and performs memory operations on it.  _uheap_walk 
  34871. then traverses the heap and calls callback_function for each memory object. The 
  34872. callback_function prints a message about each memory block. 
  34873.  
  34874. ************************************************************************/
  34875.  
  34876. #include <stdlib.h>
  34877. #include <stdio.h>
  34878. #include <umalloc.h>
  34879.  
  34880. int callback_function(const void *pentry, size_t sz, int useflag, int status,
  34881.                       const char *filename, size_t line)
  34882. {
  34883.    if (_HEAPOK != status) {
  34884.       puts("status is not _HEAPOK.");
  34885.       exit(status);
  34886.    }
  34887.    if (_USEDENTRY == useflag)
  34888.       printf("allocated  %p     %u\n", pentry, sz);
  34889.    else
  34890.       printf("freed      %p     %u\n", pentry, sz);
  34891.    return 0;
  34892. }
  34893.  
  34894. int main(void)
  34895. {
  34896.    Heap_t  myheap;
  34897.    char    *p1, *p2, *p3;
  34898.  
  34899.    /* User default heap as user heap */
  34900.    myheap = _udefault(NULL);
  34901.  
  34902.    if (NULL == (p1 = _umalloc(myheap, 100)) ||
  34903.        NULL == (p2 = _umalloc(myheap, 200)) ||
  34904.        NULL == (p3 = _umalloc(myheap, 300))) {
  34905.       puts("Cannot allocate memory from user heap.");
  34906.       exit(EXIT_FAILURE);
  34907.    }
  34908.    free(p2);
  34909.    puts("usage      address   size\n-----      -------   ----");
  34910.  
  34911.    _uheap_walk(myheap, callback_function);
  34912.  
  34913.    free(p1);
  34914.    free(p3);
  34915.    return 0;
  34916.  
  34917.    /****************************************************************************
  34918.       The output should be similar to :
  34919.  
  34920.       usage      address   size
  34921.       -----      -------   ----
  34922.       allocated  73A20     300
  34923.       allocated  738C0     100
  34924.        :
  34925.        :
  34926.       freed      73930     224
  34927.    ****************************************************************************/
  34928. }
  34929.  
  34930.  
  34931. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  34932.  
  34933. Example of _uheap_walk 
  34934.  
  34935.      _heapmin - Release Unused Memory from Default Heap 
  34936.      _heap_walk - Return Information about Default Heap 
  34937.      _uheapchk - Validate Memory Heap 
  34938.      _uheapset - Validate and Set Memory Heap 
  34939.      "Managing Memory" in the Programming Guide 
  34940.      "Debugging Your Heaps" in the Programming Guide 
  34941.      <umalloc.h> 
  34942.  
  34943.  
  34944. ΓòÉΓòÉΓòÉ 4.343. _ultoa - Convert Unsigned Long Integer to String ΓòÉΓòÉΓòÉ
  34945.  
  34946.  
  34947. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  34948.  
  34949. #include <stdlib.h>
  34950. char *_ultoa(unsigned long value, char *string, int radix);
  34951.  
  34952.  
  34953. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  34954.  
  34955. Language Level:  Extension 
  34956.  
  34957. _ultoa converts the digits of the given unsigned long value to a 
  34958. null-terminated character string and stores the result in string. No overflow 
  34959. checking is performed. The radix argument specifies the base of value; it must 
  34960. be in the range of 2 through 36. 
  34961.  
  34962. The space allocated for string must be large enough to hold the returned 
  34963. string. The function can return up to 33 bytes, including the null character 
  34964. (\0). 
  34965.  
  34966. Return Value 
  34967. _ultoa returns a pointer to string. There is no error return value. 
  34968.  
  34969.  
  34970. ΓòÉΓòÉΓòÉ <hidden> Example of _ultoa ΓòÉΓòÉΓòÉ
  34971.  
  34972. /************************************************************************
  34973.  
  34974. This example converts the digits of the value 255 to decimal, binary, and 
  34975. hexadecimal representations. 
  34976.  
  34977. ************************************************************************/
  34978.  
  34979. #include <stdio.h>
  34980. #include <stdlib.h>
  34981.  
  34982. int main(void)
  34983. {
  34984.    char buffer[35];
  34985.    char *p;
  34986.  
  34987.    p = _ltoa(-255L, buffer, 10);
  34988.    printf("The result of _ltoa(-255) with radix of 10 is %s\n", p);
  34989.    p = _ltoa(-255L, buffer, 2);
  34990.    printf("The result of _ltoa(-255) with radix of 2\n    is %s\n", p);
  34991.    p = _ltoa(-255L, buffer, 16);
  34992.    printf("The result of _ltoa(-255) with radix of 16 is %s\n", p);
  34993.    return 0;
  34994.  
  34995.    /****************************************************************************
  34996.       The output should be:
  34997.  
  34998.       The result of _ltoa(-255) with radix of 10 is -255
  34999.       The result of _ltoa(-255) with radix of 2
  35000.           is 11111111111111111111111100000001
  35001.       The result of _ltoa(-255) with radix of 16 is ffffff01
  35002.    ****************************************************************************/
  35003. }
  35004.  
  35005.  
  35006. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35007.  
  35008. Example of _ultoa 
  35009.  
  35010.      _ecvt - Convert Floating-Point to Character 
  35011.      _fcvt - Convert Floating-Point to String 
  35012.      _gcvt - Convert Floating-Point to String 
  35013.      _itoa - Convert Integer to String 
  35014.      _ltoa - Convert Long Integer to String 
  35015.      <stdlib.h> 
  35016.  
  35017.  
  35018. ΓòÉΓòÉΓòÉ 4.344. _umalloc - Reserve Memory Blocks from User Heap ΓòÉΓòÉΓòÉ
  35019.  
  35020.  
  35021. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35022.  
  35023. #include <umalloc.h>
  35024. void *_umalloc(Heap_t heap, size_t size);
  35025.  
  35026.  
  35027. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35028.  
  35029. Language Level:  Extension 
  35030.  
  35031. _umalloc allocates a memory block of size bytes from the heap you specify. 
  35032. Unlike _ucalloc, _umalloc does not initialize all bits to 0. 
  35033.  
  35034. _umalloc works just like malloc, except that you specify the heap to use; 
  35035. malloc always allocates from the default heap.  A debug version of this 
  35036. function, _debug_umalloc, is also provided. 
  35037.  
  35038. If the heap does not have enough memory for the request, _umalloc calls the 
  35039. getmore_fn that you specified when you created the heap with _ucreate. 
  35040.  
  35041. To reallocate or free memory allocated with _umalloc, use the non-heap-specific 
  35042. realloc and free. These functions always check what heap the memory was 
  35043. allocated from. 
  35044.  
  35045. Return Value 
  35046. _umalloc returns a pointer to the reserved space. If size was specified as 0, 
  35047. or if your getmore_fn cannot provide enough memory, _umalloc returns NULL. 
  35048. Passing _umalloc a heap that is not valid results in undefined behavior. 
  35049.  
  35050.  
  35051. ΓòÉΓòÉΓòÉ <hidden> Example of _umalloc ΓòÉΓòÉΓòÉ
  35052.  
  35053. /************************************************************************
  35054.  
  35055. This example creates a heap and uses _umalloc to allocate memory from the heap. 
  35056.  
  35057. ************************************************************************/
  35058.  
  35059. #include <stdlib.h>
  35060. #include <stdio.h>
  35061. #include <umalloc.h>
  35062.  
  35063. int main(void)
  35064. {
  35065.    Heap_t  myheap;
  35066.    char    *ptr;
  35067.  
  35068.    /* Use default heap as user heap */
  35069.    myheap = _udefault(NULL);
  35070.  
  35071.    if (NULL == (ptr = _umalloc(myheap, 100))) {
  35072.       puts("Cannot allocate memory from user heap.");
  35073.       exit(EXIT_FAILURE);
  35074.    }
  35075.    free(ptr);
  35076.    return 0;
  35077. }
  35078.  
  35079.  
  35080. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35081.  
  35082. Example of _umalloc 
  35083.  
  35084.      calloc - Reserve and Initialize Storage 
  35085.      _debug_umalloc - Reserve Memory Blocks from User Heap 
  35086.      free - Release Storage Blocks 
  35087.      malloc - Reserve Storage Block 
  35088.      realloc - Change Reserved Storage Block Size 
  35089.      _ucalloc - Reserve and Initialize Memory from User Heap 
  35090.      _ucreate - Create a Memory Heap 
  35091.      "Managing Memory" in the Programming Guide 
  35092.      <umalloc.h> 
  35093.  
  35094.  
  35095. ΓòÉΓòÉΓòÉ 4.345. umask - Sets File Mask of Current Process ΓòÉΓòÉΓòÉ
  35096.  
  35097.  
  35098. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35099.  
  35100. #include <io.h>
  35101. #include <sys\stat.h>
  35102. int umask(int pmode);
  35103.  
  35104.  
  35105. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35106.  
  35107. Language Level:  XPG4, Extension 
  35108.  
  35109. umask sets the file permission mask of the environment for the currently 
  35110. running process to the mode specified by pmode. The file permission mask 
  35111. modifies the permission setting of new files created by creat, open, or _sopen. 
  35112.  
  35113. If a bit in the mask is 1, the corresponding bit in the requested permission 
  35114. value of the file is set to 0 (disallowed).  If a bit in the mask is 0, the 
  35115. corresponding bit is left unchanged.  The permission setting for a new file is 
  35116. not set until the file is closed for the first time. 
  35117.  
  35118. The possible values for pmode are defined in <sys\stat.h>: 
  35119.  
  35120.  Value                   Meaning 
  35121.  S_IREAD                 No effect 
  35122.  S_IWRITE                Writing not permitted 
  35123.  S_IREAD | S_IWRITE      Writing not permitted. 
  35124.  
  35125.  If the write bit is set in the mask, any new files will be read-only. You 
  35126.  cannot give write-only permission, meaning that setting the read bit has no 
  35127.  effect. 
  35128.  
  35129.  Note:  In earlier releases of C Set ++, umask began with an underscore 
  35130.  (_umask). Because it is defined by the X/Open standard, the underscore has 
  35131.  been removed. For compatibility, VisualAge C++ will map _umask to umask for 
  35132.  you. 
  35133.  
  35134.  Return Value 
  35135.  umask returns the previous value of pmode. A return value of -1 indicates that 
  35136.  the value used for pmode was not valid, and errno is set to EINVAL. 
  35137.  
  35138.  
  35139. ΓòÉΓòÉΓòÉ <hidden> Example of umask ΓòÉΓòÉΓòÉ
  35140.  
  35141. /************************************************************************
  35142.  
  35143. This example sets the permission mask to create a write-only file. 
  35144.  
  35145. ************************************************************************/
  35146.  
  35147. #include <sys\stat.h>
  35148. #include <io.h>
  35149. #include <stdio.h>
  35150.  
  35151. int main(void)
  35152. {
  35153.    int oldMask;
  35154.  
  35155.    oldMask = umask(S_IWRITE);
  35156.    printf("\nDefault system startup mask is %d.\n", oldMask);
  35157.    return 0;
  35158.  
  35159.    /****************************************************************************
  35160.       The output should be:
  35161.  
  35162.       Default system startup mask is 0.
  35163.    ****************************************************************************/
  35164. }
  35165.  
  35166.  
  35167. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35168.  
  35169. Example of umask 
  35170.  
  35171.      chmod - Change File Permission Setting 
  35172.      creat - Create New File 
  35173.      open - Open File 
  35174.      _sopen - Open Shared File 
  35175.      <io.h> 
  35176.      <sys\stat.h> 
  35177.  
  35178.  
  35179. ΓòÉΓòÉΓòÉ 4.346. ungetc - Push Character onto Input Stream ΓòÉΓòÉΓòÉ
  35180.  
  35181.  
  35182. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35183.  
  35184. #include <stdio.h>
  35185. int ungetc(int c, FILE *stream);
  35186.  
  35187.  
  35188. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35189.  
  35190. Language Level: ANSI, SAA, POSIX, XPG4 
  35191.  
  35192. ungetc pushes the unsigned character c back onto the given input stream. 
  35193. However, only one sequential character is guaranteed to be pushed back onto the 
  35194. input stream if you call ungetc consecutively. The stream must be open for 
  35195. reading.  A subsequent read operation on the stream starts with c. The 
  35196. character c cannot be the EOF character. 
  35197.  
  35198. Characters placed on the stream by ungetc will be erased if fseek, fsetpos, 
  35199. rewind, or fflush is called before the character is read from the stream. 
  35200.  
  35201. Return Value 
  35202. ungetc returns the integer argument c converted to an unsigned char, or EOF if 
  35203. c cannot be pushed back. 
  35204.  
  35205.  
  35206. ΓòÉΓòÉΓòÉ <hidden> Example of ungetc ΓòÉΓòÉΓòÉ
  35207.  
  35208. /************************************************************************
  35209.  
  35210. In this example, the while statement reads decimal digits from an input data 
  35211. stream by using arithmetic statements to composethe numeric values of the 
  35212. numbers as it reads them. When a nondigit character appears before the end of 
  35213. the file, ungetc replaces it in the input stream so that later input functions 
  35214. can process it. 
  35215.  
  35216. ************************************************************************/
  35217.  
  35218. #include <stdio.h>
  35219. #include <ctype.h>
  35220.  
  35221. int main(void)
  35222. {
  35223.    int ch;
  35224.    unsigned int result = 0;
  35225.  
  35226.    while (EOF != (ch = getc(stdin)) && isdigit(ch))
  35227.       result = result * 10 + ch -'0';
  35228.    if (EOF != ch)
  35229.       /* Push back the nondigit character onto the input stream               */
  35230.       ungetc(ch, stdin);
  35231.  
  35232.    printf("Input number : %d\n", result);
  35233.    return 0;
  35234.  
  35235.    /****************************************************************************
  35236.       For the following input:
  35237.  
  35238.       12345s
  35239.  
  35240.       The output should be:
  35241.  
  35242.       Input number : 12345
  35243.    ****************************************************************************/
  35244. }
  35245.  
  35246.  
  35247. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35248.  
  35249. Example of ungetc 
  35250.  
  35251.      getc - getchar - Read a Character 
  35252.      fflush - Write Buffer to File 
  35253.      fseek - Reposition File Position 
  35254.      fsetpos - Set File Position 
  35255.      putc - putchar - Write a Character 
  35256.      rewind - Adjust Current File Position 
  35257.      _ungetch - Push Character Back to Keyboard 
  35258.      <stdio.h> 
  35259.  
  35260.  
  35261. ΓòÉΓòÉΓòÉ 4.347. _ungetch - Push Character Back to Keyboard ΓòÉΓòÉΓòÉ
  35262.  
  35263.  
  35264. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35265.  
  35266. #include <conio.h>
  35267. int _ungetch(int c);
  35268.  
  35269.  
  35270. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35271.  
  35272. Language Level:  Extension 
  35273.  
  35274. _ungetch pushes the character c back to the keyboard, causing c to be the next 
  35275. character read. _ungetch fails if called more than once before the next read 
  35276. operation. The character c cannot be the EOF character. 
  35277.  
  35278. Return Value 
  35279. If successful, _ungetch returns the character c. A return value of EOF 
  35280. indicates an error. 
  35281.  
  35282.  
  35283. ΓòÉΓòÉΓòÉ <hidden> Example of _ungetch ΓòÉΓòÉΓòÉ
  35284.  
  35285. /************************************************************************
  35286.  
  35287. This example uses _getch to read a string delimited by the character 'x'.  It 
  35288. then calls _ungetch to return the delimiter to the keyboard buffer. Other input 
  35289. routines can then process the delimiter. 
  35290.  
  35291. ************************************************************************/
  35292.  
  35293. #include <conio.h>
  35294. #include <stdio.h>
  35295.  
  35296. int main(void)
  35297. {
  35298.    int ch;
  35299.  
  35300.    printf("Type in some letters.\n");
  35301.    printf("If you type in an 'x', the program ends.\n");
  35302.    for (; ; ) {
  35303.       ch = _getch();
  35304.       if ('x' == ch) {
  35305.          _ungetch(ch);
  35306.          break;
  35307.       }
  35308.       _putch(ch);
  35309.    }
  35310.    ch = _getch();
  35311.    printf("\nThe last character was '%c'.", ch);
  35312.    return 0;
  35313.  
  35314.    /****************************************************************************
  35315.       Here is the output from a sample run:
  35316.  
  35317.       Type in some letters.
  35318.       If you type in an 'x', the program ends.
  35319.       One Two Three Four Five Si
  35320.       The last character was 'x'.
  35321.    ****************************************************************************/
  35322. }
  35323.  
  35324.  
  35325. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35326.  
  35327. Example of _ungetch 
  35328.  
  35329.      _cscanf - Read Data from Keyboard 
  35330.      _getch - _getche - Read Character from Keyboard 
  35331.      _putch - Write Character to Screen 
  35332.      ungetc - Push Character onto Input Stream 
  35333.      <conio.h> 
  35334.  
  35335.  
  35336. ΓòÉΓòÉΓòÉ 4.348. ungetwc - Push Wide Character onto Input Stream ΓòÉΓòÉΓòÉ
  35337.  
  35338.  
  35339. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35340.  
  35341. #include <stdio.h>
  35342. #include <wchar.h>
  35343. wint_t ungetwc(wint_t wc, FILE *stream);
  35344.  
  35345.  
  35346. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35347.  
  35348. Language Level:  XPG4 
  35349.  
  35350. ungetwc pushes the wide character by wc back onto the input stream. The 
  35351. pushed-back wide characters will be returned by subsequent reads on that stream 
  35352. in the reverse order of their pushing. A successful intervening call (on the 
  35353. stream) to a file positioning function (fseek, fsetpos, or rewind) discards any 
  35354. pushed-back wide characters for the stream. 
  35355.  
  35356. The external storage corresponding to the stream is unchanged. There is always 
  35357. at least one wide character of push-back. 
  35358.  
  35359. If the value of wc is WEOF, the operation fails and the input stream is 
  35360. unchanged. 
  35361.  
  35362. A successful call to the ungetwc function clears the EOF indicator for the 
  35363. stream. The value of the file position indicator for the stream after reading 
  35364. or discarding all pushed-back wide characters is the same as it was before the 
  35365. wide characters were pushed back. 
  35366.  
  35367. For a text stream, the file position indicator is backed up by one wide 
  35368. character. This affects ftell, fflush, fseek (with SEEK_CUR), and fgetpos. 
  35369.  
  35370. For a binary stream, the position indicator is unspecified until all characters 
  35371. are read or discarded, unless the last character is pushed back, in which case 
  35372. the file position indicator is backed up by one wide character. This affects 
  35373. ftell, fseek (with SEEK_CUR), fgetpos, and fflush. 
  35374.  
  35375. After calling ungetwc, flush the buffer or reposition the stream pointer before 
  35376. calling a read function for the stream, unless EOF has been reached. After a 
  35377. read operation on the stream, flush the buffer or reposition the stream pointer 
  35378. before calling ungetwc. 
  35379.  
  35380. Note: 
  35381.  
  35382.    1. Under VisualAge C++, only 1 wide character may be pushed back. 
  35383.  
  35384.    2. The position on the stream after a successful call to ungetwc is one wide 
  35385.       character prior to the current position. 
  35386.  
  35387.  Return Value 
  35388.  ungetwc returns the wide character pushed back after conversion, or WEOF if 
  35389.  the operation fails. 
  35390.  
  35391.  
  35392. ΓòÉΓòÉΓòÉ <hidden> Example of ungetwc ΓòÉΓòÉΓòÉ
  35393.  
  35394. /************************************************************************
  35395.  
  35396. This example reads in wide characters from stream, and then calls ungetwc to 
  35397. push the characters back to the stream. 
  35398.  
  35399. ************************************************************************/
  35400.  
  35401. #include <wchar.h>
  35402. #include <stdio.h>
  35403. #include <stdlib.h>
  35404.  
  35405. int main(void)
  35406. {
  35407.    FILE         *stream;
  35408.    wint_t       wc;
  35409.    wint_t       wc2;
  35410.    unsigned int result = 0;
  35411.  
  35412.    if (NULL == (stream = fopen("ungetwc.dat", "r+"))) {
  35413.       printf("Unable to open file.\n");
  35414.       exit(EXIT_FAILURE);
  35415.    }
  35416.  
  35417.    while (WEOF != (wc = fgetwc(stream)) && iswdigit(wc))
  35418.       result = result * 10 + wc - L'0';
  35419.  
  35420.    if (WEOF != wc)
  35421.       ungetwc(wc, stream);    /* Push the nondigit wide character back */
  35422.  
  35423.    /* get the pushed back character */
  35424.    if (WEOF != (wc2 = fgetwc(stream))) {
  35425.       if (wc != wc2) {
  35426.          printf("Subsequent fgetwc does not get the pushed back character.\n");
  35427.          exit(EXIT_FAILURE);
  35428.       }
  35429.       printf("The digits read are '%i'\n"
  35430.              "The character being pushed back is '%lc'", result, wc2);
  35431.    }
  35432.    return 0;
  35433.  
  35434.    /****************************************************************************
  35435.       Assuming the file ungetwc.dat contains:
  35436.  
  35437.       12345ABCDE67890XYZ
  35438.  
  35439.       The output should be similar to :
  35440.  
  35441.       The digits read are '12345'
  35442.       The character being pushed back is 'A'
  35443.    ****************************************************************************/
  35444. }
  35445.  
  35446.  
  35447. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35448.  
  35449. Example of ungetwc 
  35450.  
  35451.      fflush - Write Buffer to File 
  35452.      fseek - Reposition File Position 
  35453.      fsetpos - Set File Position 
  35454.      getwc - Read Wide Character from Stream 
  35455.      putwc - Write Wide Character 
  35456.      ungetc - Push Character onto Input Stream 
  35457.      _ungetch - Push Character Back to Keyboard 
  35458.      <wchar.h> 
  35459.  
  35460.  
  35461. ΓòÉΓòÉΓòÉ 4.349. unlink - Delete File ΓòÉΓòÉΓòÉ
  35462.  
  35463.  
  35464. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35465.  
  35466. #include <stdio.h>  /* also in <io.h> */
  35467. int unlink(const char *pathname);
  35468.  
  35469.  
  35470. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35471.  
  35472. Language Level:  XPG4, Extension 
  35473.  
  35474. unlink deletes the file specified by pathname. 
  35475.  
  35476. Portability Note  For portability, use the ANSI/ISO function remove. instead of 
  35477. unlink. 
  35478.  
  35479. Note:  In earlier releases of C Set ++, unlink began with an underscore 
  35480. (_unlink). Because it is defined by the X/Open standard, the underscore has 
  35481. been removed. For compatibility, VisualAge C++ will map _unlink to unlink for 
  35482. you. 
  35483.  
  35484. Return Value 
  35485. unlink returns 0 if the file is successfully deleted. A return value of -1 
  35486. indicates an error, and errno is set to one of the following values: 
  35487.  
  35488.  Value          Meaning 
  35489.  EACCESS        The path name specifies a read-only file or a directory. 
  35490.  EISOPEN        The file is open. 
  35491.  ENOENT         An incorrect path name was specified, or the file or path name 
  35492.                 was not found. 
  35493.  
  35494.  
  35495. ΓòÉΓòÉΓòÉ <hidden> Example of unlink ΓòÉΓòÉΓòÉ
  35496.  
  35497. /************************************************************************
  35498.  
  35499. This example deletes the file tmpfile from the system or prints an error 
  35500. message if unable to delete it. 
  35501.  
  35502. ************************************************************************/
  35503.  
  35504. #include <stdio.h>
  35505.  
  35506. int main(void)
  35507. {
  35508.    if (-1 == unlink("tmpfile"))
  35509.       perror("Cannot delete tmpfile");
  35510.    else
  35511.       printf("tmpfile has been successfully deleted\n");
  35512.    return 0;
  35513.  
  35514.    /****************************************************************************
  35515.       If the file "tmpfile" exists, the output should be:
  35516.  
  35517.       tmpfile has been successfully deleted
  35518.    ****************************************************************************/
  35519. }
  35520.  
  35521.  
  35522. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35523.  
  35524. Example of unlink 
  35525.  
  35526.      remove - Delete File 
  35527.      _rmtmp - Remove Temporary Files 
  35528.      <stdio.h> 
  35529.  
  35530.  
  35531. ΓòÉΓòÉΓòÉ 4.350. _uopen - Open Heap for Use ΓòÉΓòÉΓòÉ
  35532.  
  35533.  
  35534. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35535.  
  35536. #include <umalloc.h>
  35537. int _uopen(Heap_t heap);
  35538.  
  35539.  
  35540. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35541.  
  35542. Language Level:  Extension 
  35543.  
  35544. _uopen allows the current process to use the heap you specify. If the heap is 
  35545. shared, you must call _uopen in each process that will allocate or free from 
  35546. the heap. See "Managing Memory" in the Programming Guide for more information 
  35547. about sharing heaps, and about creating and using heaps in general. 
  35548.  
  35549. Return Value 
  35550. If successful, _uopen returns 0. A nonzero return code indicates failure. 
  35551. Passing _uopen a heap that is not valid results in undefined behavior. 
  35552.  
  35553.  
  35554. ΓòÉΓòÉΓòÉ <hidden> Example of _uopen ΓòÉΓòÉΓòÉ
  35555.  
  35556. /************************************************************************
  35557.  
  35558. This example creates a fixed-size heap, then uses _uopen to open it.  The 
  35559. program then performs operations on the heap, and closes and destroys it. 
  35560.  
  35561. ************************************************************************/
  35562.  
  35563. #define  INCL_DOSMEMMGR             /* Memory Manager values */
  35564. #include <os2.h>
  35565. #include <bsememf.h>                /* Get flags for memory management  */
  35566. #include <stdlib.h>
  35567. #include <stdio.h>
  35568. #include <umalloc.h>
  35569.  
  35570. int main(void)
  35571. {
  35572.    void    *initial_block;
  35573.    APIRET  rc;
  35574.    Heap_t  myheap;
  35575.    char    *p;
  35576.  
  35577.    /* Call DosAllocMem to get the initial block of memory */
  35578.    if (0 != (rc = DosAllocMem(&initial_block, 65536,
  35579.                               PAG_WRITE | PAG_READ | PAG_COMMIT))) {
  35580.       printf("DosAllocMem error: return code = %ld\n", rc);
  35581.       exit(EXIT_FAILURE);
  35582.    }
  35583.    /* Create a fixed size heap starting with the block declared earlier */
  35584.    if (NULL == (myheap = _ucreate(initial_block, 65536, _BLOCK_CLEAN,
  35585.                                   _HEAP_REGULAR, NULL, NULL))) {
  35586.       puts("_ucreate failed.");
  35587.       exit(EXIT_FAILURE);
  35588.    }
  35589.    if (0 != _uopen(myheap)) {
  35590.       puts("_uopen failed.");
  35591.       exit(EXIT_FAILURE);
  35592.    }
  35593.    p = _umalloc(myheap, 100);
  35594.    free(p);
  35595.    if (0 != _uclose(myheap)) {
  35596.       puts("_uclose failed");
  35597.       exit(EXIT_FAILURE);
  35598.    }
  35599.    if (0 != (rc = DosFreeMem(initial_block))) {
  35600.       printf("DosFreeMem error: return code = %ld\n", rc);
  35601.       exit(EXIT_FAILURE);
  35602.    }
  35603.    return 0;
  35604. }
  35605.  
  35606.  
  35607. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35608.  
  35609. Example of _uopen 
  35610.  
  35611.      _uaddmem - Add Memory to a Heap 
  35612.      _uclose - Close Heap from Use 
  35613.      _ucreate - Create a Memory Heap 
  35614.      "Managing Memory" in the Programming Guide 
  35615.      <umalloc.h> 
  35616.  
  35617.  
  35618. ΓòÉΓòÉΓòÉ 4.351. _ustats - Get Information about Heap ΓòÉΓòÉΓòÉ
  35619.  
  35620.  
  35621. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35622.  
  35623. #include <umalloc.h>
  35624. int _ustats(Heap_t heap, _HEAPSTATS *hpinfo);
  35625.  
  35626.  
  35627. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35628.  
  35629. Language Level:  Extension 
  35630.  
  35631. _ustats gets information about the heap you specify and stores it in the hpinfo 
  35632. structure you pass to it. 
  35633.  
  35634. The _HEAPSTATS structure type is defined in <umalloc.h>. The members it 
  35635. contains and the information that _ustats stores in each is as follows: 
  35636.  
  35637.  _provided     How much memory the heap holds (excluding memory used for 
  35638.                overhead for the heap) 
  35639.  _used         How much memory is currently allocated from the heap 
  35640.  _tiled        Whether the memory is tiled (_tiled is 1) or not (_tiled is 0) 
  35641.  _shared       Whether the memory is shared (_shared is 1) or not (_shared is 
  35642.                0) 
  35643.  _maxfree      The size of the largest contiguous piece of memory available on 
  35644.                the heap 
  35645.  
  35646.  Return Value 
  35647.  If successful, _ustats returns 0. A nonzero return code indicates failure. 
  35648.  Passing _ustats a heap that is not valid results in undefined behavior. 
  35649.  
  35650.  
  35651. ΓòÉΓòÉΓòÉ <hidden> Example of _ustats ΓòÉΓòÉΓòÉ
  35652.  
  35653. /************************************************************************
  35654.  
  35655. This example creates a heap and allocates memory from it. It then calls _ustats 
  35656. to print out information about the heap. 
  35657.  
  35658. ************************************************************************/
  35659.  
  35660. #include <stdlib.h>
  35661. #include <stdio.h>
  35662. #include <umalloc.h>
  35663.  
  35664. int main(void)
  35665. {
  35666.    Heap_t      myheap;
  35667.    _HEAPSTATS  myheap_stat;
  35668.    char        *ptr;
  35669.  
  35670.    /* Use default heap as user heap */
  35671.    myheap = _udefault(NULL);
  35672.  
  35673.    if (NULL == (ptr = _umalloc(myheap, 100))) {
  35674.       puts("Cannot allocate memory from user heap.");
  35675.       exit(EXIT_FAILURE);
  35676.    }
  35677.    if (0 != _ustats(myheap, &myheap_stat)) {
  35678.       puts("_ustats failed.");
  35679.       exit(EXIT_FAILURE);
  35680.    }
  35681.    printf ("_provided: %u\n", myheap_stat._provided);
  35682.    printf ("_used    : %u\n", myheap_stat._used);
  35683.    printf ("_tiled   : %u\n", myheap_stat._tiled);
  35684.    printf ("_shared  : %u\n", myheap_stat._shared);
  35685.    printf ("_max_free: %u\n", myheap_stat._max_free);
  35686.    free(ptr);
  35687.    return 0;
  35688.  
  35689.    /****************************************************************************
  35690.       The output should be similar to :
  35691.  
  35692.       _provided: 65264
  35693.       _used    : 14304
  35694.       _tiled   : 0
  35695.       _shared  : 0
  35696.       _max_free: 50960
  35697.    ****************************************************************************/
  35698. }
  35699.  
  35700.  
  35701. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35702.  
  35703. Example of _ustats 
  35704.  
  35705.      _mheap - Query Memory Heap for Allocated Object 
  35706.      _ucreate - Create a Memory Heap 
  35707.      "Managing Memory" in the Programming Guide 
  35708.      <umalloc.h> 
  35709.  
  35710.  
  35711. ΓòÉΓòÉΓòÉ 4.352. utime - Set Modification Time ΓòÉΓòÉΓòÉ
  35712.  
  35713.  
  35714. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35715.  
  35716. #include <sys\utime.h>
  35717. #include <sys\types.h>
  35718. int utime(char *pathname, struct utimbuf *times);
  35719.  
  35720.  
  35721. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35722.  
  35723. Language Level:  XPG4, xtension 
  35724.  
  35725. utime sets the modification time for the file specified by pathname.  The 
  35726. process must have write access to the file;  otherwise, the time cannot be 
  35727. changed. 
  35728.  
  35729. Although the utimbuf structure contains a field for access time, only the 
  35730. modification time is set in the OS/2 operating system. If times is a NULL 
  35731. pointer, the modification time is set to the current time.  Otherwise, times 
  35732. must point to a structure of type utimbuf, defined in <sys\utime.h>.  The 
  35733. modification time is set from the modtime field in this structure. 
  35734.  
  35735. utime accepts only even numbers of seconds. If you enter an odd number of 
  35736. seconds, the function rounds it down. 
  35737.  
  35738. Note:  In earlier releases of C Set ++, utime began with an underscore 
  35739. (_utime). Because it is defined by the X/Open standard, the underscore has been 
  35740. removed. For compatibility, VisualAge C++ will map _utime to utime for you. 
  35741.  
  35742. Return Value 
  35743. utime returns 0 if the file modification time was changed.  A return value of 
  35744. -1 indicates an error, and errno is set to one of the following values: 
  35745.  
  35746.  Value          Meaning 
  35747.  EACCESS        The path name specifies a directory or read-only file. 
  35748.  EMFILE         There are too many open files.  You must open the file to 
  35749.                 change its modification time. 
  35750.  ENOENT         The file path name was not found, or the file name was 
  35751.                 incorrectly specified. 
  35752.  
  35753.  
  35754. ΓòÉΓòÉΓòÉ <hidden> Example of utime ΓòÉΓòÉΓòÉ
  35755.  
  35756. /************************************************************************
  35757.  
  35758. This example sets the last modification time of file utime.dat to the current 
  35759. time.  It prints an error message if it cannot. 
  35760.  
  35761. ************************************************************************/
  35762.  
  35763. #include <sys\types.h>
  35764. #include <sys\utime.h>
  35765. #include <sys\stat.h>
  35766. #include <stdio.h>
  35767. #include <stdlib.h>
  35768.  
  35769. #define  FILENAME      "utime.dat"
  35770.  
  35771. int main(void)
  35772. {
  35773.    struct utimbuf ubuf;
  35774.    struct stat statbuf;
  35775.    FILE *fp;                                              /* File pointer     */
  35776.  
  35777.    /* creating file, whose date will be changed by calling utime              */
  35778.    fp = fopen(FILENAME, "w");
  35779.  
  35780.    /* write Hello World in the file                                           */
  35781.    fprintf(fp, "Hello World\n");
  35782.  
  35783.    /* close file                                                              */
  35784.    fclose(fp);
  35785.  
  35786.    /* seconds to current date from 1970 Jan 1                                 */
  35787.    /* Fri Dec 31 23:59:58 1999                                                */
  35788.    ubuf.modtime = 946702799;
  35789.  
  35790.    /* changing file modification time                                         */
  35791.    if (-1 == utime(FILENAME, &ubuf)) {
  35792.       perror("utime failed");
  35793.       remove(FILENAME);
  35794.       return EXIT_FAILURE;
  35795.    }
  35796.  
  35797.    /* display the modification time                                           */
  35798.    if (0 == stat(FILENAME, &statbuf))
  35799.       printf("The file modification time is %s", ctime(&statbuf.st_mtime));
  35800.    else
  35801.       printf("File could not be found\n");
  35802.    remove(FILENAME);
  35803.    return 0;
  35804.  
  35805.    /****************************************************************************
  35806.       The output should be:
  35807.  
  35808.       The file modification time is Fri Dec 31 23:59:58 1999
  35809.    ****************************************************************************/
  35810. }
  35811.  
  35812.  
  35813. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35814.  
  35815. Example of utime 
  35816.  
  35817.      fstat - Information about Open File 
  35818.      stat - Get Information about File or Directory 
  35819.      <sys\utime.h> 
  35820.      <sys\types.h> 
  35821.  
  35822.  
  35823. ΓòÉΓòÉΓòÉ 4.353. va_arg - va_end - va_start - Access Function Arguments ΓòÉΓòÉΓòÉ
  35824.  
  35825.  
  35826. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35827.  
  35828. #include <stdarg.h>
  35829. var_type va_arg(va_list arg_ptr, var_type);
  35830. void va_end(va_list arg_ptr);
  35831. void va_start(va_list arg_ptr, variable_name);
  35832.  
  35833.  
  35834. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35835.  
  35836. Language Level:  ANSI, SAA 
  35837.  
  35838. va_arg, va_end, and va_start access the arguments to a function when it takes a 
  35839. fixed number of required arguments and a variable number of optional arguments. 
  35840. All three of these are macros. You declare required arguments as ordinary 
  35841. parameters to the function and access the arguments through the parameter 
  35842. names. 
  35843.  
  35844. va_start initializes the arg_ptr pointer for subsequent calls to va_arg and 
  35845. va_end. 
  35846.  
  35847. The argument variable_name is the identifier of the rightmost named parameter 
  35848. in the parameter list (preceding , ...). Use va_start before va_arg. 
  35849. Corresponding va_start and va_end macros must be in the same function. 
  35850.  
  35851. va_arg retrieves a value of the given var_type from the location given by 
  35852. arg_ptr, and increases arg_ptr to point to the next argument in the list. 
  35853. va_arg can retrieve arguments from the list any number of times within the 
  35854. function. The var_type argument must be one of int, long, double, struct, 
  35855. union, or pointer, or a typedef of one of these types. 
  35856.  
  35857. va_end is needed to indicate the end of parameter scanning. 
  35858.  
  35859. Return Value 
  35860. va_arg returns the current argument. va_end and va_start do not return a value. 
  35861.  
  35862.  
  35863. ΓòÉΓòÉΓòÉ <hidden> Example of va_arg - va_end - va_start ΓòÉΓòÉΓòÉ
  35864.  
  35865. /************************************************************************
  35866.  
  35867. This example passes a variable number of arguments to a function, stores each 
  35868. argument in an array, and prints each argument. 
  35869.  
  35870. ************************************************************************/
  35871.  
  35872. #include <stdio.h>
  35873. #include <stdarg.h>
  35874.  
  35875. int vout(int max,...);
  35876.  
  35877. int main(void)
  35878. {
  35879.    vout(3, "Sat", "Sun", "Mon");
  35880.    printf("\n");
  35881.    vout(5, "Mon", "Tues", "Wed", "Thurs", "Fri");
  35882.    return 0;
  35883. }
  35884.  
  35885. int vout(int max,...)
  35886. {
  35887.    va_list arg_ptr;
  35888.    int args = 0;
  35889.    char *days[7];
  35890.  
  35891.    va_start(arg_ptr, max);
  35892.    while (args < max) {
  35893.       days[args] = va_arg(arg_ptr, char *);
  35894.       printf("Day:  %s  \n", days[args++]);
  35895.    }
  35896.    va_end(arg_ptr);
  35897.  
  35898.    /****************************************************************************
  35899.       The output should be:
  35900.  
  35901.       Day:  Sat
  35902.       Day:  Sun
  35903.       Day:  Mon
  35904.  
  35905.       Day:  Mon
  35906.       Day:  Tues
  35907.       Day:  Wed
  35908.       Day:  Thurs
  35909.       Day:  Fri
  35910.    ****************************************************************************/
  35911. }
  35912.  
  35913.  
  35914. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  35915.  
  35916. Example of va_arg - va_end - va_start 
  35917.  
  35918.      vfprintf - Print Argument Data to Stream 
  35919.      vprintf - Print Argument Data 
  35920.      vsprintf - Print Argument Data to Buffer 
  35921.      <stdarg.h> 
  35922.  
  35923.  
  35924. ΓòÉΓòÉΓòÉ 4.354. vfprintf - Print Argument Data to Stream ΓòÉΓòÉΓòÉ
  35925.  
  35926.  
  35927. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  35928.  
  35929. #include <stdarg.h>
  35930. #include <stdio.h>
  35931. int vfprintf(FILE *stream, const char *format, va_list arg_ptr);
  35932.  
  35933.  
  35934. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  35935.  
  35936. Language Level:  ANSI, SAA, XPG4, Extension 
  35937.  
  35938. vfprintf formats and writes a series of characters and values to the output 
  35939. stream. vfprintf works just like fprintf, except that arg_ptr points to a list 
  35940. of arguments whose number can vary from call to call in the program. These 
  35941. arguments should be initialized by va_start for each call. In contrast, fprintf 
  35942. can have a list of arguments, but the number of arguments in that list is fixed 
  35943. when you compile the program. 
  35944.  
  35945. vfprintf converts each entry in the argument list according to the 
  35946. corresponding format specifier in format. The format has the same form and 
  35947. function as the format string for printf. For a description of the format 
  35948. string, see printf - Print Formatted Characters. 
  35949.  
  35950. In extended mode, vfprintf also converts floating-point values of NaN and 
  35951. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  35952. and sign of the string is determined by the format specifiers.  See Infinity 
  35953. and NaN Support for more information on infinity and NaN values. 
  35954.  
  35955. If you specify a null string for the %s or %ls format specifier, vfprintf 
  35956. prints (null). (In previous releases of C Set ++, vfprintf produced no output 
  35957. for a null string.) 
  35958.  
  35959. Return Value 
  35960. If successful, vfprintf returns the number of bytes written to stream. If an 
  35961. error occurs, the function returns a negative value. 
  35962.  
  35963.  
  35964. ΓòÉΓòÉΓòÉ <hidden> Example of vfprintf ΓòÉΓòÉΓòÉ
  35965.  
  35966. /************************************************************************
  35967.  
  35968. This example prints out a variable number of strings to the file vfprintf.out. 
  35969.  
  35970. ************************************************************************/
  35971.  
  35972. #include <stdarg.h>
  35973. #include <stdio.h>
  35974.  
  35975. #define FILENAME "vfprintf.o"
  35976.  
  35977. void vout(FILE *stream, char *fmt,...);
  35978.  
  35979. char fmt1[] = "%s  %s  %s  %s\n";
  35980.  
  35981. int main(void)
  35982. {
  35983.    FILE *stream;
  35984.  
  35985.    stream = fopen(FILENAME, "w");
  35986.    vout(stream, fmt1, "Sat", "Sun", "Mon", "Tue");
  35987.    fclose(stream);
  35988.    return 0;
  35989.  
  35990.    /****************************************************************************
  35991.       After running the program, the output file should contain:
  35992.  
  35993.       Sat  Sun  Mon  Tue
  35994.    ****************************************************************************/
  35995. }
  35996.  
  35997. void vout(FILE *stream, char *fmt,...)
  35998. {
  35999.    va_list arg_ptr;
  36000.  
  36001.    va_start(arg_ptr, fmt);
  36002.    vfprintf(stream, fmt, arg_ptr);
  36003.    va_end(arg_ptr);
  36004. }
  36005.  
  36006.  
  36007. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36008.  
  36009. Example of vfprintf 
  36010.  
  36011.      fprintf - Write Formatted Data to a Stream 
  36012.      printf - Print Formatted Characters 
  36013.      va_arg - va_end - va_start - Access Function Arguments 
  36014.      vprintf - Print Argument Data 
  36015.      vsprintf - Print Argument Data to Buffer 
  36016.      vswprintf - Format and Write Wide Characters to Buffer 
  36017.      Infinity and NaN Support 
  36018.      <stdarg.h> 
  36019.      <stdio.h> 
  36020.  
  36021.  
  36022. ΓòÉΓòÉΓòÉ 4.355. vprintf - Print Argument Data ΓòÉΓòÉΓòÉ
  36023.  
  36024.  
  36025. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36026.  
  36027. #include <stdarg.h>
  36028. #include <stdio.h>
  36029. int vprintf(const char *format, va_list arg_ptr);
  36030.  
  36031.  
  36032. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36033.  
  36034. Language Level:  ANSI, SAA, XPG4, Extension 
  36035.  
  36036. vprintf formats and prints a series of characters and values to stdout. vprintf 
  36037. works just like printf, except that arg_ptr points to a list of arguments whose 
  36038. number can vary from call to call in the program. These arguments should be 
  36039. initialized by va_start for each call. In contrast, printf can have a list of 
  36040. arguments, but the number of arguments in that list is fixed when you compile 
  36041. the program. 
  36042.  
  36043. vprintf converts each entry in the argument list according to the corresponding 
  36044. format specifier in format. The format has the same form and function as the 
  36045. format string for printf. For a description of the format string, see printf - 
  36046. Print Formatted Characters. 
  36047.  
  36048. In extended mode, vprintf also converts floating-point values of NaN and 
  36049. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  36050. and sign of the string is determined by the format specifiers.  See Infinity 
  36051. and NaN Support for more information on infinity and NaN values. 
  36052.  
  36053. If you specify a null string for the %s or %ls format specifier, vfprintf 
  36054. prints (null). (In previous releases of C Set ++, vprintf produced no output 
  36055. for a null string.) 
  36056.  
  36057. Return Value 
  36058. If successful, vprintf returns the number of bytes written to stdout. If an 
  36059. error occurs, vprintf returns a negative value. 
  36060.  
  36061.  
  36062. ΓòÉΓòÉΓòÉ <hidden> Example of vprintf ΓòÉΓòÉΓòÉ
  36063.  
  36064. /************************************************************************
  36065.  
  36066. This example prints out a variable number of strings to stdout. 
  36067.  
  36068. ************************************************************************/
  36069.  
  36070. #include <stdarg.h>
  36071. #include <stdio.h>
  36072.  
  36073. void vout(char *fmt, ...);
  36074.  
  36075. int main(void)
  36076. {
  36077.    char fmt1[] = "%s  %s  %s\n";
  36078.    vout(fmt1, "Sat", "Sun", "Mon");
  36079.    return 0;
  36080.  
  36081.    /****************************************************************************
  36082.       The output should be:
  36083.  
  36084.       Sat  Sun  Mon
  36085.    ****************************************************************************/
  36086. }
  36087.  
  36088. void vout(char *fmt, ...)
  36089. {
  36090.    va_list arg_ptr;
  36091.  
  36092.    va_start(arg_ptr, fmt);
  36093.    vprintf(fmt, arg_ptr);
  36094.    va_end(arg_ptr);
  36095. }
  36096.  
  36097.  
  36098. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36099.  
  36100. Example of vprintf 
  36101.  
  36102.      printf - Print Formatted Characters 
  36103.      va_arg - va_end - va_start - Access Function Arguments 
  36104.      vfprintf - Print Argument Data to Stream 
  36105.      vsprintf - Print Argument Data to Buffer 
  36106.      vswprintf - Format and Write Wide Characters to Buffer 
  36107.      Infinity and NaN Support 
  36108.      <stdarg.h> 
  36109.      <stdio.h> 
  36110.  
  36111.  
  36112. ΓòÉΓòÉΓòÉ 4.356. vsprintf - Print Argument Data to Buffer ΓòÉΓòÉΓòÉ
  36113.  
  36114.  
  36115. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36116.  
  36117. #include <stdarg.h>
  36118. #include <stdio.h>
  36119. int vsprintf(char *target-string, const char *format, va_list arg_ptr);
  36120.  
  36121.  
  36122. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36123.  
  36124. Language Level:  ANSI, SAA, XPG4, Extension 
  36125.  
  36126. vsprintf formats and stores a series of characters and values in the buffer 
  36127. target-string. vsprintf works just like sprintf, except that arg_ptr points to 
  36128. a list of arguments whose number can vary from call to call in the program. 
  36129. These arguments should be initialized by va_start for each call. In contrast, 
  36130. sprintf can have a list of arguments, but the number of arguments in that list 
  36131. is fixed when you compile the program. 
  36132.  
  36133. vsprintf converts each entry in the argument list according to the 
  36134. corresponding format specifier in format. The format has the same form and 
  36135. function as the format string for printf. For a description of the format 
  36136. string, see printf - Print Formatted Characters. 
  36137.  
  36138. In extended mode, vsprintf also converts floating-point values of NaN and 
  36139. infinity to the strings "NAN" or "nan" and "INFINITY" or "infinity". The case 
  36140. and sign of the string is determined by the format specifiers.  See Infinity 
  36141. and NaN Support for more information on infinity and NaN values. 
  36142.  
  36143. If you specify a null string for the %s or %ls format specifier, vsprintf 
  36144. prints (null). (In previous releases of C Set ++, vsprintf produced no output 
  36145. for a null string.) 
  36146.  
  36147. Return Value 
  36148. If successful, vsprintf returns the number of bytes written to target-string. 
  36149. If an error occurs, vsprintf returns a negative value. 
  36150.  
  36151.  
  36152. ΓòÉΓòÉΓòÉ <hidden> Example of vsprintf ΓòÉΓòÉΓòÉ
  36153.  
  36154. /************************************************************************
  36155.  
  36156. This example assigns a variable number of strings to string and prints the 
  36157. resultant string. 
  36158.  
  36159. ************************************************************************/
  36160.  
  36161. #include <stdarg.h>
  36162. #include <stdio.h>
  36163.  
  36164. void vout(char *string, char *fmt,...);
  36165.  
  36166. char fmt1[] = "%s  %s  %s\n";
  36167.  
  36168. int main(void)
  36169. {
  36170.    char string[100];
  36171.  
  36172.    vout(string, fmt1, "Sat", "Sun", "Mon");
  36173.    printf("The string is: %s", string);
  36174.    return 0;
  36175.  
  36176.    /****************************************************************************
  36177.       The output should be:
  36178.  
  36179.       The string is: Sat  Sun  Mon
  36180.    ****************************************************************************/
  36181. }
  36182.  
  36183. void vout(char *string, char *fmt,...)
  36184. {
  36185.    va_list arg_ptr;
  36186.  
  36187.    va_start(arg_ptr, fmt);
  36188.    vsprintf(string, fmt, arg_ptr);
  36189.    va_end(arg_ptr);
  36190. }
  36191.  
  36192.  
  36193. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36194.  
  36195. Example of vsprintf 
  36196.  
  36197.      printf - Print Formatted Characters 
  36198.      sprintf - Print Formatted Data to Buffer 
  36199.      swprintf - Format and Write Wide Characters to Buffer 
  36200.      va_arg - va_end - va_start - Access Function Arguments 
  36201.      vfprintf - Print Argument Data to Stream 
  36202.      vprintf - Print Argument Data 
  36203.      vswprintf - Format and Write Wide Characters to Buffer 
  36204.      Infinity and NaN Support 
  36205.      <stdarg.h> 
  36206.      <stdio.h> 
  36207.  
  36208.  
  36209. ΓòÉΓòÉΓòÉ 4.357. vswprintf - Format and Write Wide Characters to Buffer ΓòÉΓòÉΓòÉ
  36210.  
  36211.  
  36212. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36213.  
  36214. #include <stdarg.h>
  36215. #include <wchar.h>
  36216. int vswprintf(wchar_t *wcsbuffer, size_t n,
  36217.               const wchar_t *format, va_list argptr);
  36218.  
  36219.  
  36220. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36221.  
  36222. Language Level:  ANSI 93 
  36223.  
  36224. vswprintf formats and stores a series of wide characters and values in the 
  36225. buffer wcsbuffer. vswprintf works just like swprintf, except that argptr points 
  36226. to a list of wide-character arguments whose number can vary from call to call. 
  36227. These arguments should be initialized by va_start for each call. In contrast, 
  36228. swprintf can have a list of arguments, but the number of arguments in that list 
  36229. are fixed when you compile in the program. 
  36230.  
  36231. The value n specifies the maximum number of wide characters to be written, 
  36232. including the terminating null character. 
  36233.  
  36234. vswprintf converts each entry in the argument list according to the 
  36235. corresponding wide-character format specifier in format. The format has the 
  36236. same form and function as the format string for printf, with the following 
  36237. exceptions: 
  36238.  
  36239.      %c (without an l prefix) converts an integer argument to wchar_t, as if 
  36240.       by calling mbtowc. 
  36241.      %lc converts a wint_t to wchar_t. 
  36242.      %s (without an l prefix); converts an array of multibyte characters to an 
  36243.       array of wchar_t, as if by calling mbrtowc. The array is written up to, 
  36244.       but not including, the terminating null character, unless the precision 
  36245.       specifies a shorter output. 
  36246.      %ls writes an array of wchar_t. The array is written up to, but not 
  36247.       including, the terminating null character, unless the precision specifies 
  36248.       a shorter output. 
  36249.  
  36250.  For a complete description of format specifiers, see printf - Print Formatted 
  36251.  Characters. 
  36252.  
  36253.  A null wide character is added to the end of the wide characters written; the 
  36254.  null wide character is not counted as part of the returned value. If copying 
  36255.  takes place between objects that overlap, the behavior is undefined. 
  36256.  
  36257.  If you specify a null string for the %s or %ls format specifier, vswprintf 
  36258.  prints (null). 
  36259.  
  36260.  Return Value 
  36261.  vswprintf returns the number of bytes written in the array, not counting the 
  36262.  terminating null wide character. 
  36263.  
  36264.  
  36265. ΓòÉΓòÉΓòÉ <hidden> Example of vswprintf ΓòÉΓòÉΓòÉ
  36266.  
  36267. /************************************************************************
  36268.  
  36269. This example creates a function vout that takes a variable number of 
  36270. wide-character arguments and uses vswprintf to print them to wcstr. 
  36271.  
  36272. ************************************************************************/
  36273.  
  36274. #include <stdio.h>
  36275. #include <stdarg.h>
  36276. #include <wchar.h>
  36277.  
  36278. wchar_t *format3 = L"%ls  %d  %ls";
  36279. wchar_t *format5 = L"%ls  %d  %ls  %d  %ls";
  36280.  
  36281. void vout(wchar_t *wcs, size_t n, wchar_t *fmt, ...)
  36282. {
  36283.    va_list arg_ptr;
  36284.  
  36285.    va_start(arg_ptr, fmt);
  36286.    vswprintf(wcs, n, fmt, arg_ptr);
  36287.    va_end(arg_ptr);
  36288.    return;
  36289. }
  36290.  
  36291. int main(void)
  36292. {
  36293.    wchar_t wcstr[100];
  36294.  
  36295.    vout(wcstr, 100, format3, L"ONE", 2L, L"THREE");
  36296.    printf("%ls\n", wcstr);
  36297.    vout(wcstr, 100, format5, L"ONE", 2L, L"THREE", 4L, L"FIVE");
  36298.    printf("%ls\n", wcstr);
  36299.    return 0;
  36300.  
  36301.    /****************************************************************************
  36302.       The output should be similar to :
  36303.  
  36304.       ONE  2  THREE
  36305.       ONE  2  THREE  4  FIVE
  36306.    ****************************************************************************/
  36307. }
  36308.  
  36309.  
  36310. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36311.  
  36312. Example of vswprintf 
  36313.  
  36314.      printf - Print Formatted Characters 
  36315.      swprintf - Format and Write Wide Characters to Buffer 
  36316.      vfprintf - Print Argument Data to Stream 
  36317.      vprintf - Print Argument Data 
  36318.      vsprintf - Print Argument Data to Buffer 
  36319.      <stdarg.h> 
  36320.      <wchar.h> 
  36321.  
  36322.  
  36323. ΓòÉΓòÉΓòÉ 4.358. wait - Wait for Child Process ΓòÉΓòÉΓòÉ
  36324.  
  36325.  
  36326. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36327.  
  36328. #include <process.h>
  36329. int wait (int *stat_loc);
  36330.  
  36331.  
  36332. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36333.  
  36334. Language Level:  XPG4, Extension 
  36335.  
  36336. wait delays a parent process until one of the immediate child processes stops. 
  36337. If all the child processes stop before wait is called, control returns 
  36338. immediately to the parent function. 
  36339.  
  36340. If stat_loc is NULL, wait does not use it. If it is not NULL, wait places 
  36341. information about the return status and the return code ot the child process 
  36342. that ended in the location to which stat_loc points. 
  36343.  
  36344. If the child process ended normally, with a call to the OS/2 DosExit function, 
  36345. the lowest-order byte of stat_loc is 0, and the next higher-order byte contains 
  36346. the lowest-order byte of the argument passed to DosExit by the child process. 
  36347. The value of this byte depends on how the child process caused the system to 
  36348. call DosExit. 
  36349.  
  36350. If the child process called exit, _exit, or return from main, the byte contains 
  36351. the lowest-order byte of the argument the child process passed to exit, _exit, 
  36352. or return.  The value of the byte is undefined if the child process caused a 
  36353. DosExit call simply by reaching the end of main. 
  36354.  
  36355. If the child process ended abnormally, the lowest-order byte of stat_loc 
  36356. contains the return status code from the OS/2 DosWaitChild function, and the 
  36357. next higher-order byte is 0. See the Control Program Guide and Reference for 
  36358. details about DosWaitChild return status codes. 
  36359.  
  36360. Note:  In earlier releases of C Set ++, wait began with an underscore (_wait). 
  36361. Because it is defined by the X/Open standard, the underscore has been removed. 
  36362. For compatibility, VisualAge C++ will map _wait to wait for you. 
  36363.  
  36364. Return Value 
  36365. If wait returns after a normal end of a child process, it returns the process 
  36366. identifier of the child process to the parent process. A return value of -1 
  36367. indicates an error, and errno is set to one of the following values: 
  36368.  
  36369.  Value          Meaning 
  36370.  ECHILD         There were no child processes or they all ended before the call 
  36371.                 to wait. This value indicates that no child processes exist for 
  36372.                 the particular process. 
  36373.  EINTR          A child process ended unexpectedly. 
  36374.  
  36375.  
  36376. ΓòÉΓòÉΓòÉ <hidden> Example of wait ΓòÉΓòÉΓòÉ
  36377.  
  36378. /************************************************************************
  36379.  
  36380. This example creates a new process called CHILD.EXE, specifying P_NOWAIT when 
  36381. the child process is called. The parent process calls wait and waits for the 
  36382. child process to stop running. The parent process then displays the return 
  36383. information of the child process in hexadecimal. 
  36384.  
  36385. ************************************************************************/
  36386.  
  36387. #include <stdio.h>
  36388. #include <process.h>
  36389.  
  36390. int stat_child;
  36391.  
  36392. int main(void)
  36393. {
  36394.    int pid;
  36395.  
  36396.    _spawnl(P_NOWAIT, "child2.exe", "child2.exe", NULL);
  36397.    if (-1 == (pid = wait(&stat_child)))
  36398.       perror("error in _spawnl"); /* display error status message             */
  36399.    else
  36400.       printf("child process %d just ran.\n", pid);
  36401.  
  36402.    printf("return information was 0x%X\n", stat_child);
  36403.    return 0;
  36404.  
  36405.    /****************************************************************************
  36406.       If the source for child2.exe is:
  36407.  
  36408.       #include <stdio.h>
  36409.       int main(void)
  36410.       {
  36411.           puts("child2.exe is an executable file");
  36412.           return 0;
  36413.       }
  36414.  
  36415.       Then the output should be similar to:
  36416.  
  36417.       child2.exe is an executable file
  36418.       child process 2423 just ran.
  36419.       return information was 0x0
  36420.    ****************************************************************************/
  36421. }
  36422.  
  36423.  
  36424. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36425.  
  36426. Example of wait 
  36427.  
  36428.      _cwait - Wait for Child Process 
  36429.      execl - _execvpe - Load and Run Child Process 
  36430.      exit - End Program 
  36431.      _exit - End Process 
  36432.      _spawnl - _spawnvpe - Start and Run Child Processes 
  36433.      <process.h> 
  36434.  
  36435.  
  36436. ΓòÉΓòÉΓòÉ 4.359. wcrtomb - Convert Wide Character to Multibyte Character ΓòÉΓòÉΓòÉ
  36437.  
  36438.  
  36439. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36440.  
  36441. #include <wchar.h>
  36442. int wcrtomb(char *dest, wchar_t wc, mbstate_t *ps);
  36443.  
  36444.  
  36445. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36446.  
  36447. Language Level:  ANSI 93 
  36448.  
  36449. wcrtomb is a restartable version of wctomb, and performs the same function. It 
  36450. first determines the length of the wide character pointed to by wc. It then 
  36451. converts the wide character to the corresponding multibyte character, and 
  36452. stores the converted character in the location pointed to by dest, if dest is 
  36453. not a null pointer. A maximum of MB_CUR_MAX bytes are stored. 
  36454.  
  36455. With wcrtomb, you can switch from one multibyte string to another. On systems 
  36456. that support shift states, ps represents the initial shift state of the string 
  36457. (0).  If you read in only part of the string, wcrtomb sets ps to the string's 
  36458. shift state at the point you stopped.  You can then call wcrtomb again for that 
  36459. string and pass in the updated ps value to continue reading where you left off. 
  36460.  
  36461. Note:  Because OS/2 does not have shift states, the ps parameter is provided 
  36462. only for compatibility with other ANSI/ISO platforms.  VisualAge C++ ignores 
  36463. the value passed for ps. 
  36464.  
  36465. The behavior of wcrtomb is affected by the LC_CTYPE category of the current 
  36466. locale. 
  36467.  
  36468. Return Value 
  36469. If dest is a null pointer, wcrtomb returns 0. If dest is not a null pointer, 
  36470. wcrtomb returns the number of bytes stored in dest. If wc is not a valid wide 
  36471. character, wcrtomb sets errno to EILSEQ and returns -1. 
  36472.  
  36473.  
  36474. ΓòÉΓòÉΓòÉ <hidden> Example of wcrtomb ΓòÉΓòÉΓòÉ
  36475.  
  36476. /************************************************************************
  36477.  
  36478. This example uses wcrtomb to convert two wide-character strings to multibyte 
  36479. strings. 
  36480.  
  36481. ************************************************************************/
  36482.  
  36483. #include <stdlib.h>
  36484. #include <stdio.h>
  36485. #include <locale.h>
  36486. #include <wchar.h>
  36487.  
  36488. #define SIZE  20
  36489.  
  36490. int main(void)
  36491. {
  36492.    wchar_t    wcs1[] = L"abc";
  36493.    wchar_t    wcs2[] = L"A\x8142" L"C";
  36494.    mbstate_t  ss1 = 0;
  36495.    mbstate_t  ss2 = 0;
  36496.    size_t     length1 = 0;
  36497.    size_t     length2 = 0;
  36498.    char       mb1[SIZE], mb2[SIZE];
  36499.    int        i;
  36500.  
  36501.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  36502.       printf("setlocale failed.\n");
  36503.       exit(EXIT_FAILURE);
  36504.    }
  36505.    for (i = 0; i <=2; ++i) {
  36506.       length1 += wcrtomb(mb1 + length1, *(wcs1 + i), &ss1);
  36507.       length2 += wcrtomb(mb2 + length2, *(wcs2 + i), &ss2);
  36508.    }
  36509.    mb1[length1] = 0;
  36510.    mb2[length2] = 0;
  36511.    printf("The first multibyte string is: <%s>\n", mb1);
  36512.    printf("The second multibyte string is: <%s>\n", mb2);
  36513.    return 0;
  36514.  
  36515.    /****************************************************************************
  36516.       The output should be similiar to :
  36517.  
  36518.       The first multibyte string is: <abc>
  36519.       The second multibyte string is: <AΓöÇBC>
  36520.    ****************************************************************************/
  36521. }
  36522.  
  36523.  
  36524. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36525.  
  36526. Example of wcrtomb 
  36527.  
  36528.      mblen - Determine Length of Multibyte Character 
  36529.      mbrlen - Calculate Length of Multibyte Character 
  36530.      mbrtowc - Convert Multibyte Character to Wide Character 
  36531.      mbsrtowcs - Convert Multibyte String to Wide-Character String 
  36532.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  36533.      wctomb -  Convert Wide Character to Multibyte Character 
  36534.      <wchar.h> 
  36535.  
  36536.  
  36537. ΓòÉΓòÉΓòÉ 4.360. wcscat - Concatenate Wide-Character Strings ΓòÉΓòÉΓòÉ
  36538.  
  36539.  
  36540. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36541.  
  36542. #include <wcstr.h>
  36543. wchar_t *wcscat(wchar_t *string1, const wchar_t *string2);
  36544.  
  36545.  
  36546. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36547.  
  36548. Language Level:  SAA, XPG4 
  36549.  
  36550. wcscat appends a copy of the string pointed to by string2 to the end of the 
  36551. string pointed to by string1. 
  36552.  
  36553. wcscat operates on null-terminated wchar_t strings. The string arguments to 
  36554. this function should contain a wchar_t null character marking the end of the 
  36555. string. Boundary checking is not performed. 
  36556.  
  36557. Return Value 
  36558. wcscat returns a pointer to the concatenated string1. 
  36559.  
  36560.  
  36561. ΓòÉΓòÉΓòÉ <hidden> Example of wcscat ΓòÉΓòÉΓòÉ
  36562.  
  36563. /*************************************************************************
  36564.  
  36565. This example creates the wide character string "computer program" using wcscat. 
  36566.  
  36567. ************************************************************************/
  36568.  
  36569. #include <stdio.h>
  36570. #include <wcstr.h>
  36571.  
  36572. #define  SIZE          40
  36573.  
  36574. int main(void)
  36575. {
  36576.    wchar_t buffer1[SIZE] = L"computer";
  36577.    wchar_t *string = L" program";
  36578.    wchar_t *ptr;
  36579.  
  36580.    ptr = wcscat(buffer1, string);
  36581.    printf("buffer1 = %ls\n", buffer1);
  36582.    return 0;
  36583.  
  36584.    /****************************************************************************
  36585.       The output should be:
  36586.  
  36587.       buffer1 = computer program
  36588.    ****************************************************************************/
  36589. }
  36590.  
  36591.  
  36592. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36593.  
  36594. Example of wcscat 
  36595.  
  36596.      strcat - Concatenate Strings 
  36597.      strncat - Concatenate Strings 
  36598.      wcsncat - Concatenate Wide-Character Strings 
  36599.      <wcstr.h> 
  36600.  
  36601.  
  36602. ΓòÉΓòÉΓòÉ 4.361. wcschr - Search for Wide Character ΓòÉΓòÉΓòÉ
  36603.  
  36604.  
  36605. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36606.  
  36607. #include <wcstr.h>
  36608. wchar_t *wcschr(const wchar_t *string, wchar_t character);
  36609.  
  36610.  
  36611. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36612.  
  36613. Language Level:  SAA, XPG4 
  36614.  
  36615. wcschr searches the wide-character string for the occurrence of character. The 
  36616. character can be a wchar_t null character (\0); the wchar_t null character at 
  36617. the end of string is included in the search. 
  36618.  
  36619. wcschr operates on null-terminated wchar_t strings. The string argument to this 
  36620. function should contain a wchar_t null character marking the end of the string. 
  36621.  
  36622. Return Value 
  36623. wcschr returns a pointer to the first occurrence of character in string. If the 
  36624. character is not found, a NULL pointer is returned. 
  36625.  
  36626.  
  36627. ΓòÉΓòÉΓòÉ <hidden> Example of wcschr ΓòÉΓòÉΓòÉ
  36628.  
  36629. /*************************************************************************
  36630.  
  36631. This example finds the first occurrence of the character p in the 
  36632. wide-character string "computer program". 
  36633.  
  36634. ************************************************************************/
  36635.  
  36636. #include <stdio.h>
  36637. #include <wcstr.h>
  36638.  
  36639. #define  SIZE          40
  36640.  
  36641. int main(void)
  36642. {
  36643.    wchar_t buffer1[SIZE] = L"computer program";
  36644.    wchar_t *ptr;
  36645.    wchar_t ch = L'p';
  36646.  
  36647.    ptr = wcschr(buffer1, ch);
  36648.    printf("The first occurrence of %lc in '%ls' is '%ls'\n", ch, buffer1, ptr);
  36649.    return 0;
  36650.  
  36651.    /****************************************************************************
  36652.       The output should be:
  36653.  
  36654.       The first occurrence of p in 'computer program' is 'puter program'
  36655.    ****************************************************************************/
  36656. }
  36657.  
  36658.  
  36659. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36660.  
  36661. Example of wcschr 
  36662.  
  36663.      strchr - Search for Character 
  36664.      strcspn - Compare Strings for Substrings 
  36665.      strpbrk - Find Characters in String 
  36666.      strrchr - Find Last Occurrence of Character in String 
  36667.      strspn - Search Strings 
  36668.      wcscspn - Find Offset of First Wide-Character Match 
  36669.      wcspbrk - Locate Wide Characters in String 
  36670.      wcsrchr - Locate Wide Character in String 
  36671.      wcsspn - Search Wide-Character Strings 
  36672.      wcswcs - Locate Wide-Character Substring 
  36673.      <wcstr.h> 
  36674.  
  36675.  
  36676. ΓòÉΓòÉΓòÉ 4.362. wcscmp - Compare Wide-Character Strings ΓòÉΓòÉΓòÉ
  36677.  
  36678.  
  36679. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36680.  
  36681. #include <wcstr.h>
  36682. int wcscmp(const wchar_t *string1, const wchar_t *string2);
  36683.  
  36684.  
  36685. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36686.  
  36687. Language Level:  SAA, XPG4 
  36688.  
  36689. wcscmp compares two wide-character strings. 
  36690.  
  36691. wcscmp operates on null-terminated wchar_t strings; string arguments to this 
  36692. function should contain a wchar_t null character marking the end of the string. 
  36693. Boundary checking is not performed when a string is added to or copied. 
  36694.  
  36695. Return Value 
  36696.  
  36697. wcscmp returns a value indicating the relationship between the two strings, as 
  36698. follows: 
  36699.  
  36700.  Value             Meaning 
  36701.  Less than 0       string1 less than string2 
  36702.  0                 string1 identical to string2 
  36703.  Greater than 0    string1 greater than string2. 
  36704.  
  36705.  
  36706. ΓòÉΓòÉΓòÉ <hidden> Example of wcscmp ΓòÉΓòÉΓòÉ
  36707.  
  36708. /*************************************************************************
  36709.  
  36710. This example compares the wide-character string string1 to string2 using 
  36711. wcscmp. 
  36712.  
  36713. ************************************************************************/
  36714.  
  36715. #include <stdio.h>
  36716. #include <wcstr.h>
  36717.  
  36718. int main(void)
  36719. {
  36720.    int result;
  36721.    wchar_t string1[] = L"abcdef";
  36722.    wchar_t string2[] = L"abcdefg";
  36723.  
  36724.    result = wcscmp(string1, string2);
  36725.    if (0 == result)
  36726.       printf("\"%ls\" is identical to \"%ls\"\n", string1, string2);
  36727.    else
  36728.       if (result < 0)
  36729.          printf("\"%ls\" is less than \"%ls\"\n", string1, string2);
  36730.       else
  36731.          printf("\"%ls\" is greater than \"%ls\"\n", string1, string2);
  36732.    return 0;
  36733.  
  36734.    /****************************************************************************
  36735.       The output should be:
  36736.  
  36737.       "abcdef" is less than "abcdefg"
  36738.    ****************************************************************************/
  36739. }
  36740.  
  36741.  
  36742. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36743.  
  36744. Example of wcscmp 
  36745.  
  36746.      strcmp - Compare Strings 
  36747.      strcmpi - Compare Strings Without Case Sensitivity 
  36748.      stricmp - Compare Strings as Lowercase 
  36749.      strnicmp - Compare Strings Without Case Sensitivity 
  36750.      wcsncmp - Compare Wide-Character Strings 
  36751.      <wcstr.h> 
  36752.  
  36753.  
  36754. ΓòÉΓòÉΓòÉ 4.363. wcscoll - Compare Wide-Character Strings ΓòÉΓòÉΓòÉ
  36755.  
  36756.  
  36757. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36758.  
  36759. #include <wchar.h>
  36760. int wcscoll(const wchar_t *wcstr1, const wchar_t *wcstr2);
  36761.  
  36762.  
  36763. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36764.  
  36765. Language Level:  ANSI 93, XPG4 
  36766.  
  36767. wcscoll compares the wide-character string pointed to by wcstr1 to the 
  36768. wide-character string pointed to by wcstr2, both interpreted according to the 
  36769. information in the LC_COLLATE category of the current locale. 
  36770.  
  36771. wcscoll differs from the wcscmp function. wcscoll performs a comparison between 
  36772. two wide-character strings based on language collation rules as controlled by 
  36773. the LC_COLLATE category. In contrast, wcscmp performs a wide-character code to 
  36774. wide-character code comparison. 
  36775.  
  36776. Return Value 
  36777. wcscoll returns an integer value indicating the relationship between the 
  36778. strings, as listed below: 
  36779.  
  36780.  Value             Meaning 
  36781.  Less than 0       wcstr1 less than wcstr2 
  36782.  0                 wcstr1 equivalent to wcstr2 
  36783.  Greater than 0    wcstr1 greater than wcstr2 
  36784.  
  36785.  If wcs1 or wcs2 contain characters outside the domain of the collating 
  36786.  sequence, wcscoll sets errno to EILSEQ. If an error occurs, wcscoll sets errno 
  36787.  to a nonzero value. There is no error return value. 
  36788.  
  36789.  
  36790. ΓòÉΓòÉΓòÉ <hidden> Example of wcscoll ΓòÉΓòÉΓòÉ
  36791.  
  36792. /************************************************************************
  36793.  
  36794. This example uses wcscoll to compare two wide-character strings. 
  36795.  
  36796. ************************************************************************/
  36797.  
  36798. #include <wchar.h>
  36799. #include <locale.h>
  36800. #include <stdio.h>
  36801. #include <stdlib.h>
  36802.  
  36803. int main(void)
  36804. {
  36805.    wchar_t *wcs1 = L"A wide string";
  36806.    wchar_t *wcs2 = L"a wide string";
  36807.    int     result;
  36808.  
  36809.    if (NULL == setlocale(LC_ALL, LC_C_JAPAN)) {
  36810.       printf("setlocale failed.\n");
  36811.       exit(EXIT_FAILURE);
  36812.    }
  36813.    result = wcscoll(wcs1, wcs2);
  36814.    if (0 == result)
  36815.       printf("\"%ls\" is identical to \"%ls\"\n", wcs1, wcs2);
  36816.    else if (0 > result)
  36817.       printf("\"%ls\" is less than \"%ls\"\n", wcs1, wcs2);
  36818.    else
  36819.       printf("\"%ls\" is greater than \"%ls\"\n", wcs1, wcs2);
  36820.    return 0;
  36821.  
  36822.    /****************************************************************************
  36823.       The output should be similar to :
  36824.  
  36825.       "A wide string" is identical to "a wide string"
  36826.    ****************************************************************************/
  36827. }
  36828.  
  36829.  
  36830. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36831.  
  36832. Example of wcscoll 
  36833.  
  36834.      strcoll - Compare Strings Using Collation Rules 
  36835.      setlocale - Set Locale 
  36836.      wcscmp - Compare Wide-Character Strings 
  36837.      <wchar.h> 
  36838.  
  36839.  
  36840. ΓòÉΓòÉΓòÉ 4.364. wcscpy - Copy Wide-Character Strings ΓòÉΓòÉΓòÉ
  36841.  
  36842.  
  36843. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36844.  
  36845. #include <wcstr.h>
  36846. wchar_t *wcscpy(wchar_t *string1, const wchar_t *string2);
  36847.  
  36848.  
  36849. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36850.  
  36851. Language Level:  SAA, XPG4 
  36852.  
  36853. wcscpy copies the contents of string2 (including the ending wchar_t null 
  36854. character) into string1. 
  36855.  
  36856. wcscpy operates on null-terminated wchar_t strings; string arguments to this 
  36857. function should contain a wchar_t null character marking the end of the string. 
  36858. Boundary checking is not performed. 
  36859.  
  36860. Return Value 
  36861. wcscpy returns a pointer to string1. 
  36862.  
  36863.  
  36864. ΓòÉΓòÉΓòÉ <hidden> Example of wcscpy ΓòÉΓòÉΓòÉ
  36865.  
  36866. /*************************************************************************
  36867.  
  36868. This example copies the contents of source to destination. 
  36869.  
  36870. ************************************************************************/
  36871.  
  36872. #include <stdio.h>
  36873. #include <wcstr.h>
  36874.  
  36875. #define  SIZE          40
  36876.  
  36877. int main(void)
  36878. {
  36879.    wchar_t source[SIZE] = L"This is the source string";
  36880.    wchar_t destination[SIZE] = L"And this is the destination string";
  36881.    wchar_t *return_string;
  36882.  
  36883.    printf("destination is originally = \"%ls\"\n", destination);
  36884.    return_string = wcscpy(destination, source);
  36885.    printf("After wcscpy, destination becomes \"%ls\"\n", return_string);
  36886.    return 0;
  36887.  
  36888.    /****************************************************************************
  36889.       The output should be:
  36890.  
  36891.       destination is originally = "And this is the destination string"
  36892.       After wcscpy, destination becomes "This is the source string"
  36893.    ****************************************************************************/
  36894. }
  36895.  
  36896.  
  36897. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36898.  
  36899. Example of wcscpy 
  36900.  
  36901.      strcpy - Copy Strings 
  36902.      strdup - Duplicate String 
  36903.      strncpy - Copy Strings 
  36904.      wcsncpy - Copy Wide-Character Strings 
  36905.      <wcstr.h> 
  36906.  
  36907.  
  36908. ΓòÉΓòÉΓòÉ 4.365. wcscspn - Find Offset of First Wide-Character Match ΓòÉΓòÉΓòÉ
  36909.  
  36910.  
  36911. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36912.  
  36913. #include <wcstr.h>
  36914. size_t wcscspn(const wchar_t *string1, const wchar_t *string2);
  36915.  
  36916.  
  36917. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36918.  
  36919. Language Level:  SAA, XPG4 
  36920.  
  36921. wcscspn determines the number of wchar_t characters in the initial segment of 
  36922. the string pointed to by string1 that do not appear in the string pointed to by 
  36923. string2. 
  36924.  
  36925. wcscspn operates on null-terminated wchar_t strings; string arguments to this 
  36926. function should contain a wchar_t null character marking the end of the string. 
  36927.  
  36928. Return Value 
  36929. wcscspn returns the number of wchar_t characters in the segment. 
  36930.  
  36931.  
  36932. ΓòÉΓòÉΓòÉ <hidden> Example of wcscspn ΓòÉΓòÉΓòÉ
  36933.  
  36934. /*************************************************************************
  36935.  
  36936. This example uses wcscspn to find the first occurrence of any of the characters 
  36937. a, x, l, or e in string. 
  36938.  
  36939. ************************************************************************/
  36940.  
  36941. #include <stdio.h>
  36942. #include <wcstr.h>
  36943.  
  36944. #define  SIZE          40
  36945.  
  36946. int main(void)
  36947. {
  36948.    wchar_t string[SIZE] = L"This is the source string";
  36949.    wchar_t *substring = L"axle";
  36950.  
  36951.    printf("The first %i characters in the string \"%ls\" are not in the "
  36952.       "string \"%ls\" \n", wcscspn(string, substring), string, substring);
  36953.    return 0;
  36954.  
  36955.    /****************************************************************************
  36956.       The output should be:
  36957.  
  36958.       The first 10 characters in the string "This is the source string" are
  36959.       not in the string "axle"?
  36960.    ****************************************************************************/
  36961. }
  36962.  
  36963.  
  36964. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  36965.  
  36966. Example of wcscspn 
  36967.  
  36968.      strcspn - Compare Strings for Substrings 
  36969.      strspn - Search Strings 
  36970.      wcsspn - Search Wide-Character Strings 
  36971.      wcswcs - Locate Wide-Character Substring 
  36972.      <wcstr.h> 
  36973.  
  36974.  
  36975. ΓòÉΓòÉΓòÉ 4.366. wcsftime - Convert to Formatted Date and Time ΓòÉΓòÉΓòÉ
  36976.  
  36977.  
  36978. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  36979.  
  36980. #include <wchar.h>
  36981. size_t wcsftime(wchar_t *wdest, size_t maxsize,
  36982.                 const wchar_t *format, const struct tm *timeptr);
  36983.  
  36984.  
  36985. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  36986.  
  36987. Language Level:  ANSI 93, XPG4 
  36988.  
  36989. wcsftime converts the time and date specification in the timeptr structure into 
  36990. a wide-character string.  It then stores the null-terminated string in the 
  36991. array pointed to by wdest according to the format string pointed to by format. 
  36992. maxsize specifies the maximum number of wide characters that can be copied into 
  36993. the array. 
  36994.  
  36995. wcsftime works just like strftime, except that it uses wide characters. 
  36996.  
  36997. The format string is a multibyte character string containing: 
  36998.  
  36999.      Conversion specification characters. 
  37000.      Ordinary wide characters, which are copied into the array unchanged. 
  37001.  
  37002.  The characters that are converted are determined by the LC_CTYPE category of 
  37003.  the current locale and by the values in the time structure pointed to by 
  37004.  timeptr. The time structure pointed to by timeptr is usually obtained by 
  37005.  calling the gmtime or localtime function. 
  37006.  
  37007.  For details on the conversion specifiers you can use in the format string, see 
  37008.  Conversion Specifiers Used by strftime. 
  37009.  
  37010.  Return Value 
  37011.  If the total number of wide characters in the resulting string, including the 
  37012.  terminating null wide character, does not exceed maxsize, wcsftime returns the 
  37013.  number of wide characters placed into wdest, not including the terminating 
  37014.  null wide character. Otherwise, wcsftime returns 0 and the contents of the 
  37015.  array are indeterminate. 
  37016.  
  37017.  
  37018. ΓòÉΓòÉΓòÉ <hidden> Example of wcsftime ΓòÉΓòÉΓòÉ
  37019.  
  37020. /************************************************************************
  37021.  
  37022. This example obtains the date and time using localtime, formats the information 
  37023. with wcsftime, and prints the date and time. 
  37024.  
  37025. ************************************************************************/
  37026.  
  37027. #include <stdio.h>
  37028. #include <time.h>
  37029. #include <wchar.h>
  37030.  
  37031. int main(void)
  37032. {
  37033.    struct tm *timeptr;
  37034.    wchar_t   dest[100];
  37035.    time_t    temp;
  37036.    size_t    rc;
  37037.  
  37038.    temp = time(NULL);
  37039.    timeptr = localtime(&temp);
  37040.    rc = wcsftime(dest, sizeof(dest)-1, L" Today is %A,"
  37041.                  L" %b %d.\n Time: %I:%M %p", timeptr);
  37042.    printf("%d characters placed in string to make:\n\n%ls\n", rc, dest);
  37043.    return 0;
  37044.  
  37045.    /****************************************************************************
  37046.       The output should be similar to :
  37047.  
  37048.       43 characters placed in string to make:
  37049.  
  37050.        Today is Thursday, Nov 10.
  37051.        Time: 04:56 PM
  37052.    ****************************************************************************/
  37053. }
  37054.  
  37055.  
  37056. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37057.  
  37058. Example of wcsftime 
  37059.  
  37060.      gmtime - Convert Time 
  37061.      localtime - Convert Time 
  37062.      strftime - Convert to Formatted Time 
  37063.      Conversion Specifiers Used by strftime 
  37064.      strptime - Convert to Formatted Date and Time 
  37065.      <wchar.h> 
  37066.  
  37067.  
  37068. ΓòÉΓòÉΓòÉ 4.367. wcsid - Determine Character Set ID for Wide Character ΓòÉΓòÉΓòÉ
  37069.  
  37070.  
  37071. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37072.  
  37073. #include <stdlib.h>
  37074. int wcsid(const wchar_t c);
  37075.  
  37076.  
  37077. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37078.  
  37079. Language Level:  Extension 
  37080.  
  37081. wcsid determines the character set identifier for the specified wide character 
  37082. wc. You can specify character set identifiers for each character in the charmap 
  37083. file for a locale. For more information about character set identifiers and 
  37084. charmap files, see the section on internationalization in the Programming 
  37085. Guide. 
  37086.  
  37087. Return Value 
  37088. wcsid returns the character set identifier for the wide character, or -1 if the 
  37089. wide character is not valid. 
  37090.  
  37091.  
  37092. ΓòÉΓòÉΓòÉ <hidden> Example of wcsid ΓòÉΓòÉΓòÉ
  37093.  
  37094. /************************************************************************
  37095.  
  37096. This example uses wcsid to get the character set identifier for the wide 
  37097. character A. 
  37098.  
  37099. ************************************************************************/
  37100.  
  37101. #include <stdio.h>
  37102. #include <stdlib.h>
  37103.  
  37104. int main(void)
  37105. {
  37106.    wchar_t wc = L'A';
  37107.    int     rc;
  37108.  
  37109.    rc = wcsid(wc);
  37110.    printf("wide character '%c' is in character set id %i\n", wc, rc);
  37111.    return 0;
  37112.  
  37113.    /****************************************************************************
  37114.       The output should be similar to :
  37115.  
  37116.       wide character 'A' is in character set id 0
  37117.    ****************************************************************************/
  37118. }
  37119.  
  37120.  
  37121. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37122.  
  37123. Example of wcsid 
  37124.  
  37125.      <stdlib.h> 
  37126.      csid - Determine Character Set ID for Multibyte Character 
  37127.  
  37128.  
  37129. ΓòÉΓòÉΓòÉ 4.368. wcslen - Calculate Length of Wide-Character String ΓòÉΓòÉΓòÉ
  37130.  
  37131.  
  37132. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37133.  
  37134. #include <wcstr.h>
  37135. size_t wcslen(const wchar_t *string);
  37136.  
  37137.  
  37138. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37139.  
  37140. Language Level:  SAA, XPG4 
  37141.  
  37142. wcslen computes the number of wide characters in the string pointed to by 
  37143. string. 
  37144.  
  37145. Return Value 
  37146. wcslen returns the number of wide characters in string, excluding the 
  37147. terminating wchar_t null character. 
  37148.  
  37149.  
  37150. ΓòÉΓòÉΓòÉ <hidden> Example of wcslen ΓòÉΓòÉΓòÉ
  37151.  
  37152. /*************************************************************************
  37153.  
  37154. This example computes the length of the wide-character string string. 
  37155.  
  37156. ************************************************************************/
  37157.  
  37158. #include <stdio.h>
  37159. #include <wcstr.h>
  37160.  
  37161. int main(void)
  37162. {
  37163.    wchar_t *string = L"abcdef";
  37164.  
  37165.    printf("Length of \"%ls\" is %i\n", string, wcslen(string));
  37166.    return 0;
  37167.  
  37168.    /****************************************************************************
  37169.       The output should be:
  37170.  
  37171.       Length of "abcdef" is 6
  37172.    ****************************************************************************/
  37173. }
  37174.  
  37175.  
  37176. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37177.  
  37178. Example of wcslen 
  37179.  
  37180.      mblen - Determine Length of Multibyte Character 
  37181.      strlen - Determine String Length 
  37182.      <wcstr.h> 
  37183.  
  37184.  
  37185. ΓòÉΓòÉΓòÉ 4.369. wcsncat - Concatenate Wide-Character Strings ΓòÉΓòÉΓòÉ
  37186.  
  37187.  
  37188. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37189.  
  37190. #include <wcstr.h>
  37191. wchar_t *wcsncat(wchar_t *string1, const wchar_t *string2, size_t count);
  37192.  
  37193.  
  37194. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37195.  
  37196. Language Level:  SAA, XPG4 
  37197.  
  37198. wcsncat appends up to count wide characters from string2 to the end of string1, 
  37199. and appends a wchar_t null character to the result. 
  37200.  
  37201. wcsncat operates on null-terminated wide-character strings; string arguments to 
  37202. this function should contain a wchar_t null character marking the end of the 
  37203. string. 
  37204.  
  37205. Return Value 
  37206. wcsncat returns string1. 
  37207.  
  37208.  
  37209. ΓòÉΓòÉΓòÉ <hidden> Example of wcsncat ΓòÉΓòÉΓòÉ
  37210.  
  37211. /*************************************************************************
  37212.  
  37213. This example demonstrates the difference between wcscat and wcsncat. wcscat 
  37214. appends the entire second string to the first; wcsncat appends only the 
  37215. specified number of characters in the second string to the first. 
  37216.  
  37217. ************************************************************************/
  37218.  
  37219. #include <stdio.h>
  37220. #include <wcstr.h>
  37221.  
  37222. #define  SIZE          40
  37223.  
  37224. int main(void)
  37225. {
  37226.    wchar_t buffer1[SIZE] = L"computer";
  37227.    wchar_t *ptr;
  37228.  
  37229.    /* Call wcscat with buffer1 and " program"                                 */
  37230.  
  37231.    ptr = wcscat(buffer1, L" program");
  37232.    printf("wcscat : buffer1 = \"%ls\"\n", buffer1);
  37233.  
  37234.    /* Reset buffer1 to contain just the string "computer" again               */
  37235.  
  37236.    memset(buffer1, L'\0', sizeof(buffer1));
  37237.    ptr = wcscpy(buffer1, L"computer");
  37238.  
  37239.    /* Call wcsncat with buffer1 and " program"                                */
  37240.  
  37241.    ptr = wcsncat(buffer1, L" program", 3);
  37242.    printf("wcsncat: buffer1 = \"%ls\"\n", buffer1);
  37243.    return 0;
  37244.  
  37245.    /****************************************************************************
  37246.       The output should be:
  37247.  
  37248.       wcscat : buffer1 = "computer program"
  37249.       wcsncat: buffer1 = "computer pr"
  37250.    ****************************************************************************/
  37251. }
  37252.  
  37253.  
  37254. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37255.  
  37256. Example of wcsncat 
  37257.  
  37258.      strncat - Concatenate Strings 
  37259.      strcat - Concatenate Strings 
  37260.      wcscat - Concatenate Wide-Character Strings 
  37261.      wcsncmp - Compare Wide-Character Strings 
  37262.      wcsncpy - Copy Wide-Character Strings 
  37263.      <wcstr.h> 
  37264.  
  37265.  
  37266. ΓòÉΓòÉΓòÉ 4.370. wcsncmp - Compare Wide-Character Strings ΓòÉΓòÉΓòÉ
  37267.  
  37268.  
  37269. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37270.  
  37271. #include <wcstr.h>
  37272. int wcsncmp(const wchar_t *string1, const wchar_t *string2, size_t count);
  37273.  
  37274.  
  37275. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37276.  
  37277. Language Level:  SAA, XPG4 
  37278.  
  37279. wcsncmp compares up to count wide characters in string1 to string2. 
  37280.  
  37281. wcsncmp operates on null-terminated wide-character strings; string arguments to 
  37282. this function should contain a wchar_t null character marking the end of the 
  37283. string. 
  37284.  
  37285. Return Value 
  37286. wcsncmp returns a value indicating the relationship between the two strings, as 
  37287. follows: 
  37288.  
  37289.  Value             Meaning 
  37290.  Less than 0       string1 less than string2 
  37291.  0                 string1 identical to string2 
  37292.  Greater than 0    string1 greater than string2. 
  37293.  
  37294.  
  37295. ΓòÉΓòÉΓòÉ <hidden> Example of wcsncmp ΓòÉΓòÉΓòÉ
  37296.  
  37297. /*************************************************************************
  37298.  
  37299. This example demonstrates the difference between wcscmp, which compares the 
  37300. entire strings, and wcsncmp, which compares only a specified number of wide 
  37301. characters in the strings. 
  37302.  
  37303. ************************************************************************/
  37304.  
  37305. #include <stdio.h>
  37306. #include <wcstr.h>
  37307.  
  37308. #define  SIZE          10
  37309.  
  37310. int main(void)
  37311. {
  37312.    int result;
  37313.    int index = 3;
  37314.    wchar_t buffer1[SIZE] = L"abcdefg";
  37315.    wchar_t buffer2[SIZE] = L"abcfg";
  37316.    void print_result(int, wchar_t *, wchar_t *);
  37317.  
  37318.    result = wcscmp(buffer1, buffer2);
  37319.    printf("Comparison of each character\n");
  37320.    printf("  wcscmp: ");
  37321.    print_result(result, buffer1, buffer2);
  37322.    result = wcsncmp(buffer1, buffer2, index);
  37323.    printf("\nComparison of only the first %i characters\n", index);
  37324.    printf("  wcsncmp: ");
  37325.    print_result(result, buffer1, buffer2);
  37326.    return 0;
  37327.  
  37328.    /****************************************************************************
  37329.       The output should be:
  37330.  
  37331.       Comparison of each character
  37332.         wcscmp: "abcdefg" is less than "abcfg"
  37333.  
  37334.       Comparison of only the first 3 characters
  37335.         wcsncmp: "abcdefg" is identical to "abcfg"
  37336.    ****************************************************************************/
  37337. }
  37338.  
  37339. void print_result(int res,wchar_t *p_buffer1,wchar_t *p_buffer2)
  37340. {
  37341.    if (0 == res)
  37342.       printf("\"%ls\" is identical to \"%ls\"\n", p_buffer1, p_buffer2);
  37343.    else
  37344.       if (res < 0)
  37345.          printf("\"%ls\" is less than \"%ls\"\n", p_buffer1, p_buffer2);
  37346.       else
  37347.          printf("\"%ls\" is greater than \"%ls\"\n", p_buffer1, p_buffer2);
  37348. }
  37349.  
  37350.  
  37351. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37352.  
  37353. Example of wcsncmp 
  37354.  
  37355.      strncmp - Compare Strings 
  37356.      strcmp - Compare Strings 
  37357.      strcoll - Compare Strings Using Collation Rules 
  37358.      strcmpi - Compare Strings Without Case Sensitivity 
  37359.      stricmp - Compare Strings as Lowercase 
  37360.      strnicmp - Compare Strings Without Case Sensitivity 
  37361.      wcscmp - Compare Wide-Character Strings 
  37362.      wcsncat - Concatenate Wide-Character Strings 
  37363.      wcsncpy - Copy Wide-Character Strings 
  37364.      <wcstr.h> 
  37365.  
  37366.  
  37367. ΓòÉΓòÉΓòÉ 4.371. wcsncpy - Copy Wide-Character Strings ΓòÉΓòÉΓòÉ
  37368.  
  37369.  
  37370. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37371.  
  37372. #include <wcstr.h>
  37373. wchar_t *wcsncpy(wchar_t *string1, const wchar_t *string2, size_t count);
  37374.  
  37375.  
  37376. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37377.  
  37378. Language Level:  SAA, XPG4 
  37379.  
  37380. wcsncpy copies up to count wide characters from string2 to string1. If string2 
  37381. is shorter than count characters, string1 is padded out to count characters 
  37382. with wchar_t null characters. 
  37383.  
  37384. wcsncpy operates on null-terminated wide-character strings; string arguments to 
  37385. this function should contain a wchar_t null character marking the end of the 
  37386. string. 
  37387.  
  37388. Return Value 
  37389. wcsncpy returns a pointer to string1. 
  37390.  
  37391.  
  37392. ΓòÉΓòÉΓòÉ <hidden> Example of wcsncpy ΓòÉΓòÉΓòÉ
  37393.  
  37394. /*************************************************************************
  37395.  
  37396. This example demonstrates the difference between wcscpy, which copies the 
  37397. entire wide-character string, and wcsncpy, which copies a specified number of 
  37398. wide characters from the string. 
  37399.  
  37400. ************************************************************************/
  37401.  
  37402. #include <stdio.h>
  37403. #include <wcstr.h>
  37404.  
  37405. #define  SIZE          40
  37406.  
  37407. int main(void)
  37408. {
  37409.    wchar_t source[SIZE] = L"123456789";
  37410.    wchar_t source1[SIZE] = L"123456789";
  37411.    wchar_t destination[SIZE] = L"abcdefg";
  37412.    wchar_t destination1[SIZE] = L"abcdefg";
  37413.    wchar_t *return_string;
  37414.    int index = 5;
  37415.  
  37416.    /* This is how wcscpy works                                                */
  37417.  
  37418.    printf("destination is originally = '%ls'\n", destination);
  37419.    return_string = wcscpy(destination, source);
  37420.    printf("After wcscpy, destination becomes '%ls'\n\n", return_string);
  37421.  
  37422.    /* This is how wcsncpy works                                               */
  37423.  
  37424.    printf("destination1 is originally = '%ls'\n", destination1);
  37425.    return_string = wcsncpy(destination1, source1, index);
  37426.    printf("After wcsncpy, destination1 becomes '%ls'\n", return_string);
  37427.    return 0;
  37428.  
  37429.    /****************************************************************************
  37430.       The output should be:
  37431.  
  37432.       destination is originally = 'abcdefg'
  37433.       After wcscpy, destination becomes '123456789'
  37434.  
  37435.       destination1 is originally = 'abcdefg'
  37436.       After wcsncpy, destination1 becomes '12345fg'
  37437.    ****************************************************************************/
  37438. }
  37439.  
  37440.  
  37441. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37442.  
  37443. Example of wcsncpy 
  37444.  
  37445.      strcpy - Copy Strings 
  37446.      strncpy - Copy Strings 
  37447.      wcscpy - Copy Wide-Character Strings 
  37448.      wcsncat - Concatenate Wide-Character Strings 
  37449.      wcsncmp - Compare Wide-Character Strings 
  37450.      <wcstr.h> 
  37451.  
  37452.  
  37453. ΓòÉΓòÉΓòÉ 4.372. wcspbrk - Locate Wide Characters in String ΓòÉΓòÉΓòÉ
  37454.  
  37455.  
  37456. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37457.  
  37458. #include <wcstr.h>
  37459. wchar_t *wcspbrk(const wchar_t *string1, const wchar_t *string2);
  37460.  
  37461.  
  37462. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37463.  
  37464. Language Level:  SAA, XPG4 
  37465.  
  37466. wcspbrk locates the first occurrence in the string pointed to by string1 of any 
  37467. wide character from the string pointed to by string2. 
  37468.  
  37469. Return Value 
  37470.  
  37471. wcspbrk returns a pointer to the character. If string1 and string2 have no wide 
  37472. characters in common, wcspbrk returns NULL. 
  37473.  
  37474.  
  37475. ΓòÉΓòÉΓòÉ <hidden> Example of wcspbrk ΓòÉΓòÉΓòÉ
  37476.  
  37477. /************************************************************************
  37478.  
  37479. This example uses wcspbrk to find the first occurrence of either a of b in the 
  37480. array string. 
  37481.  
  37482. ************************************************************************/
  37483.  
  37484. #include <stdio.h>
  37485. #include <wcstr.h>
  37486.  
  37487. int main(void)
  37488. {
  37489.    wchar_t *result;
  37490.    wchar_t *string = L"A Blue Danube";
  37491.    wchar_t *chars = L"ab";
  37492.  
  37493.    result = wcspbrk(string, chars);
  37494.    printf("The first occurrence of any of the characters \"%ls\" in "
  37495.       "\"%ls\" is \"%ls\"\n", chars, string, result);
  37496.    return 0;
  37497.  
  37498.    /****************************************************************************
  37499.       The output should be similar to:
  37500.  
  37501.       The first occurrence of any of the characters "ab" in "A Blue Danube"
  37502.       is "anube"
  37503.    ****************************************************************************/
  37504. }
  37505.  
  37506.  
  37507. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37508.  
  37509. Example of wcspbrk 
  37510.  
  37511.      strchr - Search for Character 
  37512.      strcspn - Compare Strings for Substrings 
  37513.      strpbrk - Find Characters in String 
  37514.      strrchr - Find Last Occurrence of Character in String 
  37515.      strspn - Search Strings 
  37516.      wcschr - Search for Wide Character 
  37517.      wcscmp - Compare Wide-Character Strings 
  37518.      wcscspn - Find Offset of First Wide-Character Match 
  37519.      wcsncmp - Compare Wide-Character Strings 
  37520.      wcsrchr - Locate Wide Character in String 
  37521.      wcsspn - Search Wide-Character Strings 
  37522.      wcswcs - Locate Wide-Character Substring 
  37523.      <wcstr.h> 
  37524.  
  37525.  
  37526. ΓòÉΓòÉΓòÉ 4.373. wcsrchr - Locate Wide Character in String ΓòÉΓòÉΓòÉ
  37527.  
  37528.  
  37529. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37530.  
  37531. #include <wcstr.h>
  37532. wchar_t *wcsrchr(const wchar_t *string, wchar_t character);
  37533.  
  37534.  
  37535. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37536.  
  37537. Language Level:  SAA, XPG4 
  37538.  
  37539. wcsrchr locates the last occurrence of character in the string pointed to by 
  37540. string. The terminating wchar_t null character is considered to be part of the 
  37541. string. 
  37542.  
  37543. Return Value 
  37544. wcsrchr returns a pointer to the character, or a NULL pointer if character does 
  37545. not occur in the string. 
  37546.  
  37547.  
  37548. ΓòÉΓòÉΓòÉ <hidden> Example of wcsrchr ΓòÉΓòÉΓòÉ
  37549.  
  37550. /************************************************************************
  37551.  
  37552. This example compares the use of wcschr and wcsrchr.  It searches the string 
  37553. for the first and last occurrence of p in the wide character string. 
  37554.  
  37555. ************************************************************************/
  37556.  
  37557. #include <stdio.h>
  37558. #include <wcstr.h>
  37559.  
  37560. #define  SIZE          40
  37561.  
  37562. int main(void)
  37563. {
  37564.    wchar_t buf[SIZE] = L"computer program";
  37565.    wchar_t *ptr;
  37566.    int ch = 'p';
  37567.  
  37568.    /* This illustrates wcschr                                                 */
  37569.  
  37570.    ptr = wcschr(buf, ch);
  37571.    printf("The first occurrence of %c in '%ls' is '%ls'\n", ch, buf, ptr);
  37572.  
  37573.    /* This illustrates wscrchr                                                */
  37574.  
  37575.    ptr = wcsrchr(buf, ch);
  37576.    printf("The last occurrence of %c in '%ls' is '%ls'\n", ch, buf, ptr);
  37577.    return 0;
  37578.  
  37579.    /****************************************************************************
  37580.       The output should be:
  37581.  
  37582.       The first occurrence of p in 'computer program' is 'puter program'
  37583.       The last occurrence of p in 'computer program' is 'program'
  37584.    ****************************************************************************/
  37585. }
  37586.  
  37587.  
  37588. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37589.  
  37590. Example of wcsrchr 
  37591.  
  37592.      strchr - Search for Character 
  37593.      strcspn - Compare Strings for Substrings 
  37594.      strpbrk - Find Characters in String 
  37595.      strrchr - Find Last Occurrence of Character in String 
  37596.      strspn - Search Strings 
  37597.      wcschr - Search for Wide Character 
  37598.      wcscspn - Find Offset of First Wide-Character Match 
  37599.      wcsspn - Search Wide-Character Strings 
  37600.      wcswcs - Locate Wide-Character Substring 
  37601.      wcspbrk - Locate Wide Characters in String 
  37602.      <wcstr.h> 
  37603.  
  37604.  
  37605. ΓòÉΓòÉΓòÉ 4.374. wcsrtombs - Convert Wide-Character String to Multibyte String ΓòÉΓòÉΓòÉ
  37606.  
  37607.  
  37608. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37609.  
  37610. #include <wchar.h>
  37611. size_t wcsrtombs (char *dest, const wchar_t **src,
  37612.                   size_t len, mbstate_t *ps);
  37613.  
  37614.  
  37615. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37616.  
  37617. Language Level:  ANSI 93 
  37618.  
  37619. wcsrtombs is a restartable version of wcstombs, and performs the same function. 
  37620. It converts a sequence of wide characters from the array indirectly pointed to 
  37621. by src into a sequence of corresponding multibyte characters. and then stores 
  37622. the converted characters into the array pointed to by dest. 
  37623.  
  37624. Conversion continues up to and including the terminating wchar_t null 
  37625. character. The terminating wchar_t null character is also stored. Conversion 
  37626. stops earlier if a sequence of bytes does not form a valid multibyte character, 
  37627. or when len codes have been stored into the array pointed to by dest. Each 
  37628. conversion takes places as if by a call to the wcrtomb function. 
  37629.  
  37630. wcsrtombs assigns the object pointed to by src either a null pointer (if 
  37631. conversion stopped because a terminating null character was reached) or the 
  37632. address just past the last wide character converted. With wcsrtombs, you can 
  37633. switch from one multibyte string to another. On systems that support shift 
  37634. states, ps represents the initial shift state of the string (0).  If you read 
  37635. in only part of the string, wcsrtombs sets ps to the string's shift state at 
  37636. the point you stopped.  You can then call wcsrtombs again for that string and 
  37637. pass in the updated ps value to continue reading where you left off. 
  37638.  
  37639. Note:  Because OS/2 does not have shift states, the ps parameter is provided 
  37640. only for compatibility with other ANSI/ISO platforms.  VisualAge C++ ignores 
  37641. the value passed for ps. 
  37642.  
  37643. The behavior of wcsrtombs is affected by the LC_CTYPE category of the current 
  37644. locale. 
  37645.  
  37646. Return Value 
  37647. wcsrtombs returns the number of bytes in the resulting multibyte character 
  37648. sequence pointed to by dest. If dest is a null pointer, the value of len is 
  37649. ignored and wcsrtombs returns the number of elements required for the converted 
  37650. wide characters. 
  37651.  
  37652. If the input string contains an invalid wide character, wcsrtombs sets errno to 
  37653. EILSEQ and returns (size_t)-1. 
  37654.  
  37655.  
  37656. ΓòÉΓòÉΓòÉ <hidden> Example of wcsrtombs ΓòÉΓòÉΓòÉ
  37657.  
  37658. /************************************************************************
  37659.  
  37660. This example uses wcsrtombs to convert two wide-character strings to multibyte 
  37661. character strings. 
  37662.  
  37663. ************************************************************************/
  37664.  
  37665. #include <stdlib.h>
  37666. #include <stdio.h>
  37667. #include <locale.h>
  37668. #include <wchar.h>
  37669.  
  37670. #define SIZE  20
  37671.  
  37672. int main(void)
  37673. {
  37674.    wchar_t       wcs1[] = L"abc";
  37675.    wchar_t       wcs2[] = L"A\x8142" L"C";
  37676.    const wchar_t *pwcs1 = wcs1;
  37677.    const wchar_t *pwcs2 = wcs2;
  37678.    mbstate_t     ss1 = 0;
  37679.    mbstate_t     ss2 = 0;
  37680.    char          mb1[SIZE], mb2[SIZE];
  37681.  
  37682.    if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) {
  37683.       printf("setlocale failed.\n");
  37684.       exit(EXIT_FAILURE);
  37685.    }
  37686.    wcsrtombs(mb1, &pwcs1, SIZE, &ss1);
  37687.    wcsrtombs(mb2, &pwcs2, SIZE, &ss2);
  37688.    printf("The first multibyte string is: <%s>\n", mb1);
  37689.    printf("The second multibyte string is: <%s>\n", mb2);
  37690.    return 0;
  37691.  
  37692.    /****************************************************************************
  37693.       The output should be similiar to :
  37694.  
  37695.       The first multibyte string is: <abc>
  37696.       The second multibyte string is: <AΓöÇBC>
  37697.    ****************************************************************************/
  37698. }
  37699.  
  37700.  
  37701. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37702.  
  37703. Example of wcsrtombs 
  37704.  
  37705.      mblen - Determine Length of Multibyte Character 
  37706.      mbrlen - Calculate Length of Multibyte Character 
  37707.      mbrtowc - Convert Multibyte Character to Wide Character 
  37708.      mbsrtowcs - Convert Multibyte String to Wide-Character String 
  37709.      mbstowcs - Convert Multibyte String to Wide-Character String 
  37710.      wcrtomb - Convert Wide Character to Multibyte Character 
  37711.      wcstombs - Convert Wide-Character String to Multibyte String 
  37712.      <wchar.h> 
  37713.  
  37714.  
  37715. ΓòÉΓòÉΓòÉ 4.375. wcsspn - Search Wide-Character Strings ΓòÉΓòÉΓòÉ
  37716.  
  37717.  
  37718. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37719.  
  37720. #include <wcstr.h>
  37721. size_t wcsspn(const wchar_t *string1, const wchar_t *string2);
  37722.  
  37723.  
  37724. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37725.  
  37726. Language Level:  SAA, XPG4 
  37727.  
  37728. wcsspn scans string1 for the wide characters contained in string2. It stops 
  37729. when it encounters a character in string1 that is not in string2. 
  37730.  
  37731. Return Value 
  37732. wcsspn returns the number of wide characters from string2 that it found in 
  37733. string1. 
  37734.  
  37735.  
  37736. ΓòÉΓòÉΓòÉ <hidden> Example of wcsspn ΓòÉΓòÉΓòÉ
  37737.  
  37738. /************************************************************************
  37739.  
  37740. This example finds the first occurrence in the array string of a wide character 
  37741. that is not an a, b, or c.  Because the string in this example is cabbage, 
  37742. wcsspn returns 5, the index of the segment of cabbage before a character that 
  37743. is not an a, b, or c. 
  37744.  
  37745. ************************************************************************/
  37746.  
  37747. #include <stdio.h>
  37748. #include <wcstr.h>
  37749.  
  37750. int main(void)
  37751. {
  37752.    wchar_t *string = L"cabbage";
  37753.    wchar_t *source = L"abc";
  37754.    int index;
  37755.  
  37756.    index = wcsspn(string, L"abc");
  37757.    printf("The first %d characters of \"%ls\" are found in \"%ls\"\n", index,
  37758.       string, source);
  37759.    return 0;
  37760.  
  37761.    /****************************************************************************
  37762.       The output should be:
  37763.  
  37764.       The first 5 characters of "cabbage" are found in "abc"
  37765.    ****************************************************************************/
  37766. }
  37767.  
  37768.  
  37769. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37770.  
  37771. Example of wcsspn 
  37772.  
  37773.      strchr - Search for Character 
  37774.      strcspn - Compare Strings for Substrings 
  37775.      strpbrk - Find Characters in String 
  37776.      strrchr - Find Last Occurrence of Character in String 
  37777.      strspn - Search Strings 
  37778.      wcschr - Search for Wide Character 
  37779.      wcscspn - Find Offset of First Wide-Character Match 
  37780.      wcsrchr - Locate Wide Character in String 
  37781.      wcsspn - Search Wide-Character Strings 
  37782.      wcswcs - Locate Wide-Character Substring 
  37783.      wcspbrk - Locate Wide Characters in String 
  37784.      <wcstr.h> 
  37785.  
  37786.  
  37787. ΓòÉΓòÉΓòÉ 4.376. wcsstr - Locate Wide-Character Substring ΓòÉΓòÉΓòÉ
  37788.  
  37789.  
  37790. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37791.  
  37792. #include <wchar.h>
  37793. wchar_t *wcsstr(const wchar_t *wcs1, const wchar_t *wcs2);
  37794.  
  37795.  
  37796. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37797.  
  37798. Language Level:  ANSI 93 
  37799.  
  37800. wcsstr locates the first occurrence of wcs2 in wcs1. In the matching process, 
  37801. wcsstr ignores the wchar_t null character that ends wcs2. 
  37802.  
  37803. The behavior of wcsstr is affected by the LC_CTYPE category of the current 
  37804. locale. 
  37805.  
  37806. Return Value 
  37807. wcsstr returns a pointer to the beginning of the first occurrence of wcs2 in 
  37808. wcs1. If wcs2 does not appear in wcs1, wcsstr returns NULL. If wcs2 points to a 
  37809. wide-character string with zero length, wcsstr returns wcs1. 
  37810.  
  37811.  
  37812. ΓòÉΓòÉΓòÉ <hidden> Example of wcsstr ΓòÉΓòÉΓòÉ
  37813.  
  37814. /************************************************************************
  37815.  
  37816. This example uses wcsstr to find the first occurrence of hay in the 
  37817. wide-character string needle in a haystack. 
  37818.  
  37819. ************************************************************************/
  37820.  
  37821. #include <stdio.h>
  37822. #include <wchar.h>
  37823.  
  37824. int main(void)
  37825. {
  37826.    wchar_t *wcs1 = L"needle in a haystack";
  37827.    wchar_t *wcs2 = L"hay";
  37828.  
  37829.    printf("result: \"%ls\"\n", wcsstr(wcs1, wcs2));
  37830.    return 0;
  37831.  
  37832.    /****************************************************************************
  37833.       The output should be similar to :
  37834.  
  37835.       result: "haystack"
  37836.    ****************************************************************************/
  37837. }
  37838.  
  37839.  
  37840. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37841.  
  37842. Example of wcsstr 
  37843.  
  37844.      strstr - Locate Substring 
  37845.      wcschr - Search for Wide Character 
  37846.      wcsrchr - Locate Wide Character in String 
  37847.      wcswcs - Locate Wide-Character Substring 
  37848.      <wchar.h> 
  37849.  
  37850.  
  37851. ΓòÉΓòÉΓòÉ 4.377. wcstod - Convert Wide-Character String to Double ΓòÉΓòÉΓòÉ
  37852.  
  37853.  
  37854. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37855.  
  37856. #include <wchar.h>
  37857. double wcstod(const wchar_t *nptr, wchar_t **endptr);
  37858.  
  37859.  
  37860. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37861.  
  37862. Language Level:  ANSI 93, XPG4 
  37863.  
  37864. wcstod converts the wide-character string pointed to by nptr to a double value. 
  37865. The nptr parameter points to a sequence of characters that can be interpreted 
  37866. as a numerical value of type double. wcstod stops reading the string at the 
  37867. first character that it cannot recognize as part of a number. This character 
  37868. can be the wchar_t null character at the end of the string. 
  37869.  
  37870. wcstod expects nptr to point to a string with the following form: 
  37871.  
  37872. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  37873. Γöé                                        Γöé
  37874. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ>         Γöé
  37875. Γöé   ΓööΓöÇwhite-spaceΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ  Γö£ΓöÇdigitsΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöñ           Γöé
  37876. Γöé            ΓööΓöÇΓö┤ΓöÇΓöÿ  Γöé     ΓööΓöÇ.ΓöÇΓöÿ  ΓööΓöÇdigitsΓöÇΓöÿ Γöé           Γöé
  37877. Γöé               ΓööΓöÇ.ΓöÇΓöÇdigitsΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ           Γöé
  37878. Γöé                                        Γöé
  37879. Γöé >ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><                        Γöé
  37880. Γöé   ΓööΓöÇΓö¼ΓöÇeΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇdigitsΓöÇΓöÿ                          Γöé
  37881. Γöé    ΓööΓöÇEΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ                               Γöé
  37882. Γöé       ΓööΓöÇΓö┤ΓöÇΓöÿ                               Γöé
  37883. Γöé                                        Γöé
  37884. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  37885.  
  37886. Note:  The character used for the decimal point (shown as . in the above 
  37887. diagram) depends on the LC_NUMERIC category of the current locale. 
  37888.  
  37889. In locales other than the "C" locale, additional implementation-defined subject 
  37890. sequence forms may be accepted. 
  37891.  
  37892. The behavior of wcstod is affected by the LC_CTYPE category of the current 
  37893. locale. 
  37894.  
  37895. Return Value 
  37896. wcstod function returns the converted double value. If no conversion could be 
  37897. performed, wcstod returns 0. If the correct value is outside the range of 
  37898. representable values, wcstod returns +HUGE_VAL or -HUGE_VAL (according to the 
  37899. sign of the value), and sets errno to ERANGE. If the correct value would cause 
  37900. underflow, wcstod returns 0 and sets errno to ERANGE. 
  37901.  
  37902. If the string nptr points to is empty or does not have the expected form, no 
  37903. conversion is performed, and the value of nptr is stored in the object pointed 
  37904. to by endptr, provided that endptr is not a null pointer. 
  37905.  
  37906.  
  37907. ΓòÉΓòÉΓòÉ <hidden> Example of wcstod ΓòÉΓòÉΓòÉ
  37908.  
  37909. /************************************************************************
  37910.  
  37911. This example uses wcstod to convert the string wcs to a floating-point value. 
  37912.  
  37913. ************************************************************************/
  37914.  
  37915. #include <stdio.h>
  37916. #include <wchar.h>
  37917.  
  37918. int main(void)
  37919. {
  37920.    wchar_t *wcs = L"3.1415926This stopped it";
  37921.    wchar_t *stopwcs;
  37922.  
  37923.    printf("wcs = \"%ls\"\n", wcs);
  37924.    printf("   wcstod = %f\n", wcstod(wcs, &stopwcs));
  37925.    printf("   Stop scanning at \"%ls\"\n", stopwcs);
  37926.    return 0;
  37927.  
  37928.    /****************************************************************************
  37929.       The output should be similar to :
  37930.  
  37931.       wcs = "3.1415926This stopped it"
  37932.          wcstod = 3.141593
  37933.          Stop scanning at "This stopped it"
  37934.    ****************************************************************************/
  37935. }
  37936.  
  37937.  
  37938. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  37939.  
  37940. Example of wcstod 
  37941.  
  37942.      strtod - Convert Character String to Double 
  37943.      strtol - Convert Character String to Long Integer 
  37944.      strtold - Convert String to Long Double 
  37945.      strtoul - Convert String Segment to Unsigned Integer 
  37946.      wcstol - Convert Wide-Character to Long Integer 
  37947.      wcstoul - Convert Wide-Character String to Unsigned Long 
  37948.      <wchar.h> 
  37949.  
  37950.  
  37951. ΓòÉΓòÉΓòÉ 4.378. wcstok - Tokenize Wide-Character String ΓòÉΓòÉΓòÉ
  37952.  
  37953.  
  37954. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  37955.  
  37956. #include <wchar.h>
  37957. wchar_t *wcstok(wchar_t *wcs1, const wchar_t *wcs2, wchar_t **ptr);
  37958.  
  37959.  
  37960. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  37961.  
  37962. Language Level:  ANSI 93, XPG4 
  37963.  
  37964. wcstok reads wcs1 as a series of zero or more tokens and wcs2 as the set of 
  37965. wide characters serving as delimiters for the tokens in wcs1. A sequence of 
  37966. calls to wcstok locates the tokens inside wcs1. The tokens can be separated by 
  37967. one or more of the delimiters from wcs2. The third argument points to a 
  37968. wide-character pointer that you provide where wcstok stores information 
  37969. necessary for it to continue scanning the same string. 
  37970.  
  37971. When wcstok is first called for the wide-character string wcs1, it searches for 
  37972. the first token in wcs1, skipping over leading delimiters. wcstok returns a 
  37973. pointer to the first token. 
  37974.  
  37975. To read the next token from wcs1, call wcstok with NULL as the first parameter 
  37976. (wcs1). This NULL parameter causes wcstok to search for the next token in the 
  37977. previous token string. Each delimiter is replaced by a null character to 
  37978. terminate the token. 
  37979.  
  37980. wcstok always stores enough information in the pointer ptr so that subsequent 
  37981. calls, with NULL as the first paramter and the unmodified pointer value as the 
  37982. third, will start searching right after the previously returned token. You can 
  37983. change the set of delimiters (wcs2) from call to call. 
  37984.  
  37985. The behavior of wcstok function is affected by the LC_CTYPE category of the 
  37986. current locale. 
  37987.  
  37988. Return Value 
  37989. wcstok function returns a pointer to the first wide character of the token, or 
  37990. a null pointer if there is no token. In later calls with the same token string, 
  37991. strtok returns a pointer to the next token in the string.  When there are no 
  37992. more tokens, strtok returns NULL. 
  37993.  
  37994.  
  37995. ΓòÉΓòÉΓòÉ <hidden> Example of wcstok ΓòÉΓòÉΓòÉ
  37996.  
  37997. /************************************************************************
  37998.  
  37999. This example uses wcstok to locate the tokens in the wide-character string 
  38000. str1. 
  38001.  
  38002. ************************************************************************/
  38003.  
  38004. #include <stdio.h>
  38005. #include <wchar.h>
  38006.  
  38007. int main(void)
  38008. {
  38009.    static wchar_t str1[] = L"?a??b,,,#c";
  38010.    static wchar_t str2[] = L"\t \t";
  38011.    wchar_t *t, *ptr1, *ptr2;
  38012.  
  38013.    t = wcstok(str1, L"?", &ptr1);     /* t points to the token L"a"    */
  38014.    printf("t = '%ls'\n", t);
  38015.    t = wcstok(NULL, L",", &ptr1);     /* t points to the token L"?b"   */
  38016.    printf("t = '%ls'\n", t);
  38017.    t = wcstok(str2, L" \t,", &ptr2);  /* t is a null pointer           */
  38018.    printf("t = '%ls'\n", t);
  38019.    t = wcstok(NULL, L"#,", &ptr1);    /* t points to the token L"c"    */
  38020.    printf("t = '%ls'\n", t);
  38021.    t = wcstok(NULL, L"?", &ptr1);     /* t is a null pointer           */
  38022.    printf("t = '%ls'\n", t);
  38023.    return 0;
  38024.  
  38025.    /****************************************************************************
  38026.       The output should be similar to :
  38027.  
  38028.           t = 'a'
  38029.           t = '?b'
  38030.           t = '(null)'
  38031.           t = 'c'
  38032.           t = '(null)'
  38033.    ****************************************************************************/
  38034. }
  38035.  
  38036.  
  38037. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38038.  
  38039. Example of wcstok 
  38040.  
  38041.      strtok - Tokenize String 
  38042.      <wchar.h> 
  38043.  
  38044.  
  38045. ΓòÉΓòÉΓòÉ 4.379. wcstol - Convert Wide-Character to Long Integer ΓòÉΓòÉΓòÉ
  38046.  
  38047.  
  38048. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38049.  
  38050. #include <wchar.h>
  38051. long int wcstol(const wchar_t *nptr, wchar_t **endptr, int base);
  38052.  
  38053.  
  38054. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38055.  
  38056. Language Level:  ANSI 93, XPG4 
  38057.  
  38058. wcstol converts the wide-character string pointed to by nptr to a long integer 
  38059. value. nptr points to a sequence of wide characters that can be interpreted as 
  38060. a numerical value of type long int. wcstol stops reading the string at the 
  38061. first wide character that it cannot recognize as part of a number.  This 
  38062. character can be the wchar_t null character at the end of the string.  The 
  38063. ending character can also be the first numeric character greater than or equal 
  38064. to the base. 
  38065.  
  38066. When you use wcstol, nptr should point to a string with the following form: 
  38067.  
  38068. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  38069. Γöé                                        Γöé
  38070. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><              Γöé
  38071. Γöé   ΓööΓöÇwhite-spaceΓöÇΓöÿ  Γö£ΓöÇ+ΓöÇΓöñ  Γö£ΓöÇ0ΓöÇΓöÇΓöñ  ΓööΓöÇdigitsΓöÇΓöÿ                Γöé
  38072. Γöé            ΓööΓöÇΓö┤ΓöÇΓöÿ  Γö£ΓöÇ0xΓöÇΓöñ                      Γöé
  38073. Γöé               ΓööΓöÇ0XΓöÇΓöÿ                      Γöé
  38074. Γöé                                        Γöé
  38075. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  38076.  
  38077. If base is in the range of 2 through 36, it becomes the base of the number. If 
  38078. base is 0, the prefix determines the base (8, 16, or 10): the prefix 0 means 
  38079. base 8 (octal); the prefix 0x or 0X means base 16 (hexadecimal); using any 
  38080. other digit without a prefix means decimal. 
  38081.  
  38082. In locales other than the "C" locale, additional implementation-defined forms 
  38083. may be accepted. 
  38084.  
  38085. The behavior of wcstol is affected by the LC_CTYPE category of the current 
  38086. locale. 
  38087.  
  38088. Return Value 
  38089. wcstol returns the converted long integer value. If no conversion could be 
  38090. performed, wcstol returns 0. If the correct value is outside the range of 
  38091. representable values, wcstol returns LONG_MAX or LONG_MIN returned (according 
  38092. to the sign of the value), and sets errno to ERANGE. 
  38093.  
  38094. If the string nptr points to is empty or does not have the expected form, no 
  38095. conversion is performed, and the value of nptr is stored in the object pointed 
  38096. to by endptr, provided that endptr is not a null pointer. 
  38097.  
  38098.  
  38099. ΓòÉΓòÉΓòÉ <hidden> Example of wcstol ΓòÉΓòÉΓòÉ
  38100.  
  38101. /************************************************************************
  38102.  
  38103. This example uses wcstol to convert the wide-character string wcs to a long 
  38104. integer value. 
  38105.  
  38106. ************************************************************************/
  38107.  
  38108. #include <stdio.h>
  38109. #include <wchar.h>
  38110.  
  38111. int main(void)
  38112. {
  38113.    wchar_t *wcs = L"10110134932";
  38114.    wchar_t *stopwcs;
  38115.    long     l;
  38116.    int      base;
  38117.  
  38118.    printf("wcs = \"%ls\"\n", wcs);
  38119.    for (base=2; base<=8; base*=2) {
  38120.       l = wcstol(wcs, &stopwcs, base);
  38121.       printf("   wcstol = %ld\n"
  38122.              "   Stopped scan at \"%ls\"\n\n", l, stopwcs);
  38123.    }
  38124.    return 0;
  38125.  
  38126.    /****************************************************************************
  38127.       The output should be similar to :
  38128.  
  38129.       wcs = "10110134932"
  38130.          wcstol = 45
  38131.          Stopped scan at "34932"
  38132.  
  38133.          wcstol = 4423
  38134.          Stopped scan at "4932"
  38135.  
  38136.          wcstol = 2134108
  38137.          Stopped scan at "932"
  38138.  
  38139.    ****************************************************************************/
  38140. }
  38141.  
  38142.  
  38143. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38144.  
  38145. Example of wcstol 
  38146.  
  38147.      atol - Convert Character String to Long Integer 
  38148.      strtol - Convert Character String to Long Integer 
  38149.      strtold - Convert String to Long Double 
  38150.      strtoul - Convert String Segment to Unsigned Integer 
  38151.      wcstod - Convert Wide-Character String to Double 
  38152.      wcstoul - Convert Wide-Character String to Unsigned Long 
  38153.      <wchar.h> 
  38154.  
  38155.  
  38156. ΓòÉΓòÉΓòÉ 4.380. wcstombs - Convert Wide-Character String to Multibyte String ΓòÉΓòÉΓòÉ
  38157.  
  38158.  
  38159. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38160.  
  38161. #include <stdlib.h>
  38162. size_t wcstombs(char *dest, const wchar_t *string, size_t n);
  38163.  
  38164.  
  38165. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38166.  
  38167. Language Level:  ANSI, SAA, XPG4 
  38168.  
  38169. wcstombs converts the wide-character string pointed to by string into the 
  38170. multibyte array pointed to by dest. The conversion stops after n bytes in dest 
  38171. are filled or after a wide null character is encountered. 
  38172.  
  38173. Only complete multibyte characters are stored in dest. If the lack of space in 
  38174. dest would cause a partial multibyte character to be stored, wcstombs stores 
  38175. fewer than n bytes and discards the invalid character. 
  38176.  
  38177. The behavior of wcstombs is affected by the LC_CTYPE category of the current 
  38178. locale. 
  38179.  
  38180. Return Value 
  38181. If successful, wcstombs returns the number of bytes converted and stored in 
  38182. dest, not counting the terminating null character. The string pointed to by 
  38183. dest ends with a null character unless wcstombs returns the value n. 
  38184.  
  38185. If it encounters an invalid wide character, wcstombs returns (size_t)-1. 
  38186.  
  38187. If the area pointed to by dest is too small to contain all the wide characters 
  38188. represented as multibyte characters, wcstombs returns the number of bytes 
  38189. containing complete multibyte characters. 
  38190.  
  38191. If dest is a null pointer, the value of len is ignored and wcstombs returns the 
  38192. number of elements required for the converted wide characters. 
  38193.  
  38194.  
  38195. ΓòÉΓòÉΓòÉ <hidden> Example of wcstombs ΓòÉΓòÉΓòÉ
  38196.  
  38197. /************************************************************************
  38198.  
  38199. In this example, wcstombs converts a wide-character string to a multibyte 
  38200. character string twice. The first call converts the entire string, while the 
  38201. second call only converts three characters. The results are printed each time. 
  38202.  
  38203. ************************************************************************/
  38204.  
  38205. #include <stdio.h>
  38206. #include <stdlib.h>
  38207.  
  38208. #define  SIZE          20
  38209.  
  38210. int main(void)
  38211. {
  38212.    char dest[SIZE];
  38213.    wchar_t *dptr = L"string";
  38214.    size_t count = SIZE;
  38215.    size_t length;
  38216.  
  38217.    length = wcstombs(dest, dptr, count);
  38218.    printf("%d characters were converted.\n", length);
  38219.    printf("The converted string is \"%s\"\n\n", dest);
  38220.  
  38221.    /* Reset the destination buffer                                            */
  38222.  
  38223.    memset(dest, '\0', sizeof(dest));
  38224.  
  38225.    /* Now convert only 3 characters                                           */
  38226.  
  38227.    length = wcstombs(dest, dptr, 3);
  38228.    printf("%d characters were converted.\n", length);
  38229.    printf("The converted string is \"%s\"\n", dest);
  38230.    return 0;
  38231.  
  38232.    /****************************************************************************
  38233.       The output should be:
  38234.  
  38235.       6 characters were converted.
  38236.       The converted string is "string"
  38237.  
  38238.       3 characters were converted.
  38239.       The converted string is "str"
  38240.    ****************************************************************************/
  38241. }
  38242.  
  38243.  
  38244. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38245.  
  38246. Example of wcstombs 
  38247.  
  38248.      mbstowcs - Convert Multibyte String to Wide-Character String 
  38249.      wcslen - Calculate Length of Wide-Character String 
  38250.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  38251.      wctomb -  Convert Wide Character to Multibyte Character 
  38252.      <stdlib.h> 
  38253.  
  38254.  
  38255. ΓòÉΓòÉΓòÉ 4.381. wcstoul - Convert Wide-Character String to Unsigned Long ΓòÉΓòÉΓòÉ
  38256.  
  38257.  
  38258. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38259.  
  38260. #include <wchar.h>
  38261. unsigned long int wcstoul(const wchar_t *nptr, wchar_t **endptr, int base);
  38262.  
  38263.  
  38264. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38265.  
  38266. Language Level:  ANSI, SAA, XPG4 
  38267.  
  38268. wcstoul converts the wide-character string pointed to by nptr to an unsigned 
  38269. long integer value. nptr points to a sequence of wide characters that can be 
  38270. interpreted as a numerical value of type unsigned long int. wcstoul stops 
  38271. reading the string at the first wide character that it cannot recognize as part 
  38272. of a number. This character can be the wchar_t null character at the end of the 
  38273. string.  The ending character can also be the first numeric character greater 
  38274. than or equal to the base. 
  38275.  
  38276. When you use wcstoul, nptr should point to a string with the following form: 
  38277.  
  38278. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  38279. Γöé                                        Γöé
  38280. Γöé >>ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ><                  Γöé
  38281. Γöé   ΓööΓöÇwhite-spaceΓöÇΓöÿ  Γö£ΓöÇ0ΓöÇΓöÇΓöñ  ΓööΓöÇdigitsΓöÇΓöÿ                    Γöé
  38282. Γöé            Γö£ΓöÇ0xΓöÇΓöñ                          Γöé
  38283. Γöé            ΓööΓöÇ0XΓöÇΓöÿ                          Γöé
  38284. Γöé                                        Γöé
  38285. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  38286.  
  38287. If base is in the range of 2 through 36, it becomes the base of the number. If 
  38288. base is 0, the prefix determines the base (8, 16, or 10): the prefix 0 means 
  38289. base 8 (octal); the prefix 0x or 0X means base 16 (hexadecimal); using any 
  38290. other digit without a prefix means decimal. 
  38291.  
  38292. In locales other than the "C" locale, additional implementation-defined subject 
  38293. sequence forms may be accepted. 
  38294.  
  38295. If the subject sequence is empty or does not have the expected form, no 
  38296. conversion is performed and wcstoul stores the value of nptr in the object 
  38297. pointed to by endptr, provided that endptr is not a null pointer. 
  38298.  
  38299. The behavior of wcstoul is affected by the LC_CTYPE category of the current 
  38300. locale. 
  38301.  
  38302. Return Value 
  38303. wcstoul returns the converted unsigned long integer value. If no conversion 
  38304. could be performed, wcstoul returns 0. If the correct value is outside the 
  38305. range of representable values, wcstoul returns ULONG_MAX and sets errno to 
  38306. ERANGE. 
  38307.  
  38308. If the string nptr points to is empty or does not have the expected form, no 
  38309. conversion is performed, and the value of nptr is stored in the object pointed 
  38310. to by endptr, provided that endptr is not a null pointer. 
  38311.  
  38312.  
  38313. ΓòÉΓòÉΓòÉ <hidden> Example of wcstoul ΓòÉΓòÉΓòÉ
  38314.  
  38315. /************************************************************************
  38316.  
  38317. This example uses wcstoul to convert the string wcs to an unsigned long integer 
  38318. value. 
  38319.  
  38320. ************************************************************************/
  38321.  
  38322. #include <stdio.h>
  38323. #include <wchar.h>
  38324.  
  38325. #define BASE 2
  38326.  
  38327. int main(void)
  38328. {
  38329.    wchar_t *wcs = L"1000e13 camels";
  38330.    wchar_t *endptr;
  38331.    unsigned long int answer;
  38332.  
  38333.    answer = wcstoul(wcs, &endptr, BASE);
  38334.    printf("The input wide string used: '%ls'\n"
  38335.           "The unsigned long int produced: %lu\n"
  38336.           "The substring of the input wide string that was not"
  38337.           " converted to unsigned long: '%ls'\n", wcs, answer, endptr);
  38338.    return 0;
  38339.  
  38340.    /****************************************************************************
  38341.       The output should be similar to :
  38342.  
  38343.       The input wide string used: '1000e13 camels'
  38344.       The unsigned long int produced: 8
  38345.       The substring of the input wide string that was not converted to
  38346.       unsigned long: 'e13 camels'
  38347.    ****************************************************************************/
  38348. }
  38349.  
  38350.  
  38351. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38352.  
  38353. Example of wcstoul 
  38354.  
  38355.      strtod - Convert Character String to Double 
  38356.      strtol - Convert Character String to Long Integer 
  38357.      strtol - Convert Character String to Long Integer 
  38358.      strtold - Convert String to Long Double 
  38359.      wcstod - Convert Wide-Character String to Double 
  38360.      wcstol - Convert Wide-Character to Long Integer 
  38361.      <wchar.h> 
  38362.  
  38363.  
  38364. ΓòÉΓòÉΓòÉ 4.382. wcswcs - Locate Wide-Character Substring ΓòÉΓòÉΓòÉ
  38365.  
  38366.  
  38367. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38368.  
  38369. #include <wcstr.h>
  38370. wchar_t *wcswcs(const wchar_t *string1, const wchar_t *string2);
  38371.  
  38372.  
  38373. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38374.  
  38375. Language Level:  SAA, XPG4 
  38376.  
  38377. wcswcs locates the first occurrence of string2 in the wide-character string 
  38378. pointed to by string1. In the matching process, wcswcs ignores the wchar_t null 
  38379. character that ends string2. 
  38380.  
  38381. Return Value 
  38382. wcswcs returns a pointer to the located string or NULL if the string is not 
  38383. found. If string2 points to a string with zero length, wcswcs returns string1. 
  38384.  
  38385.  
  38386. ΓòÉΓòÉΓòÉ <hidden> Example of wcswcs ΓòÉΓòÉΓòÉ
  38387.  
  38388. /*************************************************************************
  38389.  
  38390. This example finds the first occurrence of the wide character string pr in 
  38391. buffer1. 
  38392.  
  38393. ************************************************************************/
  38394.  
  38395. #include <stdio.h>
  38396. #include <wcstr.h>
  38397.  
  38398. #define  SIZE          40
  38399.  
  38400. int main(void)
  38401. {
  38402.    wchar_t buffer1[SIZE] = L"computer program";
  38403.    wchar_t *ptr;
  38404.    wchar_t *wch = L"pr";
  38405.  
  38406.    ptr = wcswcs(buffer1, wch);
  38407.    printf("The first occurrence of %ls in '%ls' is '%ls'\n", wch, buffer1, ptr);
  38408.    return 0;
  38409.  
  38410.    /****************************************************************************
  38411.       The output should be:
  38412.  
  38413.       The first occurrence of pr in 'computer program' is 'program'
  38414.    ****************************************************************************/
  38415. }
  38416.  
  38417.  
  38418. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38419.  
  38420. Example of wcswcs 
  38421.  
  38422.      strchr - Search for Character 
  38423.      strcspn - Compare Strings for Substrings 
  38424.      strpbrk - Find Characters in String 
  38425.      strrchr - Find Last Occurrence of Character in String 
  38426.      strspn - Search Strings 
  38427.      wcschr - Search for Wide Character 
  38428.      wcscspn - Find Offset of First Wide-Character Match 
  38429.      wcspbrk - Locate Wide Characters in String 
  38430.      wcsrchr - Locate Wide Character in String 
  38431.      wcsspn - Search Wide-Character Strings 
  38432.      <wcstr.h> 
  38433.  
  38434.  
  38435. ΓòÉΓòÉΓòÉ 4.383. wcswidth - Determine Display Width of Wide-Character String ΓòÉΓòÉΓòÉ
  38436.  
  38437.  
  38438. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38439.  
  38440. #include <wchar.h>
  38441. int wcswidth (const wchar_t *wcs, size_t n);
  38442.  
  38443.  
  38444. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38445.  
  38446. Language Level:  XPG4 
  38447.  
  38448. wcswidth determines the number of printing positions occupied on a display 
  38449. device by a graphic representation of n wide characters in the string pointed 
  38450. to by wcs (or fewer than n wide characters, if a null wide character is 
  38451. encountered before n characters have been exhausted). The number is independent 
  38452. of its location on the device. 
  38453.  
  38454. The behavior of wcswidth is affected by the LC_CTYPE category. 
  38455.  
  38456. Return Value 
  38457. wcswidth returns the number of printing positions occupied by the 
  38458. wide-character string. If wcs points to a null wide character, wcswidth returns 
  38459. 0. If any wide character in wcs is not a printing character, wcswidth returns 
  38460. -1. 
  38461.  
  38462. Note:  Under VisualAge C++, the printing width is 0 for a null character, 1 for 
  38463. each single-byte character, and 2 for each double-byte character. 
  38464.  
  38465.  
  38466. ΓòÉΓòÉΓòÉ <hidden> Example of wcswidth ΓòÉΓòÉΓòÉ
  38467.  
  38468. /************************************************************************
  38469.  
  38470. This example uses wcswidth to calculate the display width of ABC. 
  38471.  
  38472. ************************************************************************/
  38473.  
  38474. #include <stdio.h>
  38475. #include <wchar.h>
  38476.  
  38477. int main(void)
  38478. {
  38479.    wchar_t *wcs = L"ABC";
  38480.  
  38481.    printf("wcs has a width of: %d\n", wcswidth(wcs,3));
  38482.    return 0;
  38483.  
  38484.    /****************************************************************************
  38485.       The output should be similar to :
  38486.  
  38487.       wcs has a width of: 3
  38488.    ****************************************************************************/
  38489. }
  38490.  
  38491.  
  38492. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38493.  
  38494. Example pf wcswidth 
  38495.  
  38496.      wcwidth - Determine Display Width of Wide Character 
  38497.      <wchar.h> 
  38498.  
  38499.  
  38500. ΓòÉΓòÉΓòÉ 4.384. wcsxfrm - Transform Wide-Character String ΓòÉΓòÉΓòÉ
  38501.  
  38502.  
  38503. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38504.  
  38505. #include <wchar.h>
  38506. size_t wcsxfrm(wchar_t *wcs1, const wchar_t *wcs2, size_t n);
  38507.  
  38508.  
  38509. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38510.  
  38511. Language Level:  ANSI 93, XPG4 
  38512.  
  38513. wcsxfrm transforms the wide-character string pointed to by wcs2 to values that 
  38514. represent character collating weights and places the resulting wide-character 
  38515. string into the array pointed to by wcs1. The transformation is determined by 
  38516. the program's locale. The transformed string is not necessarily readable, but 
  38517. can be used with the wcscmp function. 
  38518.  
  38519. The transformation is such that if wcscmp were applied to two transformed 
  38520. wide-character strings, the results would be the same as applying the wcscoll 
  38521. function to the two corresponding untransformed strings. 
  38522.  
  38523. No more than n elements are placed into the resulting array pointed to by wcs1, 
  38524. including the terminating null wide character. If n is 0, wcs1 can be a null 
  38525. pointer. If copying takes place between objects that overlap, the behavior is 
  38526. undefined. 
  38527.  
  38528. The behavior of wcsxfrm is controlled by the LC_COLLATE category of the current 
  38529. locale. 
  38530.  
  38531. Return Value 
  38532. wcsxfrm returns the length of the transformed wide-character string (excluding 
  38533. the terminating null wide character). If the value returned is n or more, the 
  38534. contents of the array pointed to by wcs1 are indeterminate. 
  38535.  
  38536. If wcs1 is a null pointer, wcsxfrm returns the number of elements required to 
  38537. contain the transformed wide string. 
  38538.  
  38539. If wcs2 contains invalid wide characters, wcsxfrm returns (size_t)-1. The 
  38540. transformed values of the invalid characters are either less than or greater 
  38541. than the transformed values of valid wide characters, depending on the option 
  38542. chosen for the particular locale definition. 
  38543.  
  38544. If wcs2 contains wide characters outside the domain of the collating sequence. 
  38545. wcsxfrm sets errno to EILSEQ. 
  38546.  
  38547.  
  38548. ΓòÉΓòÉΓòÉ <hidden> Example of wcsxfrm ΓòÉΓòÉΓòÉ
  38549.  
  38550. /************************************************************************
  38551.  
  38552. This example uses wcsxfrm to transform two different strings with the same 
  38553. collating weight. It then uses wcscmp to compare the new strings. 
  38554.  
  38555. ************************************************************************/
  38556.  
  38557. #include <stdlib.h>
  38558. #include <stdio.h>
  38559. #include <locale.h>
  38560. #include <wchar.h>
  38561.  
  38562. int main(void)
  38563. {
  38564.    wchar_t *string1 = L"stride ng1";
  38565.    wchar_t *string2 = L"stri*ng1";
  38566.    wchar_t *newstring1, *newstring2;
  38567.    int  length1, length2;
  38568.  
  38569.    if (NULL == setlocale(LC_ALL, LC_C_FRANCE)) {
  38570.       printf("setlocale failed.\n");
  38571.       exit(EXIT_FAILURE);
  38572.    }
  38573.    length1 = wcsxfrm(NULL, string1, 0);
  38574.    length2 = wcsxfrm(NULL, string2, 0);
  38575.    if (NULL == (newstring1 = calloc(length1 + 1, sizeof(wchar_t))) ||
  38576.        NULL == (newstring2 = calloc(length2 + 1, sizeof(wchar_t)))) {
  38577.       printf("insufficient memory\n");
  38578.       exit(EXIT_FAILURE);
  38579.    }
  38580.    if ((wcsxfrm(newstring1, string1, length1 + 1) != length1) ||
  38581.        (wcsxfrm(newstring2, string2, length2 + 1) != length2)) {
  38582.       printf("error in string processing\n");
  38583.       exit(EXIT_FAILURE);
  38584.    }
  38585.    if (0 != wcscmp(newstring1, newstring2))
  38586.       printf("wrong results\n");
  38587.    else
  38588.       printf("correct results\n");
  38589.    return 0;
  38590.  
  38591.    /****************************************************************************
  38592.       The output should be similar to :
  38593.  
  38594.       correct results
  38595.    ****************************************************************************/
  38596. }
  38597.  
  38598.  
  38599. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38600.  
  38601. Example of wcsxfrm 
  38602.  
  38603.      strxfrm - Transform String 
  38604.      wcscmp - Compare Wide-Character Strings 
  38605.      wcscoll - Compare Wide-Character Strings 
  38606.      <wchar.h> 
  38607.  
  38608.  
  38609. ΓòÉΓòÉΓòÉ 4.385. wctob - Convert Wide Character to Byte ΓòÉΓòÉΓòÉ
  38610.  
  38611.  
  38612. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38613.  
  38614. #include <stdio.h>
  38615. #include <wchar.h>
  38616. int wctob(wint_t wc);
  38617.  
  38618.  
  38619. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38620.  
  38621. Language Level:  ANSI 93 
  38622.  
  38623. wctob determines whether wc corresponds to a member of the extended character 
  38624. set, whose multibyte character has a length of 1 byte 
  38625.  
  38626. The behavior of wctob is affected by the LC_CTYPE category of the current 
  38627. locale. 
  38628.  
  38629. Return Value 
  38630. If c corresponds to a multibyte character with a length of 1 byte, wctob 
  38631. returns the single-byte representation. Otherwise, wctob returns EOF. 
  38632.  
  38633.  
  38634. ΓòÉΓòÉΓòÉ <hidden> Example of wctob ΓòÉΓòÉΓòÉ
  38635.  
  38636. /************************************************************************
  38637.  
  38638. This example uses wctob to test if the wide character A is a valid single-byte 
  38639. character. 
  38640.  
  38641. ************************************************************************/
  38642.  
  38643. #include <stdio.h>
  38644. #include <wchar.h>
  38645.  
  38646. int main(void)
  38647. {
  38648.    wint_t wc = L'A';
  38649.  
  38650.    if (wctob(wc) == wc)
  38651.       printf("%lc is a valid single byte character\n", wc);
  38652.    else
  38653.       printf("%lc is not a valid single byte character\n", wc);
  38654.    return 0;
  38655.  
  38656.    /****************************************************************************
  38657.       The output should be similar to :
  38658.  
  38659.       A is a valid single byte character
  38660.    ****************************************************************************/
  38661. }
  38662.  
  38663.  
  38664. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38665.  
  38666. Example of wctob 
  38667.  
  38668.      mbtowc - Convert Multibyte Character to Wide Character 
  38669.      wctomb -  Convert Wide Character to Multibyte Character 
  38670.      wcstombs - Convert Wide-Character String to Multibyte String 
  38671.      <wchar.h> 
  38672.  
  38673.  
  38674. ΓòÉΓòÉΓòÉ 4.386. wctomb -  Convert Wide Character to Multibyte Character ΓòÉΓòÉΓòÉ
  38675.  
  38676.  
  38677. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38678.  
  38679. #include <stdlib.h>
  38680. int wctomb(char *string, wchar_t wc);
  38681.  
  38682.  
  38683. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38684.  
  38685. Language Level:  ANSI, SAA, XPG4 
  38686.  
  38687. wctomb converts the wide character wc into a multibyte character and stores it 
  38688. in the location pointed to by string. wctomb stores a maximum of MB_CUR_MAX 
  38689. characters in string. 
  38690.  
  38691. The behavior of wctomb is affected by the LC_CTYPE category of the current 
  38692. locale. 
  38693.  
  38694. Return Value 
  38695. wctomb returns the length in bytes of the multibyte character. If wc is not a 
  38696. valid multibyte character, wctomb returns -1. 
  38697.  
  38698. If string is a NULL pointer, wctomb returns 0. 
  38699.  
  38700. Note:  On platforms that support shift states, wctomb can also return a nonzero 
  38701. value to indicate that the multibyte encoding is state dependent. Because 
  38702. VisualAge C++ does not support state-dependent encoding, wctomb always returns 
  38703. 0 when string is NULL. 
  38704.  
  38705.  
  38706. ΓòÉΓòÉΓòÉ <hidden> Example of wctomb ΓòÉΓòÉΓòÉ
  38707.  
  38708. /************************************************************************
  38709.  
  38710. This example calls wctomb to convert the wide character c to a multibyte 
  38711. character. 
  38712.  
  38713. ************************************************************************/
  38714.  
  38715. #include <stdio.h>
  38716. #include <wcstr.h>
  38717.  
  38718. #define  SIZE          40
  38719.  
  38720. int main(void)
  38721. {
  38722.    static char buffer[SIZE];
  38723.    wchar_t wch = L'c';
  38724.    int length;
  38725.  
  38726.    length = wctomb(buffer, wch);
  38727.    printf("The number of bytes that comprise the multibyte ""character is %i\n",
  38728.       length);
  38729.    printf("And the converted string is \"%s\"\n", buffer);
  38730.    return 0;
  38731.  
  38732.    /****************************************************************************
  38733.       The output should be:
  38734.  
  38735.       The number of bytes that comprise the multibyte character is 1
  38736.       And the converted string is "c"
  38737.    ****************************************************************************/
  38738. }
  38739.  
  38740.  
  38741. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38742.  
  38743. Example of wctomb 
  38744.  
  38745.      mbtowc - Convert Multibyte Character to Wide Character 
  38746.      wcrtomb - Convert Wide Character to Multibyte Character 
  38747.      wcslen - Calculate Length of Wide-Character String 
  38748.      wcsrtombs - Convert Wide-Character String to Multibyte String 
  38749.      wcstombs - Convert Wide-Character String to Multibyte String 
  38750.      wctob - Convert Wide Character to Byte 
  38751.      <stdlib.h> 
  38752.  
  38753.  
  38754. ΓòÉΓòÉΓòÉ 4.387. wctype - Get Handle for Character Property Classification ΓòÉΓòÉΓòÉ
  38755.  
  38756.  
  38757. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38758.  
  38759. #include <wctype.h>
  38760. wctype_t wctype(const char *property);
  38761.  
  38762.  
  38763. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38764.  
  38765. Language Level:  ANSI 93, XPG4 
  38766.  
  38767. wctype returns a handle for the specified character class from the LC_CTYPE 
  38768. category. You can then use this handle with the iswctype function to determine 
  38769. if a given wide character belongs to that class. 
  38770.  
  38771. The following strings correspond to the standard (basic) character classes or 
  38772. properties: 
  38773.  
  38774. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  38775. Γöé "         Γöé "         Γöé "         Γöé "         Γöé
  38776. Γöé "alnum"      Γöé "cntrl"      Γöé "lower"      Γöé "space"      Γöé
  38777. Γöé "alpha"      Γöé "digit"      Γöé "print"      Γöé "upper"      Γöé
  38778. Γöé "blank" "     Γöé "graph" "     Γöé "punct" "     Γöé "xdigit" "    Γöé
  38779. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  38780.  
  38781. These classes are described in isalnum to isxdigit - Test Integer Value and 
  38782. iswalnum to iswxdigit - Test Wide Integer Value. 
  38783.  
  38784. You can also give the name of a user-defined class, as specified in a locale 
  38785. definition file, as the property argument. 
  38786.  
  38787. The behavior of this wide-character function is affected by the LC_CTYPE 
  38788. category of the current locale. 
  38789.  
  38790. Return Value 
  38791. wctype returns a value of type wctype_t that represents the property and can be 
  38792. used in calls to iswctype. If the given property is not valid for the current 
  38793. locale (LC_CTYPE category), wctype returns 0. 
  38794.  
  38795. Values returned by wctype are valid until a call to setlocale that modifies the 
  38796. LC_CTYPE category. 
  38797.  
  38798.  
  38799. ΓòÉΓòÉΓòÉ <hidden> Example of wctype ΓòÉΓòÉΓòÉ
  38800.  
  38801. /************************************************************************
  38802.  
  38803. This example uses wctype to return each standard property, and calls iswctype 
  38804. to test a wide character against each property. 
  38805.  
  38806. ************************************************************************/
  38807.  
  38808. #include <wctype.h>
  38809. #include <stdio.h>
  38810.  
  38811. #define UPPER_LIMIT 0xFF
  38812.  
  38813. int main(void)
  38814. {
  38815.    int wc;
  38816.  
  38817.    for (wc = 0; wc <= UPPER_LIMIT; wc++) {
  38818.       printf("%#4x ", wc);
  38819.       printf("%c", iswctype(wc, wctype("print"))  ? wc    : ' ');
  38820.       printf("%s", iswctype(wc, wctype("alnum"))  ? " AN" : "   ");
  38821.       printf("%s", iswctype(wc, wctype("alpha"))  ? " A " : "   ");
  38822.       printf("%s", iswctype(wc, wctype("blank"))  ? " B " : "   ");
  38823.       printf("%s", iswctype(wc, wctype("cntrl"))  ? " C " : "   ");
  38824.       printf("%s", iswctype(wc, wctype("digit"))  ? " D " : "   ");
  38825.       printf("%s", iswctype(wc, wctype("graph"))  ? " G " : "   ");
  38826.       printf("%s", iswctype(wc, wctype("lower"))  ? " L " : "   ");
  38827.       printf("%s", iswctype(wc, wctype("punct"))  ? " PU" : "   ");
  38828.       printf("%s", iswctype(wc, wctype("space"))  ? " S " : "   ");
  38829.       printf("%s", iswctype(wc, wctype("print"))  ? " PR" : "   ");
  38830.       printf("%s", iswctype(wc, wctype("upper"))  ? " U " : "   ");
  38831.       printf("%s", iswctype(wc, wctype("xdigit")) ? " X " : "   ");
  38832.       putchar('\n');
  38833.    }
  38834.    return 0;
  38835.  
  38836.    /****************************************************************************
  38837.       The output should be similar to :
  38838.        :
  38839.       0x1f            C
  38840.       0x20         B                 S  PR
  38841.       0x21 !                G     PU    PR
  38842.       0x22 "                G     PU    PR
  38843.       0x23 #                G     PU    PR
  38844.       0x24 $                G     PU    PR
  38845.       0x25 %                G     PU    PR
  38846.       0x26 &                G     PU    PR
  38847.       0x27 '                G     PU    PR
  38848.       0x28 (                G     PU    PR
  38849.       0x29 )                G     PU    PR
  38850.       0x2a *                G     PU    PR
  38851.       0x2b +                G     PU    PR
  38852.       0x2c ,                G     PU    PR
  38853.       0x2d -                G     PU    PR
  38854.       0x2e .                G     PU    PR
  38855.       0x2f /                G     PU    PR
  38856.       0x30 0 AN          D  G           PR    X
  38857.       0x31 1 AN          D  G           PR    X
  38858.       0x32 2 AN          D  G           PR    X
  38859.       0x33 3 AN          D  G           PR    X
  38860.       0x34 4 AN          D  G           PR    X
  38861.       0x35 5 AN          D  G           PR    X
  38862.        :
  38863.    ****************************************************************************/
  38864. }
  38865.  
  38866.  
  38867. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38868.  
  38869. Example of wctype 
  38870.  
  38871.      iswalnum to iswxdigit - Test Wide Integer Value 
  38872.      iswctype - Test for Character Property 
  38873.      <wchar.h> 
  38874.  
  38875.  
  38876. ΓòÉΓòÉΓòÉ 4.388. wcwidth - Determine Display Width of Wide Character ΓòÉΓòÉΓòÉ
  38877.  
  38878.  
  38879. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38880.  
  38881. #include <wchar.h>
  38882. int wcwidth (const wint_t wc);
  38883.  
  38884.  
  38885. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38886.  
  38887. Language Level:  XPG4 
  38888.  
  38889. wcwidth determines the number of printing positions that a graphic 
  38890. representation of wc occupies on a display device. Each of the printing wide 
  38891. characters occupies its own number of printing positions on a display device. 
  38892. The number is independent of its location on the device. 
  38893.  
  38894. The behavior of wcwidth is affected by the LC_CTYPE category. 
  38895.  
  38896. Return Value 
  38897. wcwidth returns the number of printing positions occupied by wc. If wc is a 
  38898. null wide character, wcwidth returns 0.  If wc is not a printing wide 
  38899. character, wc returns -1. 
  38900.  
  38901. Note:  Under VisualAge C++, the printing width is 0 for a null character, 1 for 
  38902. a single-byte character, and 2 for a double-byte character. 
  38903.  
  38904.  
  38905. ΓòÉΓòÉΓòÉ <hidden> Example of wcwidth ΓòÉΓòÉΓòÉ
  38906.  
  38907. /************************************************************************
  38908.  
  38909. This example determines the printing width for the wide character A. 
  38910.  
  38911. ************************************************************************/
  38912.  
  38913. #include <stdio.h>
  38914. #include <wchar.h>
  38915.  
  38916. int main(void)
  38917. {
  38918.    wint_t wc = L'A';
  38919.  
  38920.    printf("%lc has a width of %d\n", wc, wcwidth(wc));
  38921.    return 0;
  38922.  
  38923.    /****************************************************************************
  38924.       The output should be similar to :
  38925.  
  38926.       A has a width of 1
  38927.    ****************************************************************************/
  38928. }
  38929.  
  38930.  
  38931. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  38932.  
  38933. Example of wcwidth 
  38934.  
  38935.      wcswidth - Determine Display Width of Wide-Character String 
  38936.      <wchar.h> 
  38937.  
  38938.  
  38939. ΓòÉΓòÉΓòÉ 4.389. write - Writes from Buffer to File ΓòÉΓòÉΓòÉ
  38940.  
  38941.  
  38942. ΓòÉΓòÉΓòÉ <hidden> Format ΓòÉΓòÉΓòÉ
  38943.  
  38944. #include <io.h>
  38945. int write(int handle, const void *buffer, unsigned int count);
  38946.  
  38947.  
  38948. ΓòÉΓòÉΓòÉ <hidden> Description ΓòÉΓòÉΓòÉ
  38949.  
  38950. Language Level:  XPG4, Extension 
  38951.  
  38952. write writes count bytes from buffer into the file associated with handle. The 
  38953. write operation begins at the current position of the file pointer associated 
  38954. with the given file. If the file is open for appending, the operation begins at 
  38955. the end of the file. After the write operation, the file pointer is increased 
  38956. by the number of bytes actually written. 
  38957.  
  38958. If the given file was opened in text mode, each line feed character is replaced 
  38959. with a carriage return/line feed pair in the output.  The replacement does not 
  38960. affect the return value. 
  38961.  
  38962. Note:  In earlier releases of C Set ++, write began with an underscore 
  38963. (_write). Because it is defined by the X/Open standard, the underscore has been 
  38964. removed. For compatibility, VisualAge C++ will map _write to write for you. 
  38965.  
  38966. Return Value 
  38967. write returns the number of bytes moved from the buffer to the file. The return 
  38968. value may be positive but less than count. A return value of -1 indicates an 
  38969. error, and errno is set to one of the following values: 
  38970.  
  38971.  Value         Meaning 
  38972.  EBADF         The file handle is not valid, or the file is not open for 
  38973.                writing. 
  38974.  ENOSPC        No space is left on the device. 
  38975.  EOS2ERR       The call to the operating system was not successful. 
  38976.  
  38977.  
  38978. ΓòÉΓòÉΓòÉ <hidden> Example of write ΓòÉΓòÉΓòÉ
  38979.  
  38980. /************************************************************************
  38981.  
  38982. This example writes the contents of the character array buffer to the output 
  38983. file whose handle is fh. 
  38984.  
  38985. ************************************************************************/
  38986.  
  38987. #include <io.h>
  38988. #include <stdio.h>
  38989. #include <stdlib.h>
  38990. #include <fcntl.h>
  38991. #include <string.h>
  38992.  
  38993. #define FILENAME  "write.dat"
  38994.  
  38995. int main(void)
  38996. {
  38997.    int fh;
  38998.    char buffer[20];
  38999.  
  39000.    memset(buffer, 'a', 20);                 /* initialize storage             */
  39001.    printf("\nCreating " FILENAME ".\n");
  39002.    system("echo Sample Program > " FILENAME);
  39003.    if (-1 == (fh = open(FILENAME, O_RDWR|O_APPEND))) {
  39004.       perror("Unable to open " FILENAME);
  39005.       return EXIT_FAILURE;
  39006.    }
  39007.    if (5 != write(fh, buffer, 5)) {
  39008.       perror("Unable to write to " FILENAME);
  39009.       close(fh);
  39010.       return EXIT_FAILURE;
  39011.    }
  39012.    printf("Successfully appended 5 characters.\n");
  39013.    close(fh);
  39014.    return 0;
  39015.  
  39016.    /****************************************************************************
  39017.       The program should create a file "write.dat" containing:
  39018.  
  39019.       Sample Program
  39020.       aaaaa
  39021.  
  39022.       The output should be:
  39023.  
  39024.       Creating write.dat.
  39025.       Successfully appended 5 characters.
  39026.    ****************************************************************************/
  39027. }
  39028.  
  39029.  
  39030. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39031.  
  39032. Example of write 
  39033.  
  39034.      creat - Create New File 
  39035.      fread - Read Items 
  39036.      fwrite - Write Items 
  39037.      lseek - Move File Pointer 
  39038.      open - Open File 
  39039.      read - Read Into Buffer 
  39040.      _sopen - Open Shared File 
  39041.      _tell - Get Pointer Position 
  39042.      <io.h> 
  39043.  
  39044.  
  39045. ΓòÉΓòÉΓòÉ 5. Include Files ΓòÉΓòÉΓòÉ
  39046.  
  39047. The include files provided with the runtime library contain macro and constant 
  39048. definitions, type definitions, and function declarations.  Some functions 
  39049. require definitions and declarations from include files to work properly. The 
  39050. inclusion of files is optional, as long as the necessary statements from the 
  39051. files are coded directly into the source. 
  39052.  
  39053. Note:  If you change the default calling convention (using one of the /M 
  39054. options), you must include the appropriate header files with the declarations 
  39055. of the library functions that you use. 
  39056.  
  39057. This section describes each include file, explains its contents, and lists the 
  39058. functions that are declared in the file. 
  39059.  
  39060.      <assert.h> 
  39061.      <builtin.h> 
  39062.      <collate.h> 
  39063.      <conio.h> 
  39064.      <ctype.h> 
  39065.      <direct.h> 
  39066.      <errno.h> 
  39067.      <fcntl.h> 
  39068.      <float.h> 
  39069.      <io.h> 
  39070.      <langinfo.h> 
  39071.      <limits.h> 
  39072.      <locale.h> 
  39073.      <malloc.h> 
  39074.      <math.h> 
  39075.      <memory.h> 
  39076.      <monetary.h> 
  39077.      <nl_types.h> 
  39078.      <process.h> 
  39079.      <regex.h> 
  39080.      <search.h> 
  39081.      <setjmp.h> 
  39082.      <share.h> 
  39083.      <signal.h> 
  39084.      <stdarg.h> 
  39085.      <stddef.h> 
  39086.      <stdio.h> 
  39087.      <stdlib.h> 
  39088.      <string.h> 
  39089.      <sys\stat.h> 
  39090.      <sys\timeb.h> 
  39091.      <sys\types.h> 
  39092.      <sys\utime.h> 
  39093.      <time.h> 
  39094.      <umalloc.h> 
  39095.      <variant.h> 
  39096.      <wchar.h> 
  39097.      <wcstr.h> 
  39098.  
  39099.  
  39100. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39101.  
  39102.      #include 
  39103.  
  39104.  
  39105. ΓòÉΓòÉΓòÉ 5.1. <assert.h> ΓòÉΓòÉΓòÉ
  39106.  
  39107. The <assert.h> include file defines the assert macro.  You must include 
  39108. assert.h when you use assert. 
  39109.  
  39110. The definition of assert is in an #ifndef preprocessor block.  If you have not 
  39111. defined the identifier NDEBUG through a #define directive or on the compiler 
  39112. command line, the assert macro tests a given expression (the assertion).  If 
  39113. the assertion is false, the system prints a message to stderr and an abort 
  39114. signal is raised for the program. 
  39115.  
  39116. If NDEBUG is defined, assert is defined to do nothing. You can suppress program 
  39117. assertions by defining NDEBUG. 
  39118.  
  39119.  
  39120. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39121.  
  39122.      #define 
  39123.      #ifndef 
  39124.      Include Files 
  39125.      #include 
  39126.  
  39127.  
  39128. ΓòÉΓòÉΓòÉ 5.2. <builtin.h> ΓòÉΓòÉΓòÉ
  39129.  
  39130. The <builtin.h> include file declares the following built-in and intrinsic 
  39131. functions: 
  39132.  
  39133.  _alloca             _clear87 
  39134.  _control87          _crotl 
  39135.  _crotr              _disable 
  39136.  _enable             _facos 
  39137.  _fasin              _fcos 
  39138.  _fcossin            _fpatan 
  39139.  _fptan              _fsin 
  39140.  _fsincos            _fyl2x 
  39141.  _fyl2xp1            _f2xm1 
  39142.  _getTIBvalue        _inp 
  39143.  _inpd               _inpw 
  39144.  _interrupt          _lrotl 
  39145.  _lrotr              _outp 
  39146.  _outpd              _outpw 
  39147.  _rotl               _rotr 
  39148.  _srotl              _srotr 
  39149.  __parmdwords        _status87 
  39150.  
  39151.  _clear87, _control87, and _status87 are also defined in <float.h>. _alloca is 
  39152.  also defined in <stdlib.h> and <malloc.h>. The functions _inp, _inpd, _inpw, 
  39153.  _outp, _outpd, and _outpw are also defined in <conio.h>. 
  39154.  
  39155.  <builtin.h> also includes a declaration for the type size_t. 
  39156.  
  39157.  
  39158. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39159.  
  39160.      Intrinsic Functions 
  39161.      Include Files 
  39162.      #include 
  39163.  
  39164.  
  39165. ΓòÉΓòÉΓòÉ 5.3. <collate.h> ΓòÉΓòÉΓòÉ
  39166.  
  39167. The <collate.h> include file declares functions that retrieve information about 
  39168. the current locale's collating properties: 
  39169.  
  39170.  cclass              collequiv 
  39171.  collorder           collrange 
  39172.  colltostr           getmccoll 
  39173.  getwmccoll          ismccollel 
  39174.  maxcoll             strtocoll 
  39175.  
  39176.  
  39177. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39178.  
  39179.      Locales in the Programming Guide 
  39180.      <locale.h> 
  39181.      setlocale - Set Locale 
  39182.      Include Files 
  39183.      #include 
  39184.  
  39185.  
  39186. ΓòÉΓòÉΓòÉ 5.4. <conio.h> ΓòÉΓòÉΓòÉ
  39187.  
  39188. The <conio.h> include file defines the functions that involve screen and 
  39189. console input and output: 
  39190.  
  39191.  _cgets              _cprintf 
  39192.  _cputs              _cscanf 
  39193.  _getch              _getche 
  39194.  _inp                _inpd 
  39195.  _inpw               _kbhit 
  39196.  _outp               _outpd 
  39197.  _outpw              _putch 
  39198.  _ungetch 
  39199.  
  39200.  
  39201. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39202.  
  39203.      <io.h> 
  39204.      <stdio.h> 
  39205.      Include Files 
  39206.      #include 
  39207.  
  39208.  
  39209. ΓòÉΓòÉΓòÉ 5.5. <ctype.h> ΓòÉΓòÉΓòÉ
  39210.  
  39211. The <ctype.h> include file defines functions used in character classification. 
  39212. The functions defined in <ctype.h> are: 
  39213.  
  39214.  isalnum             isalpha 
  39215.  iscntrl             isdigit 
  39216.  isgraph             islower 
  39217.  isprint             ispunct 
  39218.  isspace             isupper 
  39219.  isxdigit            tolower 
  39220.  toupper 
  39221.  
  39222.  In extended mode, <ctype.h> also includes definitions for the following 
  39223.  VisualAge C++ extensions: 
  39224.  
  39225.  isascii             _iscsym 
  39226.  _iscsymf            _toascii 
  39227.  _tolower            _toupper 
  39228.  
  39229.  In the VisualAge C++ compiler, the <ctype.h> functions are all implemented as 
  39230.  macros. 
  39231.  
  39232.  
  39233. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39234.  
  39235.      Include Files 
  39236.      #include 
  39237.  
  39238.  
  39239. ΓòÉΓòÉΓòÉ 5.6. <direct.h> ΓòÉΓòÉΓòÉ
  39240.  
  39241. The <direct.h> include file defines functions that control directories and 
  39242. drives. The functions defined in <direct.h> are: 
  39243.  
  39244.  chdir               _chdrive 
  39245.  _getcwd             _getdcwd 
  39246.  _getdrive           mkdir 
  39247.  rmdir 
  39248.  
  39249.  
  39250. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39251.  
  39252.      Include Files 
  39253.      #include 
  39254.  
  39255.  
  39256. ΓòÉΓòÉΓòÉ 5.7. <errno.h> ΓòÉΓòÉΓòÉ
  39257.  
  39258. The <errno.h> include file defines symbolic macro names, such as EDOM and 
  39259. ERANGE, for runtime errors, and a modifiable lvalue having type int called 
  39260. errno. It also defines the global variable _doserrno, which is determined by 
  39261. the OS/2 error code when an operating system error occurs. 
  39262.  
  39263. See Runtime Return Codes and Messages for a list of the runtime error messages 
  39264. and the errno values associated with each message. 
  39265.  
  39266. Note:  If you are going to test the value of errno after library function 
  39267. calls, first set it to 0, because its value may not be reset during the call. 
  39268.  
  39269. The definitions of errno and _doserrno are also provided in stdlib.h. 
  39270.  
  39271.  
  39272. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39273.  
  39274.      Runtime Return Codes and Messages 
  39275.      <stdlib.h> 
  39276.      Include Files 
  39277.      #include 
  39278.  
  39279.  
  39280. ΓòÉΓòÉΓòÉ 5.8. <fcntl.h> ΓòÉΓòÉΓòÉ
  39281.  
  39282. The <fcntl.h> include file defines constants used by the open and _sopen 
  39283. functions. Definitions for these two functions are included in <io.h>. 
  39284. Additional definitions for _sopen are provided in <share.h>. 
  39285.  
  39286.  
  39287. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39288.  
  39289.      <io.h> 
  39290.      <share.h> 
  39291.      Include Files 
  39292.      #include 
  39293.  
  39294.  
  39295. ΓòÉΓòÉΓòÉ 5.9. <float.h> ΓòÉΓòÉΓòÉ
  39296.  
  39297. The <float.h> include file defines constants that specify the ranges of 
  39298. floating-point data types, for example, the maximum number of digits for 
  39299. objects of type double or the minimum exponent for objects of type float. 
  39300.  
  39301. In extended mode, <float.h> also defines the macros that represent infinity and 
  39302. NaN (not-a-number) values, and defines the following functions that manipulate 
  39303. the floating-point control and status words, and for the constants that they 
  39304. use: 
  39305.  
  39306.  _clear87            _control87 
  39307.  _fpreset            _status87 
  39308.  
  39309.  
  39310. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39311.  
  39312.      Infinity and NaN Support 
  39313.      Floating-Point Variables 
  39314.      Include Files 
  39315.      #include 
  39316.  
  39317.  
  39318. ΓòÉΓòÉΓòÉ 5.10. <iconv.h> ΓòÉΓòÉΓòÉ
  39319.  
  39320. The <iconv.h> include file declares the iconv_open, iconv, and iconv_close 
  39321. functions to convert characters from one character set definition to another. 
  39322. The ICONV utility also uses these functions. 
  39323.  
  39324. iconv.h also declares the iconv_t type, which is a pointer to an object capable 
  39325. of storing the information about the opened converters used. 
  39326.  
  39327.  
  39328. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39329.  
  39330.      Include Files 
  39331.      iconv Utility in the User's Guide. 
  39332.  
  39333.  
  39334. ΓòÉΓòÉΓòÉ 5.11. <io.h> ΓòÉΓòÉΓòÉ
  39335.  
  39336. The <io.h> include file defines the following file handle and low-level input 
  39337. and output functions: 
  39338.  
  39339.  access              chmod 
  39340.  _chsize             close 
  39341.  creat               dup 
  39342.  dup2                __eof 
  39343.  _filelength         isatty 
  39344.  lseek               open 
  39345.  read                remove 
  39346.  rename              _setmode 
  39347.  _sopen              _tell 
  39348.  umask               unlink 
  39349.  write 
  39350.  
  39351.  Two additional functions, fstat and stat, are defined in <sys\stat.h>. 
  39352.  
  39353.  Constants required by the open and _sopen functions are provided in <fcntl.h>. 
  39354.  Additional constants used by _sopen are defined in <share.h>. 
  39355.  
  39356.  The unlink function is also defined in <stdio.h>. 
  39357.  
  39358.  
  39359. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39360.  
  39361.      <fcntl.h> 
  39362.      <share.h> 
  39363.      <sys\stat.h> 
  39364.      <stdlib.h> 
  39365.      <conio.h> 
  39366.      <stdio.h> 
  39367.      Include Files 
  39368.      #include 
  39369.  
  39370.  
  39371. ΓòÉΓòÉΓòÉ 5.12. <langinfo.h> ΓòÉΓòÉΓòÉ
  39372.  
  39373. The <langinfo.h> include file declares the nl_langinfo function. The include 
  39374. file also defines the macros that, in turn, define constants that are used to 
  39375. identify the information queried in the current locale, and the nl_item type, 
  39376. which is the type of the constants. The following macros are defined: 
  39377.  
  39378.  ABDAY_1        Abbreviated first day of the week 
  39379.  ABDAY_2        Abbreviated second day of the week 
  39380.  ABDAY_3        Abbreviated third day of the week 
  39381.  ABDAY_4        Abbreviated fourth day of the week 
  39382.  ABDAY_5        Abbreviated fifth day of the week 
  39383.  ABDAY_6        Abbreviated sixth day of the week 
  39384.  ABDAY_7        Abbreviated seventh day of the week 
  39385.  ABMON_1        Abbreviated first month 
  39386.  ABMON_2        Abbreviated second month 
  39387.  ABMON_3        Abbreviated third month 
  39388.  ABMON_4        Abbreviated fourth month 
  39389.  ABMON_5        Abbreviated fifth month 
  39390.  ABMON_6        Abbreviated sixth month 
  39391.  ABMON_7        Abbreviated seventh month 
  39392.  ABMON_8        Abbreviated eighth month 
  39393.  ABMON_9        Abbreviated ninth month 
  39394.  ABMON_10       Abbreviated tenth month 
  39395.  ABMON_11       Abbreviated eleventh month 
  39396.  ABMON_12       Abbreviated twelfth month 
  39397.  AM_STR         String for morning 
  39398.  CODESET        Current encoded character set of the process 
  39399.  CRNCYSTR       Currency symbol 
  39400.  D_FMT          String for formatting date 
  39401.  D_T_FMT        String for formatting date and time 
  39402.  DAY_1          Name of the first day of the week 
  39403.  DAY_2          Name of the second day of the week 
  39404.  DAY_3          Name of the third day of the week 
  39405.  DAY_4          Name of the fourth day of the week 
  39406.  DAY_5          Name of the fifth day of the week 
  39407.  DAY_6          Name of the sixth day of the week 
  39408.  DAY_7          Name of the seventh day of the week 
  39409.  MON_1          Name of the first month 
  39410.  MON_2          Name of the second month 
  39411.  MON_3          Name of the third month 
  39412.  MON_4          Name of the fourth month 
  39413.  MON_5          Name of the fifth month 
  39414.  MON_6          Name of the sixth month 
  39415.  MON_7          Name of the seventh month 
  39416.  MON_8          Name of the eighth month 
  39417.  MON_9          Name of the ninth month 
  39418.  MON_10         Name of the tenth month 
  39419.  MON_11         Name of the eleventh month 
  39420.  MON_12         Name of the twelfth month 
  39421.  NOEXPR         Negative response expression 
  39422.  PM_STR         String for afternoon 
  39423.  RADIXCHAR      Radix character 
  39424.  T_FMT          String for formatting time 
  39425.  T_FMT_AMPM     String for morning or afternoon time format 
  39426.  THOUSEP        Separator for thousands 
  39427.  YESEXPR        Affirmative response expression 
  39428.  
  39429.  
  39430. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39431.  
  39432.      <locale.h> 
  39433.      setlocale - Set Locale 
  39434.      Introduction to Locale in the Programming Guide 
  39435.      Include Files 
  39436.      #include 
  39437.  
  39438.  
  39439. ΓòÉΓòÉΓòÉ 5.13. <lc_core.h> ΓòÉΓòÉΓòÉ
  39440.  
  39441. The <lc_core.h> include file declares the LOCALDEF utility. Do not include it 
  39442. in your source code. 
  39443.  
  39444.  
  39445. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39446.  
  39447.      LOCALDEF Utility in the User's Guide 
  39448.      Introduction to Locale in the Programming Guide 
  39449.      Include Files 
  39450.  
  39451.  
  39452. ΓòÉΓòÉΓòÉ 5.14. <limits.h> ΓòÉΓòÉΓòÉ
  39453.  
  39454. The <limits.h> include file defines constants that specify the ranges of 
  39455. integer and character data types, such as the maximum value for an object of 
  39456. type char. 
  39457.  
  39458.  
  39459. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39460.  
  39461.      Characters 
  39462.      Integers 
  39463.      Include Files 
  39464.      #include 
  39465.  
  39466.  
  39467. ΓòÉΓòÉΓòÉ 5.15. <localdef.h> ΓòÉΓòÉΓòÉ
  39468.  
  39469. The <localdef.h> include file declares the LOCALDEF utility. Do not include it 
  39470. in your source code. 
  39471.  
  39472.  
  39473. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39474.  
  39475.      LOCALDEF Utility in the User's Guide 
  39476.      Introduction to Locale in the Programming Guide 
  39477.      Include Files 
  39478.  
  39479.  
  39480. ΓòÉΓòÉΓòÉ 5.16. <locale.h> ΓòÉΓòÉΓòÉ
  39481.  
  39482. The <locale.h> include file declares the localdtconv, localeconv, and setlocale 
  39483. library functions, which are useful for changing the C locale when you are 
  39484. creating applications for international users. <locale.h> also declares the 
  39485. lconv structure. 
  39486.  
  39487. The table below shows the elements of the lconv structure as well as the 
  39488. defaults for the C locale. 
  39489.  
  39490. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  39491. Γöé ELEMENT        Γöé PURPOSE OF ELEMENT       Γöé DEFAULT   Γöé
  39492. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39493. Γöé "char         Γöé Decimal-point character used  Γöé "."     Γöé
  39494. Γöé *decimal_point"    Γöé to format nonmonetary quanti-  Γöé       Γöé
  39495. Γöé            Γöé ties.              Γöé       Γöé
  39496. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39497. Γöé "char         Γöé Character used to separate   Γöé ""     Γöé
  39498. Γöé *thousands_sep"    Γöé groups of digits to the left  Γöé       Γöé
  39499. Γöé            Γöé of the decimal-point character Γöé       Γöé
  39500. Γöé            Γöé in formatted nonmonetary quan- Γöé       Γöé
  39501. Γöé            Γöé tities.             Γöé       Γöé
  39502. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39503. Γöé "char *grouping"   Γöé String indicating the size of  Γöé ""     Γöé
  39504. Γöé            Γöé each group of digits in for-  Γöé       Γöé
  39505. Γöé            Γöé matted nonmonetary quantities. Γöé       Γöé
  39506. Γöé            Γöé The value of each character in Γöé       Γöé
  39507. Γöé            Γöé the string determines the    Γöé       Γöé
  39508. Γöé            Γöé number of digits in a group.  Γöé       Γöé
  39509. Γöé            Γöé A value of "CHAR_MAX" indi-   Γöé       Γöé
  39510. Γöé            Γöé cates that there are no     Γöé       Γöé
  39511. Γöé            Γöé further groupings.  0 indi-   Γöé       Γöé
  39512. Γöé            Γöé cates that the previous     Γöé       Γöé
  39513. Γöé            Γöé element is to be used for the  Γöé       Γöé
  39514. Γöé            Γöé remainder of the digits.    Γöé       Γöé
  39515. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39516. Γöé "char         Γöé International currency symbol  Γöé ""     Γöé
  39517. Γöé *int_curr_symbol"   Γöé for the current locale.  The  Γöé       Γöé
  39518. Γöé            Γöé first three characters contain Γöé       Γöé
  39519. Γöé            Γöé the alphabetic international  Γöé       Γöé
  39520. Γöé            Γöé currency symbol.  The fourth  Γöé       Γöé
  39521. Γöé            Γöé character (usually a space) is Γöé       Γöé
  39522. Γöé            Γöé the character used to separate Γöé       Γöé
  39523. Γöé            Γöé the international currency   Γöé       Γöé
  39524. Γöé            Γöé symbol from the monetary quan- Γöé       Γöé
  39525. Γöé            Γöé tity.              Γöé       Γöé
  39526. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39527. Γöé "char         Γöé Local currency symbol of the  Γöé ""     Γöé
  39528. Γöé *currency_symbol"   Γöé current locale.         Γöé       Γöé
  39529. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39530. Γöé "char         Γöé Decimal-point character used  Γöé "."     Γöé
  39531. Γöé *mon_decimal_point"  Γöé to format monetary quantities. Γöé       Γöé
  39532. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39533. Γöé "char         Γöé Separator for digits in for-  Γöé ""     Γöé
  39534. Γöé *mon_thousands_sep"  Γöé matted monetary quantities.   Γöé       Γöé
  39535. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39536. Γöé "char *mon_grouping" Γöé String indicating the size of  Γöé ""     Γöé
  39537. Γöé            Γöé each group of digits in for-  Γöé       Γöé
  39538. Γöé            Γöé matted monetary quantities.   Γöé       Γöé
  39539. Γöé            Γöé The value of each character in Γöé       Γöé
  39540. Γöé            Γöé the string determines the    Γöé       Γöé
  39541. Γöé            Γöé number of digits in a group.  Γöé       Γöé
  39542. Γöé            Γöé A value of "CHAR_MAX" indi-   Γöé       Γöé
  39543. Γöé            Γöé cates that there are no     Γöé       Γöé
  39544. Γöé            Γöé further groupings.  0 indi-   Γöé       Γöé
  39545. Γöé            Γöé cates that the previous     Γöé       Γöé
  39546. Γöé            Γöé element is to be used for the  Γöé       Γöé
  39547. Γöé            Γöé remainder of the digits.    Γöé       Γöé
  39548. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39549. Γöé "char         Γöé String indicating the positive Γöé ""     Γöé
  39550. Γöé *positive_sign"    Γöé sign used in monetary quanti-  Γöé       Γöé
  39551. Γöé            Γöé ties.              Γöé       Γöé
  39552. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39553. Γöé "char         Γöé String indicating the negative Γöé ""     Γöé
  39554. Γöé *negative_sign"    Γöé sign used in monetary quanti-  Γöé       Γöé
  39555. Γöé            Γöé ties.              Γöé       Γöé
  39556. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39557. Γöé "char         Γöé The number of displayed digits Γöé "UCHAR_MAX"Γöé
  39558. Γöé int_frac_digits"   Γöé to the right of the decimal   Γöé       Γöé
  39559. Γöé            Γöé place for internationally for- Γöé       Γöé
  39560. Γöé            Γöé matted monetary quantities.   Γöé       Γöé
  39561. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39562. Γöé "char frac_digits"  Γöé Number of digits to the right  Γöé "UCHAR_MAX"Γöé
  39563. Γöé            Γöé of the decimal place in mone-  Γöé       Γöé
  39564. Γöé            Γöé tary quantities.        Γöé       Γöé
  39565. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39566. Γöé "char p_cs_precedes" Γöé 1 if the "currency_symbol"   Γöé "UCHAR_MAX"Γöé
  39567. Γöé            Γöé precedes the value for a non-  Γöé       Γöé
  39568. Γöé            Γöé negative formatted monetary   Γöé       Γöé
  39569. Γöé            Γöé quantity; 0 if it does not.   Γöé       Γöé
  39570. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  39571. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  39572. Γöé "char         Γöé 1 if the "currency_symbol" is  Γöé "UCHAR_MAX"Γöé
  39573. Γöé p_sep_by_space"    Γöé separated by a space from the  Γöé       Γöé
  39574. Γöé            Γöé value of a nonnegative for-   Γöé       Γöé
  39575. Γöé            Γöé matted monetary quantity; 0 if Γöé       Γöé
  39576. Γöé            Γöé it does not; 2 if a space sep- Γöé       Γöé
  39577. Γöé            Γöé arates the symbol and the sign Γöé       Γöé
  39578. Γöé            Γöé string-if adjacent.       Γöé       Γöé
  39579. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39580. Γöé "char n_cs_precedes" Γöé 1 if the "currency_symbol"   Γöé "UCHAR_MAX"Γöé
  39581. Γöé            Γöé precedes the value for a nega- Γöé       Γöé
  39582. Γöé            Γöé tive formatted monetary quan-  Γöé       Γöé
  39583. Γöé            Γöé tity; 0 if it does not.     Γöé       Γöé
  39584. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39585. Γöé "char         Γöé 1 if the "currency_symbol" is  Γöé "UCHAR_MAX"Γöé
  39586. Γöé n_sep_by_space"    Γöé separated by a space from the  Γöé       Γöé
  39587. Γöé            Γöé value of a negative formatted  Γöé       Γöé
  39588. Γöé            Γöé monetary quantity; 0 if it   Γöé       Γöé
  39589. Γöé            Γöé does not; 2 if a space sepa-  Γöé       Γöé
  39590. Γöé            Γöé rates the symbol and the sign  Γöé       Γöé
  39591. Γöé            Γöé string-if adjacent.       Γöé       Γöé
  39592. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39593. Γöé "char p_sign_posn"  Γöé Value indicating the position  Γöé "UCHAR_MAX"Γöé
  39594. Γöé            Γöé of the "positive_sign" for a  Γöé       Γöé
  39595. Γöé            Γöé nonnegative formatted monetary Γöé       Γöé
  39596. Γöé            Γöé quantity.            Γöé       Γöé
  39597. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39598. Γöé "char n_sign_posn"  Γöé Value indicating the position  Γöé "UCHAR_MAX"Γöé
  39599. Γöé            Γöé of the "negative_sign" for a  Γöé       Γöé
  39600. Γöé            Γöé negative formatted monetary   Γöé       Γöé
  39601. Γöé            Γöé quantity.            Γöé       Γöé
  39602. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39603. Γöé "char         Γöé Negative-valued monetary    Γöé """"    Γöé
  39604. Γöé *left_parenthesis"  Γöé symbol.             Γöé       Γöé
  39605. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39606. Γöé "char         Γöé Negative-valued monetary    Γöé """"    Γöé
  39607. Γöé *right_parenthesis"  Γöé symbol.             Γöé       Γöé
  39608. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39609. Γöé "char *debit_sign"  Γöé Debit_sign characters.     Γöé ""     Γöé
  39610. Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  39611. Γöé "char *credit_sign"  Γöé Credit_sign characters.     Γöé ""     Γöé
  39612. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  39613.  
  39614. <locale.h> declares the dtconv structure: 
  39615.  
  39616. struct dtconv {
  39617.         char *abbrev_month_names[12];   /* Abbreviated month names      */
  39618.         char *month_names[12];          /* full month names             */
  39619.         char *abbrev_day_names[7];      /* Abbreviated day names        */
  39620.         char *day_names[7];             /* full day names               */
  39621.         char *date_time_format;         /* date and time format         */
  39622.         char *date_format;              /* date format                  */
  39623.         char *time_format;              /* time format                  */
  39624.         char *am_string;                /* AM string                    */
  39625.         char *pm_string;                /* PM string                    */
  39626.         char *time_format_ampm;         /* long date format             */
  39627. };
  39628.  
  39629. The information in each field is equivalent to calling nl_langinfo with these 
  39630. keywords: 
  39631.  
  39632.  Keyword       Element 
  39633.  abmon         abbrev_month_names 
  39634.  mon           month_names 
  39635.  abday         abbrev_day_names 
  39636.  day           day_names 
  39637.  d_t_fmt       date_time_format 
  39638.  d_fmt         date_format 
  39639.  t_fmt         time_format 
  39640.  am_pm         am_string 
  39641.  am_pm         pm_string 
  39642.  t_fmt_ampm    time_format_ampm 
  39643.  
  39644.  <locale.h> also contains definitions for the following macros: 
  39645.  
  39646.  LC_ALL           LC_NUMERIC 
  39647.  LC_COLLATE       LC_TIME 
  39648.  LC_CTYPE         LC_SYNTAX 
  39649.  LC_MESSAGES      LC_MONETARY 
  39650.  LC_TOD           NULL 
  39651.  
  39652.  It also contains definitions for the LC_C_* macros, which are provided for 
  39653.  compatibility with C Set ++ V2.0. 
  39654.  
  39655.  The aspects of a program related to national language, or to cultural 
  39656.  characteristics (such as time zone, currency symbols, and sorting order of 
  39657.  characters), can be customized at run time using different locales, to suit 
  39658.  users' requirements at those locales. The methods for doing so are discussed 
  39659.  in the internationalization chapters of the Programming Guide. 
  39660.  
  39661.  
  39662. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39663.  
  39664.      <langinfo.h> 
  39665.      setlocale - Set Locale 
  39666.      Introduction to Locale in the Programming Guide 
  39667.      Include Files 
  39668.      #include 
  39669.  
  39670.  
  39671. ΓòÉΓòÉΓòÉ 5.17. <malloc.h> ΓòÉΓòÉΓòÉ
  39672.  
  39673. The <malloc.h> include file defines the following memory allocation functions: 
  39674.  
  39675.  _alloca                       calloc 
  39676.  _debug_calloc                 _debug_free 
  39677.  _debug_malloc                 _debug_heapmin 
  39678.  _debug_realloc                _debug_tcalloc 
  39679.  _debug_tfree                  _debug_theapmin 
  39680.  _debug_tmalloc                _debug_trealloc 
  39681.  _dump_allocated               _dump_allocated_delta 
  39682.  free                          _heap_check 
  39683.  malloc                        _mheap 
  39684.  _msize                        realloc 
  39685.  _tcalloc                      _tdump_allocated 
  39686.  _tdump_allocated_delta        _tfree 
  39687.  _theap_check                  _theapmin 
  39688.  _tmalloc                      _trealloc 
  39689.  
  39690.  It also includes a definition for the type size_t. 
  39691.  
  39692.  calloc, free, malloc, and realloc are also defined in <stdlib.h>, as are 
  39693.  _alloca and _heapmin. 
  39694.  
  39695.  The tiled and debug versions of the memory management functions are also 
  39696.  defined in <stdlib.h>. Heap-specific versions of the memory management 
  39697.  functions are defined in <umalloc.h>. 
  39698.  
  39699.  Note:  To use the tiled functions, you must compile with the tiled memory 
  39700.  (/Gt) option. To use the debug functions, you must compile with the debug 
  39701.  memory (/Tm) option. To use the tiled debug functions, you must compile with 
  39702.  both the tiled memory and debug memory options (/Gt /Tm). See Differentiating 
  39703.  between Memory Management Functions for more information about the different 
  39704.  types of memory management functions. 
  39705.  
  39706.  <malloc.h> also defines a number of far and near pointer macros to the 
  39707.  corresponding standard library function. These macros are: 
  39708.  
  39709.  _fcalloc            _ffree 
  39710.  _fheapmin           _fmalloc 
  39711.  _frealloc           _ncalloc 
  39712.  _nfree              _nheapmin 
  39713.  _nmalloc            _nrealloc 
  39714.  
  39715.  These macros are also defined in <stdlib.h>. 
  39716.  
  39717.  
  39718. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39719.  
  39720.      <stdlib.h> 
  39721.      <umalloc.h> 
  39722.      Include Files 
  39723.      #include 
  39724.  
  39725.  
  39726. ΓòÉΓòÉΓòÉ 5.18. <math.h> ΓòÉΓòÉΓòÉ
  39727.  
  39728. The <math.h> include file declares all the floating-point math functions: 
  39729.  
  39730.  acos                asin 
  39731.  atan                atan2 
  39732.  Bessel              ceil 
  39733.  cos                 cosh 
  39734.  erf                 erfc 
  39735.  exp                 fabs 
  39736.  floor               fmod 
  39737.  frexp               gamma 
  39738.  hypot               ldexp 
  39739.  log                 log10 
  39740.  modf                pow 
  39741.  sin                 sinh 
  39742.  sqrt                tan 
  39743.  tanh 
  39744.  
  39745.  Note:  The Bessel functions are a group of functions named _j0, _j1, _jn, _y0, 
  39746.  _y1, and _yn. 
  39747.  
  39748.  <math.h> also includes definitions for the following VisualAge C++ extensions: 
  39749.  
  39750.       _atold 
  39751.       _cabs 
  39752.       _matherr 
  39753.  
  39754.  The _atold function is also defined in <stdlib.h>. 
  39755.  
  39756.  <math.h> defines the macros HUGE, _LHUGE, HUGE_VAL, and _LHUGE_VAL, which 
  39757.  expand to a positive double expression or to infinity. 
  39758.  
  39759.  You can define a macro _FP_INLINE to inline the functions sin, cos, tan, atan, 
  39760.  acos and asin. If you use _FP_INLINE to inline the functions, you cannot use 
  39761.  the functions defined in <complex.h>, or an error message is generated. 
  39762.  
  39763.  For all mathematical functions, a domain error occurs when an input argument 
  39764.  is outside the range of values allowed for that function.  In the event of a 
  39765.  domain error, errno is set to the value of EDOM. 
  39766.  
  39767.  A range error occurs if the result of the function cannot be represented in a 
  39768.  double value.  If the magnitude of the result is too large (overflow), the 
  39769.  function returns the positive or negative value of the macro HUGE_VAL, and 
  39770.  sets errno to ERANGE.  If the result is too small (underflow), the function 
  39771.  returns zero. 
  39772.  
  39773.  
  39774. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39775.  
  39776.      <stdlib.h> 
  39777.      Include Files 
  39778.      #include 
  39779.  
  39780.  
  39781. ΓòÉΓòÉΓòÉ 5.19. <memory.h> ΓòÉΓòÉΓòÉ
  39782.  
  39783. The <memory.h> include file defines the following buffer manipulation 
  39784. functions: 
  39785.  
  39786.  memccpy             memchr 
  39787.  memcmp              memcpy 
  39788.  memicmp             memmove 
  39789.  memset 
  39790.  
  39791.  Definitions of these functions are also provided in <string.h>. 
  39792.  
  39793.  The <memory.h> include file also defines a number of far and near pointer 
  39794.  macros to the corresponding standard library function.  These macros are: 
  39795.  
  39796.  _fmemccpy           _fmemchr 
  39797.  _fmemcmp            _fmemcpy 
  39798.  _fmemicmp           _fmemset 
  39799.  
  39800.  These macros are also defined in <string.h>. 
  39801.  
  39802.  
  39803. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39804.  
  39805.      <string.h> 
  39806.      Include Files 
  39807.      #include 
  39808.  
  39809.  
  39810. ΓòÉΓòÉΓòÉ 5.20. <monetary.h> ΓòÉΓòÉΓòÉ
  39811.  
  39812. The <monetary.h> include file declares the strfmon function. 
  39813.  
  39814.  
  39815. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39816.  
  39817.      <locale.h> 
  39818.      setlocale - Set Locale 
  39819.      Introduction to Locale in the Programming Guide 
  39820.      Include Files 
  39821.      #include 
  39822.  
  39823.  
  39824. ΓòÉΓòÉΓòÉ 5.21. <nl_types.h> ΓòÉΓòÉΓòÉ
  39825.  
  39826. The <nl_types.h> include file defines the nl_item type for the nl_langinfo 
  39827. function. 
  39828.  
  39829.  
  39830. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39831.  
  39832.      <langinfo.h> 
  39833.      <locale.h> 
  39834.      setlocale - Set Locale 
  39835.      Introduction to Locale in the Programming Guide 
  39836.      Include Files 
  39837.      #include 
  39838.  
  39839.  
  39840. ΓòÉΓòÉΓòÉ 5.22. <process.h> ΓòÉΓòÉΓòÉ
  39841.  
  39842. The <process.h> include file defines the process control functions: 
  39843.  
  39844.  abort               _beginthread 
  39845.  _cwait              _endthread 
  39846.  execl               execle 
  39847.  execlp              _execlpe 
  39848.  execv               execve 
  39849.  execvp              _execvpe 
  39850.  exit                _exit 
  39851.  getpid              _spawnl 
  39852.  _spawnle            _spawnlp 
  39853.  _spawnlpe           _spawnv 
  39854.  _spawnve            _spawnvp 
  39855.  _spawnvpe           system 
  39856.  wait 
  39857.  
  39858.  The definitions of _beginthread, _endthread, abort, exit, and system are also 
  39859.  provided in <stdlib.h>. 
  39860.  
  39861.  
  39862. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39863.  
  39864.      <stdlib.h> 
  39865.      Include Files 
  39866.      #include 
  39867.  
  39868.  
  39869. ΓòÉΓòÉΓòÉ 5.23. <regex.h> ΓòÉΓòÉΓòÉ
  39870.  
  39871. The <regex.h> include file declares the type size_t and defines the following 
  39872. regular expression functions: 
  39873.  
  39874.  regcomp             regerror 
  39875.  regexec             regfree 
  39876.  
  39877.  <regex.h> also declares the regex_t type, which is capable of storing a 
  39878.  compiled regular expression, and the following macros: 
  39879.  
  39880.  REG_EXTENDED 
  39881.  REG_ICASE 
  39882.  REG_NEWLINE 
  39883.  REG_NOSUB       Values of the cflags parameter of the regcomp function 
  39884.  
  39885.  REG_NOTBOL 
  39886.  REG_NOTEOL      Values of the eflags parameter of the regexec function 
  39887.  
  39888.  REG_*           Values of the errcode parameter of the regerror function 
  39889.  
  39890.  
  39891. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39892.  
  39893.      Include Files 
  39894.      #include 
  39895.  
  39896.  
  39897. ΓòÉΓòÉΓòÉ 5.24. <search.h> ΓòÉΓòÉΓòÉ
  39898.  
  39899. The <search.h> include file defines the following search functions: 
  39900.  
  39901.  bsearch             lfind 
  39902.  lsearch             qsort 
  39903.  
  39904.  It also defines the type size_t. 
  39905.  
  39906.  Definitions for bsearch and qsort are also provided in <stdlib.h>. 
  39907.  
  39908.  
  39909. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39910.  
  39911.      <stdlib.h> 
  39912.      Include Files 
  39913.      #include 
  39914.  
  39915.  
  39916. ΓòÉΓòÉΓòÉ 5.25. <setjmp.h> ΓòÉΓòÉΓòÉ
  39917.  
  39918. The <setjmp.h> include file declares the setjmp macro and longjmp function. It 
  39919. also defines a buffer type, jmp_buf, that the setjmp macro and longjmp function 
  39920. use to save and restore the program state. 
  39921.  
  39922.  
  39923. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39924.  
  39925.      Include Files 
  39926.      #include 
  39927.  
  39928.  
  39929. ΓòÉΓòÉΓòÉ 5.26. <share.h> ΓòÉΓòÉΓòÉ
  39930.  
  39931. The <share.h> include file defines constants used by the following functions: 
  39932.  
  39933.  creat               fdopen 
  39934.  open                _sopen 
  39935.  
  39936.  The definitions for the above functions are also included in <io.h>. 
  39937.  Additional constants for open and _sopen are provided in <fcntl.h>. 
  39938.  
  39939.  
  39940. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39941.  
  39942.      <fcntl.h> 
  39943.      <io.h> 
  39944.      Include Files 
  39945.      #include 
  39946.  
  39947.  
  39948. ΓòÉΓòÉΓòÉ 5.27. <signal.h> ΓòÉΓòÉΓòÉ
  39949.  
  39950. The <signal.h> include file defines the values for signals and declares the 
  39951. signal and raise functions. 
  39952.  
  39953. <signal.h> also defines the following macros: 
  39954.  
  39955.  SIGABRT             SIGBREAK 
  39956.  SIG_DFL             SIG_ERR 
  39957.  SIGFPE              SIG_IGN 
  39958.  SIGILL              SIGINT 
  39959.  SIGSEGV             SIGTERM 
  39960.  SIGUSR1             SIGUSR2 
  39961.  SIGUSR3 
  39962.  
  39963.  <signal.h> also defines the type sig_atomic_t. 
  39964.  
  39965.  
  39966. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39967.  
  39968.      Include Files 
  39969.      #include 
  39970.  
  39971.  
  39972. ΓòÉΓòÉΓòÉ 5.28. <stdarg.h> ΓòÉΓòÉΓòÉ
  39973.  
  39974. The <stdarg.h> include file defines macros that allow you access to arguments 
  39975. in functions with variable-length argument lists: va_arg, va_start, and va_end. 
  39976. <stdarg.h> also defines the type va_list. 
  39977.  
  39978.  
  39979. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  39980.  
  39981.      Include Files 
  39982.      #include 
  39983.  
  39984.  
  39985. ΓòÉΓòÉΓòÉ 5.29. <stddef.h> ΓòÉΓòÉΓòÉ
  39986.  
  39987. The <stddef.h> include file defines the commonly used pointers, variables, and 
  39988. types, from typedef statements, as listed below: 
  39989.  
  39990.  ptrdiff_t        typedef for the type of the difference of two pointers 
  39991.  
  39992.  size_t           typedef for the type of the value returned by sizeof 
  39993.  
  39994.  wchar_t          typedef for a wide character constant. 
  39995.  
  39996.  <stddef.h> also defines the macros NULL and offsetof. NULL is a pointer that 
  39997.  is guaranteed not to point to a data object. NULL is also defined in 
  39998.  <locale.h>. The offsetof macro expands to the number of bytes between a 
  39999.  structure member and the start of the structure. The offsetof macro has the 
  40000.  form: 
  40001.  
  40002.      offsetof(structure_type, member)
  40003.  
  40004.  In extended mode, <stddef.h> also contains definitions of the global variables 
  40005.  errno and _threadid. errno is also defined in <stdlib.h> for extended mode, 
  40006.  and in <errno.h> in ANSI and SAA modes. 
  40007.  
  40008.  
  40009. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40010.  
  40011.      <errno.h> 
  40012.      <stdlib.h> 
  40013.      <stdio.h> 
  40014.      Include Files 
  40015.      #include 
  40016.  
  40017.  
  40018. ΓòÉΓòÉΓòÉ 5.30. <stdio.h> ΓòÉΓòÉΓòÉ
  40019.  
  40020. The <stdio.h> include file defines constants, macros, and types, and declares 
  40021. stream input and output functions. The stream I/O functions are: 
  40022.  
  40023.  clearerr            fclose 
  40024.  feof                ferror 
  40025.  fflush              fgetc 
  40026.  fgetpos             fgets 
  40027.  fopen               fprintf 
  40028.  fputc               fputs 
  40029.  fread               freopen 
  40030.  fscanf              fseek 
  40031.  fsetpos             ftell 
  40032.  fwrite              getc 
  40033.  getchar             gets 
  40034.  perror              printf 
  40035.  putc                putchar 
  40036.  puts                remove 
  40037.  rename              rewind 
  40038.  scanf               setbuf 
  40039.  setvbuf             sprintf 
  40040.  sscanf              tmpfile 
  40041.  tmpnam              ungetc 
  40042.  vfprintf            vprintf 
  40043.  vsprintf 
  40044.  
  40045.  In extended mode, <stdio.h> also defines the following extensions: 
  40046.  
  40047.  _fcloseall                  _fgetchar 
  40048.  fileno                      _flushall 
  40049.  _fputchar                   _rmtmp 
  40050.  _set_crt_msg_handle         tempnam 
  40051.  unlink 
  40052.  
  40053.  The unlink function is also defined in <io.h>. 
  40054.  
  40055.  <stdio.h> also defines the macros listed below. You can use these constants in 
  40056.  your programs, but you should not alter their values. 
  40057.  
  40058.  BUFSIZ 
  40059.    Specifies the buffer size to be used by the setbuf library function when you 
  40060.    are allocating buffers for stream I/O.  This value establishes the size of 
  40061.    system-allocated buffers and is used with setbuf. 
  40062.  
  40063.  EOF 
  40064.    The value returned by an I/O function when the end of the file (or in some 
  40065.    cases, an error) is found. 
  40066.  
  40067.  FOPEN_MAX 
  40068.    The number of files that can be opened simultaneously. 
  40069.  
  40070.  FILENAME_MAX 
  40071.    The longest file name supported. If there is no reasonable limit, 
  40072.    FILENAME_MAX will be the recommended size. 
  40073.  
  40074.  L_tmpnam 
  40075.    The size of the longest temporary name that can be generated by the tmpnam 
  40076.    function. 
  40077.  
  40078.  P_tmpdir 
  40079.    Indicates the default directory to be used by the tempnam function. 
  40080.  
  40081.  TMP_MAX 
  40082.    The minimum number of unique file names that can be generated by the tmpnam 
  40083.    function. 
  40084.  
  40085.  NULL 
  40086.    A pointer guaranteed not to point to a data object. NULL is also defined in 
  40087.    <locale.h>. 
  40088.  
  40089.  The FILE structure type is defined in <stdio.h>. Stream I/O functions use a 
  40090.  pointer to the FILE type to get access to a given stream. The system uses the 
  40091.  information in the FILE structure to maintain the stream. 
  40092.  
  40093.  The C standard streams stdin, stdout, and stderr are also defined in 
  40094.  <stdio.h>. 
  40095.  
  40096.  The macros SEEK_CUR, SEEK_END, and SEEK_SET expand to integral constant 
  40097.  expressions and can be used as the third argument to fseek. 
  40098.  
  40099.  The macros _IOFBF, _IOLBF, and _IONBF expand to integral constant expressions 
  40100.  with distinct values suitable for use as the third argument to the setvbuf 
  40101.  function. 
  40102.  
  40103.  The type fpos_t is defined in <stdio.h> for use with fgetpos and fsetpos. 
  40104.  
  40105.  
  40106. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40107.  
  40108.      <stddef.h> 
  40109.      <stdlib.h> 
  40110.      <conio.h> 
  40111.      <io.h> 
  40112.      Include Files 
  40113.      #include 
  40114.  
  40115.  
  40116. ΓòÉΓòÉΓòÉ 5.31. <stdlib.h> ΓòÉΓòÉΓòÉ
  40117.  
  40118. The <stdlib.h> include file declares the following functions: 
  40119.  
  40120.  abort               abs 
  40121.  atexit              atof 
  40122.  atoi                atol 
  40123.  bsearch             calloc 
  40124.  div                 exit 
  40125.  free                getenv 
  40126.  labs                ldiv 
  40127.  malloc              mblen 
  40128.  mbstowcs            mbtowc 
  40129.  qsort               rand 
  40130.  realloc             srand 
  40131.  strtod              strtol 
  40132.  strtoul             system 
  40133.  wctomb              wcstombs 
  40134.  
  40135.  In extended mode, <stdlib.h> also defines the following standard extensions: 
  40136.  
  40137.  _alloca                     _atold 
  40138.  _beginthread                _crotl 
  40139.  _crotr                      _debug_calloc 
  40140.  _debug_free                 _debug_heapmin 
  40141.  _debug_malloc               _debug_realloc 
  40142.  _debug_tcalloc              _debug_tfree 
  40143.  _debug_theapmin             _debug_tmalloc 
  40144.  _debug_trealloc             _dump_allocated 
  40145.  _dump_allocated_delta       _ecvt 
  40146.  _endthread                  _exit 
  40147.  _fcvt                       _freemod 
  40148.  _fullpath                   _gcvt 
  40149.  _heapmin                    _heap_check 
  40150.  _itoa                       _loadmod 
  40151.  _lrotl                      _lrotr 
  40152.  _ltoa                       _makepath 
  40153.  max                         min 
  40154.  _onexit                     __parmdwords 
  40155.  putenv                      _rotl 
  40156.  _rotr                       _searchenv 
  40157.  _splitpath                  _srotl 
  40158.  _srotr                      strtold 
  40159.  swab                        _tcalloc 
  40160.  _tdump_allocated            _tdump_allocated_delta 
  40161.  _tfree                      _theap_check 
  40162.  _theapmin                   _threadstore 
  40163.  _tmalloc                    _trealloc 
  40164.  _ultoa 
  40165.  
  40166.  Note: 
  40167.  
  40168.    1. To use the debug memory management functions (_debug_calloc, 
  40169.       _dump_allocated, and so on), you must compile with the debug memory (/Tm) 
  40170.       option. 
  40171.  
  40172.    2. To use the tiled memory management functions (_tcalloc and so on) you 
  40173.       must compile with the tiled memory (/Gt) option. 
  40174.  
  40175.    3. To use tiled debug functions (_debug_tcalloc, _tdump_allocated, and so 
  40176.       on), you must compile with the debug memory and tiled memory options (/Tm 
  40177.       /Gt). 
  40178.  
  40179.  For a description of how these functions differ, see Differentiating between 
  40180.  Memory Management Functions. For more information about the memory management 
  40181.  functions, see Memory Management in the Programming Guide. 
  40182.  
  40183.  <stdlib.h> also contains definitions for the following macros: 
  40184.  
  40185.  NULL 
  40186.    The NULL pointer value. The value of NULL is 0 when in extended mode; 
  40187.    otherwise, its value is ((void*)0). NULL is also defined in <locale.h>. 
  40188.  
  40189.  EXIT_SUCCESS 
  40190.    Expands to 0; used by the atexit function. 
  40191.  
  40192.  EXIT_FAILURE 
  40193.    Expands to 8; used by the atexit function. 
  40194.  
  40195.  RAND_MAX 
  40196.    Expands to an integer representing the largest number that the rand function 
  40197.    can return. 
  40198.  
  40199.  MB_CUR_MAX 
  40200.    Expands to an integral expression representing the maximum number of bytes 
  40201.    in a multibyte character for the current locale. 
  40202.  
  40203.  For more information on NULL and the types size_t and wchar_t, see <stddef.h>. 
  40204.  
  40205.  In extended mode, <stdlib.h> also defines the following global variables: 
  40206.  
  40207.  _doserrno           _environ 
  40208.  errno               onexit_t 
  40209.  _osmajor            _osminor 
  40210.  _osmode 
  40211.  
  40212.  The variable errno is also defined in <stddef.h>. The variable _doserrno and 
  40213.  the SAA definition of errno are provided in <errno.h>. 
  40214.  
  40215.  <stdlib.h> also defines the following far and near pointer macros to the 
  40216.  corresponding standard library function: 
  40217.  
  40218.  _fcalloc            _ffree 
  40219.  _fmalloc            _fheapmin 
  40220.  _frealloc           _ncalloc 
  40221.  _nfree              _nmalloc 
  40222.  _nheapmin           _nrealloc 
  40223.  
  40224.  These macros are also defined in <malloc.h>. 
  40225.  
  40226.  
  40227. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40228.  
  40229.      <errno.h> 
  40230.      <malloc.h> 
  40231.      <stddef.h> 
  40232.      <stdio.h> 
  40233.      Include Files 
  40234.      #include 
  40235.  
  40236.  
  40237. ΓòÉΓòÉΓòÉ 5.32. <string.h> ΓòÉΓòÉΓòÉ
  40238.  
  40239. The <string.h> include file declares the string manipulation functions: 
  40240.  
  40241.  memchr              memcmp 
  40242.  memcpy              memmove 
  40243.  memset              strcat 
  40244.  strchr              strcmp 
  40245.  strcoll             strcpy 
  40246.  strcspn             strerror 
  40247.  strlen              strncat 
  40248.  strncmp             strncpy 
  40249.  strpbrk             strrchr 
  40250.  strspn              strstr 
  40251.  strtok              strxfrm 
  40252.  
  40253.  In extended mode, <string.h> also defines the following standard extensions: 
  40254.  
  40255.  memccpy             memicmp 
  40256.  strcmpi             strdup 
  40257.  _strerror           stricmp 
  40258.  strlwr              strnicmp 
  40259.  strnset             strrev 
  40260.  strset              strupr 
  40261.  
  40262.  The memxxxx functions are also included in <memory.h>. 
  40263.  
  40264.  <string.h> also defines the macro NULL and the type size_t. These definitions 
  40265.  are also provided in <stddef.h>. NULL is also defined in <locale.h>. 
  40266.  
  40267.  string.h also defines the following far  and near pointer macros to the 
  40268.  corresponding standard library function: 
  40269.  
  40270.  _fmemccpy           _fmemchr 
  40271.  _fmemcmp            _fmemcpy 
  40272.  _fmemicmp           _fmemmove 
  40273.  _fmemset            _fstrcat 
  40274.  _fstrchr            _fstrcmp 
  40275.  _fstrcpy            _fstrcspn 
  40276.  _fstrdup            _fstricmp 
  40277.  _fstrlen            _fstrlwr 
  40278.  _fstrncat           _fstrncmp 
  40279.  _fstrncpy           _fstrnicmp 
  40280.  _fstrnset           _fstrpbrk 
  40281.  _fstrrchr           _fstrrev 
  40282.  _fstrset            _fstrspn 
  40283.  _fstrstr            _fstrtok 
  40284.  _fstrupr            _nstrdup 
  40285.  
  40286.  These macros are also defined in <memory.h>. 
  40287.  
  40288.  
  40289. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40290.  
  40291.      <stddef.h> 
  40292.      <memory.h> 
  40293.      <stdlib.h> 
  40294.      <stdio.h> 
  40295.      Include Files 
  40296.      #include 
  40297.  
  40298.  
  40299. ΓòÉΓòÉΓòÉ 5.33. <sys\stat.h> ΓòÉΓòÉΓòÉ
  40300.  
  40301. The <sys\stat.h> include file defines the low-level input/output functions 
  40302. fstat and stat. It also defines the structure stat and the following types: 
  40303.  
  40304.  dev_t               ino_t 
  40305.  off_t               time_t 
  40306.  
  40307.  These types are also defined in <sys\types.h>. Other low-level I/O functions 
  40308.  are defined in <io.h>. 
  40309.  
  40310.  
  40311. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40312.  
  40313.      <io.h> 
  40314.      <sys\types.h> 
  40315.      Include Files 
  40316.      #include 
  40317.  
  40318.  
  40319. ΓòÉΓòÉΓòÉ 5.34. <sys\timeb.h> ΓòÉΓòÉΓòÉ
  40320.  
  40321. The <sys\timeb.h> include file defines the _ftime function and also defines the 
  40322. type time_t and the structure timeb. 
  40323.  
  40324.  
  40325. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40326.  
  40327.      Include Files 
  40328.      #include 
  40329.  
  40330.  
  40331. ΓòÉΓòÉΓòÉ 5.35. <sys\types.h> ΓòÉΓòÉΓòÉ
  40332.  
  40333. The <sys\types.h> include file defines the following types: 
  40334.  
  40335.  ino_t               time_t 
  40336.  dev_t               off_t 
  40337.  
  40338.  These types are also defined in <sys\stat.h>. 
  40339.  
  40340.  
  40341. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40342.  
  40343.      <sys\stat.h> 
  40344.      Include Files 
  40345.      #include 
  40346.  
  40347.  
  40348. ΓòÉΓòÉΓòÉ 5.36. <sys\utime.h> ΓòÉΓòÉΓòÉ
  40349.  
  40350. The <sys\utime.h> include file defines the utime function, the structure 
  40351. utimbuf, and the type time_t. 
  40352.  
  40353.  
  40354. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40355.  
  40356.      Include Files 
  40357.      #include 
  40358.  
  40359.  
  40360. ΓòÉΓòÉΓòÉ 5.37. <time.h> ΓòÉΓòÉΓòÉ
  40361.  
  40362. The <time.h> include file declares the time and date functions: 
  40363.  
  40364.  asctime             clock 
  40365.  ctime               difftime 
  40366.  gmtime              localtime 
  40367.  mktime              strftime 
  40368.  time 
  40369.  
  40370.  In extended mode, <time.h> also defines the standard extensions _strdate, 
  40371.  _strtime, and _tzset. 
  40372.  
  40373.  <time.h> also provides: 
  40374.  
  40375.      A structure tm containing the components of a calendar time.  See gmtime 
  40376.       - Convert Time for a list of the members of the tm structure. 
  40377.  
  40378.      A macro CLOCKS_PER_SEC equal to the number per second of the value 
  40379.       returned by the clock function. 
  40380.  
  40381.      Types clock_t, time_t, and size_t. 
  40382.  
  40383.      The NULL pointer value. 
  40384.  
  40385.  For more information on NULL and the type size_t, see <stddef.h>. 
  40386.  
  40387.  <time.h> also defines the global variables _daylight, _timezone, and _tzname. 
  40388.  
  40389.  
  40390. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40391.  
  40392.      <stddef.h> 
  40393.      Include Files 
  40394.      #include 
  40395.  
  40396.  
  40397. ΓòÉΓòÉΓòÉ 5.38. <umalloc.h> ΓòÉΓòÉΓòÉ
  40398.  
  40399. The <umalloc.h> include file defines the memory allocation functions that are 
  40400. heap-specific: 
  40401.  
  40402.  _debug_ucalloc            _debug_uheapmin 
  40403.  _debug_umalloc            _mheap 
  40404.  _uaddmem                  _ucalloc 
  40405.  _uclose                   _ucreate 
  40406.  _udefault                 _udestroy 
  40407.  _udump_allocated          _udump_allocated_delta 
  40408.  _uheapchk                 _uheap_check 
  40409.  _uheapmin                 _uheapset 
  40410.  _uheap_walk               _umalloc 
  40411.  _uopen 
  40412.  
  40413.  <umalloc.h> also defines macros used by the heap-specific functions. 
  40414.  
  40415.  Definitions for the non-heap-specific memory management functions are located 
  40416.  in <stdlib.h> and in <malloc.h>. 
  40417.  
  40418.  Note:  To use the debug versions of memory management functions, specify the 
  40419.  debug memory (/Tm) compiler option. 
  40420.  
  40421.  
  40422. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40423.  
  40424.      <malloc.h> 
  40425.      <stdlib.h> 
  40426.      Memory Management in the Programming Guide 
  40427.      Include Files 
  40428.      #include 
  40429.  
  40430.  
  40431. ΓòÉΓòÉΓòÉ 5.39. <variant.h> ΓòÉΓòÉΓòÉ
  40432.  
  40433. The <variant.h> include file declares the getsyntx function and for the struct 
  40434. variant type: 
  40435.  
  40436. struct variant {
  40437.       char *codeset;           /* code set of the current locale */
  40438.       char  backslash;         /* encoding of \  */
  40439.       char  right_bracket;     /* encoding of ]  */
  40440.       char  left_bracket;      /* encoding of [  */
  40441.       char  right_brace;       /* encoding of }  */
  40442.       char  left_brace;        /* encoding of {  */
  40443.       char  circumflex;        /* encoding of ^  */
  40444.       char  tilde;             /* encoding of ~  */
  40445.       char  exclamation_mark;  /* encoding of !  */
  40446.       char  number_sign;       /* encoding of #  */
  40447.       char  vertical_line;     /* encoding of |  */
  40448.       char  dollar_sign;       /* encoding of $  */
  40449.       char  commercial_at;     /* encoding of @  */
  40450.       char  grave_accent;      /* encoding of `  */
  40451. }
  40452.  
  40453.  
  40454. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40455.  
  40456.      <locale.h> 
  40457.      setlocale - Set Locale 
  40458.      Introduction to Locale in the Programming Guide 
  40459.      Include Files 
  40460.      #include 
  40461.  
  40462.  
  40463. ΓòÉΓòÉΓòÉ 5.40. <wchar.h> ΓòÉΓòÉΓòÉ
  40464.  
  40465. The <wchar.h> include file declares the supported subset of the ISO/C Multibyte 
  40466. Support extensions defined in ISO/IEC 9899:1990/Amendment 1:1993(E) extensions. 
  40467. The following functions are declared in <wchar.h>: 
  40468.  
  40469.  fgetwc              fgetws 
  40470.  fputwc              fputws 
  40471.  getwc               getwchar 
  40472.  mbrlen              mbrtowc 
  40473.  mbsrtowcs           putwc 
  40474.  putwchar            swprintf 
  40475.  swscanf             ungetwc 
  40476.  vswprintf           wcrtomb 
  40477.  wcscat              wcschr 
  40478.  wcscmp              wcscoll 
  40479.  wcscpy              wcscspn 
  40480.  wcsftime            wcslen 
  40481.  wcsncat             wcsncmp 
  40482.  wcsncpy             wcspbrk 
  40483.  wcsrchr             wcsrtombs 
  40484.  wcsspn              wcsstr 
  40485.  wcstod              wcstok 
  40486.  wcstol              wcstoul 
  40487.  wcswidth            wcsxfrm 
  40488.  wctob               wcwidth 
  40489.  
  40490.  You do not need to include <stdio.h> and <stdarg.h> to use this include file. 
  40491.  
  40492.  <wchar.h> also defines the following types and constants: 
  40493.  
  40494.  mbstate_t    Conversion state information needed when converting between 
  40495.               sequences of multibyte characters and wide characters. 
  40496.  
  40497.  size_t       typedef for the type of the value returned by sizeof. 
  40498.  
  40499.  wchar_t      typedef for a wide character constant. 
  40500.  
  40501.  wint_t       An integral type unchanged by integral promotions, that can hold 
  40502.               any value corresponding to members of the extended character set, 
  40503.               as well as WEOF (see below). 
  40504.  
  40505.  FILE         The FILE structure type is defined in <stdio.h>. Stream functions 
  40506.               use a pointer to the FILE type to get access to a given stream. 
  40507.               The system uses the information in the FILE structure to maintain 
  40508.               the stream. The C standard streams stdin, stdout, and stderr are 
  40509.               also defined in <stdio.h>. 
  40510.  
  40511.  va_list      This type is also defined in <stdio.h>. 
  40512.  
  40513.  NULL         A pointer that never points to a data object. 
  40514.  
  40515.  WEOF         Expands to a constant expression of type wint_t, whose value does 
  40516.               not correspond to any member of the extended character set. It 
  40517.               indicates EOF. 
  40518.  
  40519.  You can perform wide character input/output on the streams described in the 
  40520.  ISO/IEC 9899:1990 standard, subclause 7.9.2. This standard expands the 
  40521.  definition of a stream to include an orientation for both text and binary 
  40522.  streams. After you have associated a stream with an external file, but before 
  40523.  you have performed any operations on it, the stream does not have any 
  40524.  orientation. Once you apply a wide character input or output function to a 
  40525.  stream that does not have orientation, the stream becomes wide-oriented. 
  40526.  Similarly, once you apply a byte input or output function to a stream without 
  40527.  orientation, the stream becomes byte-oriented. 
  40528.  
  40529.  After you establish a stream's orientation, the only way to change it is to 
  40530.  make a successful call to the freopen function, which removes a stream's 
  40531.  orientation. 
  40532.  
  40533.  
  40534. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40535.  
  40536.      <stdio.h> 
  40537.      <locale.h> 
  40538.      setlocale - Set Locale 
  40539.      Introduction to Locale in the Programming Guide 
  40540.      Include Files 
  40541.      #include 
  40542.  
  40543.  
  40544. ΓòÉΓòÉΓòÉ 5.41. <wcstr.h> ΓòÉΓòÉΓòÉ
  40545.  
  40546. The wcstr.h include file declares the multibyte functions: 
  40547.  
  40548.  wcscat              wcschr 
  40549.  wcscmp              wcscpy 
  40550.  wcscspn             wcslen 
  40551.  wcsncat             wcsncmp 
  40552.  wcsncpy             wcspbrk 
  40553.  wcsspn              wcsrchr 
  40554.  wcswcs 
  40555.  
  40556.  wcstr.h also defines the types size_t, NULL, and wchar_t. 
  40557.  
  40558.  
  40559. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40560.  
  40561.      Include Files 
  40562.      #include 
  40563.  
  40564.  
  40565. ΓòÉΓòÉΓòÉ 5.42. <wctype.h> ΓòÉΓòÉΓòÉ
  40566.  
  40567. The <wctype.h> file declares functions used to classify wide characters: 
  40568.  
  40569.  iswalnum            iswalpha 
  40570.  iswblank            iswcntrl 
  40571.  iswctype            iswctype 
  40572.  iswdigit            iswgraph 
  40573.  iswlower            iswprint 
  40574.  iswpunct 
  40575.  iswspace            iswupper 
  40576.  iswxdigit           towlower 
  40577.  towupper            wctype 
  40578.  
  40579.  wctype.h also defines the types wint_t and wctype_t, and the macro WEOF, which 
  40580.  expands to a constant expression of type wint_t whose value does not 
  40581.  correspond to any member of the extended character set and indicates EOF. 
  40582.  
  40583.  
  40584. ΓòÉΓòÉΓòÉ <hidden> Related Information ΓòÉΓòÉΓòÉ
  40585.  
  40586.      <ctype.h> 
  40587.      <wchar.h> 
  40588.      Include Files 
  40589.      #include 
  40590.