Deutsch   English   Français   Italiano  
<uu5u8p$3dffl$1@i2pn2.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: fir <fir@grunge.pl>
Newsgroups: comp.lang.c
Subject: Re: macro for fir list?
Date: Fri, 29 Mar 2024 09:31:16 +0100
Organization: i2pn2 (i2pn.org)
Message-ID: <uu5u8p$3dffl$1@i2pn2.org>
References: <uu3s0m$3av2s$1@i2pn2.org> <uu3sca$3av2s$2@i2pn2.org> <uu3t72$3b0f5$1@i2pn2.org> <uu48nm$3bgp1$1@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 29 Mar 2024 08:31:21 -0000 (UTC)
Injection-Info: i2pn2.org;
	logging-data="3587573"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0";
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
X-Spam-Checker-Version: SpamAssassin 4.0.0
In-Reply-To: <uu48nm$3bgp1$1@i2pn2.org>

fir wrote:
>
> // sickle.h
>    struct str_list_entry { char* str;};
>    const int str_lists_max = 10;
>     str_list_entry* str_list[str_lists_max] = {NULL};
>      int str_list_size[str_lists_max] = {0};
>    str_list_entry* str_list_new(int N)  {
>        str_list[N] = (str_list_entry*) realloc(str_list[N],
> ++str_list_size[N] * sizeof(str_list_entry) );
>        return &str_list[N][str_list_size[N]-1];  }
>
you can use the above for example to build list from commanline

const int commandline_list_key = 0;

void BuildListOfComandline(int argc, char* argv[])
{
   for(int i=0; i<argc; i++)
    *str_list_new(commandline_list_key)={argv[i]};
}

int main(int argc, char* argv[])
{
  BuildListOfComandline( argc, argv);
  for(int i=0; i<str_list_size[commandline_list_key];i++)
     printf("\n%d %s", i, str_list[commandline_list_key][i].str);
}

the names here are maybe to long as for such common use items so some 
abrreviation should be used