<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Char Buffer Initialization in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/char-buffer-initialization/m-p/3032543#M910520</link>
    <description>Thanks Clay. Now is clear for me.</description>
    <pubDate>Thu, 24 Jul 2003 14:57:46 GMT</pubDate>
    <dc:creator>Alfonso_15</dc:creator>
    <dc:date>2003-07-24T14:57:46Z</dc:date>
    <item>
      <title>Char Buffer Initialization</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/char-buffer-initialization/m-p/3032541#M910518</link>
      <description>Good Morning:&lt;BR /&gt;I am working gcc 64, for HP11.11. I am migrating a program, and I find several run problems in the handle of variables declared as char pointer:&lt;BR /&gt;char *buffer;&lt;BR /&gt;&lt;BR /&gt;Exist in gcc any compile option for initialize the buffer when is declared: I means, when find the instruction&lt;BR /&gt; char *buffer;&lt;BR /&gt;autmatically put in buffer[0]='\0'&lt;BR /&gt;Thanks a lot for any help.</description>
      <pubDate>Thu, 24 Jul 2003 13:52:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/char-buffer-initialization/m-p/3032541#M910518</guid>
      <dc:creator>Alfonso_15</dc:creator>
      <dc:date>2003-07-24T13:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Char Buffer Initialization</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/char-buffer-initialization/m-p/3032542#M910519</link>
      <description>No and this is absolutely not a good idea. At best, it would be code that is not portable.&lt;BR /&gt;&lt;BR /&gt;You could, of course, &lt;BR /&gt;char *buffer = {""}; &lt;BR /&gt;&lt;BR /&gt;to do this but this is of limited value because all you have done is created a 1-byte string to hold the NUL. If you stop to think for a moment you will realize that your request really doesn't make a lot of sense because no intelligent space allocation can be done. I suspect that you are testing the string for length 0 and if so then allocating space. A better way is this (which will be completely portable):&lt;BR /&gt;&lt;BR /&gt;char *buffer = NULL;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if (buffer == NULL)&lt;BR /&gt;  {&lt;BR /&gt;    buffer = (char *) malloc((size_t) (nbytes + 1));&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jul 2003 14:04:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/char-buffer-initialization/m-p/3032542#M910519</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-24T14:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Char Buffer Initialization</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/char-buffer-initialization/m-p/3032543#M910520</link>
      <description>Thanks Clay. Now is clear for me.</description>
      <pubDate>Thu, 24 Jul 2003 14:57:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/char-buffer-initialization/m-p/3032543#M910520</guid>
      <dc:creator>Alfonso_15</dc:creator>
      <dc:date>2003-07-24T14:57:46Z</dc:date>
    </item>
  </channel>
</rss>

