Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <be85fd1fb842b5dc7851d36d535869973cc325cf@i2pn2.org>
Deutsch   English   Français   Italiano  
<be85fd1fb842b5dc7851d36d535869973cc325cf@i2pn2.org>

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

Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: fir <fir@grunge.pl>
Newsgroups: comp.lang.c
Subject: Re: how to make it work
Date: Thu, 29 Aug 2024 15:13:58 +0200
Organization: i2pn2 (i2pn.org)
Message-ID: <be85fd1fb842b5dc7851d36d535869973cc325cf@i2pn2.org>
References: <877194bd8a95b9acb03db317ee000e94cce2834d@i2pn2.org> <87cylrwkdf.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Aug 2024 13:14:00 -0000 (UTC)
Injection-Info: i2pn2.org;
	logging-data="143022"; 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
In-Reply-To: <87cylrwkdf.fsf@bsb.me.uk>
X-Spam-Checker-Version: SpamAssassin 4.0.0
Bytes: 3155
Lines: 80

Ben Bacarisse wrote:
> fir <fir@grunge.pl> writes:
>
>> see such code
>>
>>
>> long long unsigned tag ;
>>
>> void foo(long long unsigned tag)
>> {
>>   if(tag=='warsaw') printf("\nwarsaw");
>>   if(tag=='paris')  printf("\nparis");
>>   if(tag=='new york') printf("\nnew york");
>>   if(tag=='old york') printf("\nold york");
>>   if(tag=='very old york') printf("\nvery old york");
>>
>>
>> }
>>
>> int main(void)
>> {
>>   foo('warsaw');
>>   foo('paris');
>>   foo('new york');
>>   foo('old york');
>>   foo('very old york');
>>
>>   return 'bye';
>> }
>>
>> and maybe guess the result (or how it should be)
>> (later i may tell you)
>>
>> the problem is how to make it work i want to use that kind of
>> 'tags' and would like to use it assuming at least 8 characters
>> work okay i mean the code above would "catch" only on proper tag and
>> each one would be printed one time
>>
>> right now it dont - is thsi a way to make it work
>> (maybe except the last one as i understand
>>   if(tag=='old york') printf("\nold york");
>>   if(tag=='very old york') printf("\nvery old york");
>> may be treated as the same
>>
>> (i need it to work on 32 bit old mingw/gcc)
>
> That's unfortunate because this can be done in a portable and relatively
> convenient way in modern C:
>
> #include <stdint.h>
> #include <stdio.h>
>
> typedef union {
>       unsigned char bytes[sizeof (uint64_t)];
>       uint64_t tag;
> } Tag;
>
> void foo(Tag t)
> {
>       if (t.tag == (Tag){"warsaw"}.tag)
>            printf("warsaw\n");
> }
>
> int main(void)
> {
>       foo((Tag){"warsaw"});
> }
>
> With a little bit more work, you can get this to work in older C without
> compound literals.
>
> But depending on what your ultimate goal is, you might want to look at
> how Lisp implementations "intern" their symbols.  That can avoid the
> obvious length limitations while making for very efficient equality
> comparisons.
>
i want it in classic c - my example work on up to 4 lellets/digits/signs 
but i dont know how to make it work for 8

as even old c has 64 bit unsigned i guess it should work, but dont know 
how to make it work