Deutsch English Français Italiano |
<pan$97210$7f2c1504$c93772a0$7dfab761@invalid.invalid> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.net!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail From: Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> Newsgroups: comp.lang.c Subject: Re: is it possible to point to a slice of an array without malloc or VLAs? Date: Wed, 28 Aug 2024 14:25:59 -0000 (UTC) Organization: A noiseless patient Spider Lines: 28 Message-ID: <pan$97210$7f2c1504$c93772a0$7dfab761@invalid.invalid> References: <NS2dnaQtUKseUVP7nZ2dnZfqn_WdnZ2d@brightview.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 28 Aug 2024 16:26:00 +0200 (CEST) Injection-Info: bluemanedhawk.eternal-september.org; posting-host="0b4658bd13aedbb628ae5696435bb749"; logging-data="3686318"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18azrJblxq9flMJeMxt6u/x+/MlYnJk+z4=" User-Agent: Pan/0.154 (Izium; 517acf4) Cancel-Lock: sha1:ud3L8LziJu/4eWaZuzyntZ4h0IY= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9 jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq 0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1 z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9 R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6 k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx 2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII= X-Face: Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronuku pokaiwhenuakitanatahu Bytes: 2905 Mark Summerfield wrote: > I'm using getopt_long() to process a command line. > So after a typical call I might have: > > argv == {"./efind", "-D", "-x", "one", "two", "three", "four"} > optind == 3 > > What I'd like to do (without copying or mallocing and without using a > VLA) > is to get a pointer to a slice of argv, specifically, > {"one", "two", "three", "four"}. > In Python terms argv[optind:argc]. > > Is this possible in C? Yes. const char * argv_slice[argc - optind] = &argv[optind]; -- Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr. blue-maned_hawk.srht.site This subroutine must not be called from any thread.