<?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 Help with getopt.h in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540402#M80357</link>
    <description>Been writing a program for a while, and seem to be having a bit of difficulty with usting the standard argument processor "getopt.h".&lt;BR /&gt;&lt;BR /&gt;It works fine for regular arguments, but I can not seem to cast the string to an integer for a arg with option.&lt;BR /&gt;&lt;BR /&gt;What is getopt.h returning in optarg?&lt;BR /&gt;&lt;BR /&gt;case 'l':&lt;BR /&gt;        password_length = (int)optarg ;&lt;BR /&gt;        break;&lt;BR /&gt;&lt;BR /&gt;simply returns junk, and no matter which type I have tried to cast fails...&lt;BR /&gt;&lt;BR /&gt;Logic problem?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;BR /&gt;&lt;BR /&gt;Shannon</description>
    <pubDate>Thu, 14 Jun 2001 01:28:12 GMT</pubDate>
    <dc:creator>Shannon Petry</dc:creator>
    <dc:date>2001-06-14T01:28:12Z</dc:date>
    <item>
      <title>Help with getopt.h</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540402#M80357</link>
      <description>Been writing a program for a while, and seem to be having a bit of difficulty with usting the standard argument processor "getopt.h".&lt;BR /&gt;&lt;BR /&gt;It works fine for regular arguments, but I can not seem to cast the string to an integer for a arg with option.&lt;BR /&gt;&lt;BR /&gt;What is getopt.h returning in optarg?&lt;BR /&gt;&lt;BR /&gt;case 'l':&lt;BR /&gt;        password_length = (int)optarg ;&lt;BR /&gt;        break;&lt;BR /&gt;&lt;BR /&gt;simply returns junk, and no matter which type I have tried to cast fails...&lt;BR /&gt;&lt;BR /&gt;Logic problem?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;BR /&gt;&lt;BR /&gt;Shannon</description>
      <pubDate>Thu, 14 Jun 2001 01:28:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540402#M80357</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2001-06-14T01:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help with getopt.h</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540403#M80358</link>
      <description>Just a wild guess:&lt;BR /&gt;&lt;BR /&gt;case 'l': &lt;BR /&gt;password_length = atoi(optarg) ; &lt;BR /&gt;break; &lt;BR /&gt;&lt;BR /&gt;don't forget to include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Vincent&lt;/STDLIB.H&gt;</description>
      <pubDate>Thu, 14 Jun 2001 04:54:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540403#M80358</guid>
      <dc:creator>Vincent Stedema</dc:creator>
      <dc:date>2001-06-14T04:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with getopt.h</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540404#M80359</link>
      <description>Darn good wild guess!&lt;BR /&gt;&lt;BR /&gt;Where did you get that &lt;BR /&gt;atoi(optarg)&lt;BR /&gt;I'll asume it's an array?&lt;BR /&gt;&lt;BR /&gt;I dug through man pages, and my C book...the C book was using strcat and strcopy to a buffer, and using the buffer...  and strlen and such...  yours was pretty easy!&lt;BR /&gt;Thanks!&lt;BR /&gt;Shannon</description>
      <pubDate>Thu, 14 Jun 2001 10:43:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540404#M80359</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2001-06-14T10:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help with getopt.h</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540405#M80360</link>
      <description>Shannon,&lt;BR /&gt;&lt;BR /&gt;Per the man page for getopt(2), "optarg" is defined as an "extern char *".  So in order to convert this to an integer, you need to use the atoi() function from &lt;STDLIB.H&gt;&lt;/STDLIB.H&gt;</description>
      <pubDate>Thu, 14 Jun 2001 11:06:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-getopt-h/m-p/2540405#M80360</guid>
      <dc:creator>Kenneth Platz</dc:creator>
      <dc:date>2001-06-14T11:06:05Z</dc:date>
    </item>
  </channel>
</rss>

