Article View: comp.lang.c
Article #418Re: compare literals / if( "cat"== "dog") {}
From: Janis Papanagnou
Date: Thu, 15 Oct 2026 10:09
Date: Thu, 15 Oct 2026 10:09
46 lines
2783 bytes
2783 bytes
On 2026-10-15 11:36, Rosario19 wrote:
> On Sat, 10 Oct 2026 23:02:54 +0200, fir
>> have asked for that but i got somewhat holes im my memory and i
>> dont exactly remember sometimes on which i wrote and on which not
>>
>> the problem is i need this adhos enums strongly and really, but those
>> 'smth' are to shore i could use two of them f('some','thin') but it gets
>> uglier and such code is like degraded
>>
>> in fact there could be quite easy solution - it is use string literals
>> as such tags - i mean you dont need to use strcomp , you just need to
>> have same string literals have same pointer then
>>
>> if("cat" == "cat") will return true and
>> if("cat" == "dog") will return false
>
> I say if int is 4 chars this should return 1 in case of fist line
> 0 in case the second line
>
> if((*(int*)"cat") == (*(int*)"cat")) return 1
> if((*(int*)"cat") == (*(int*)"dog") ) return 0
You are seriously suggesting that the semantics of "C" should
depend on the actual string-length at runtime, that it should
not have an unambiguous uniform semantics in the first place?
Janis
>
> otherwise there is a need one function that from the pointer check
> strings are ugual as strcmp
>
> I think can be too
> strcpy(char* a, char* b)
> {
> if(a==b) return 0;
>
> }
>
> but who is sure a and b point a to 2 strings?
>
>> i probably asked that but if so once again
>>
>> is there way to enforce it to work?
>
Technical Details
Message-ID:
<11aq8o2$206gh$2@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11ae962$2365v$1@dont-email.me> <6171dlho2h59l01e1jvp6so5cbddc5brct@4ax.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: compare literals / if( "cat"== "dog") {}
Date: Thu, 15 Oct 2026 12:09:06 +0200
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <11aq8o2$206gh$2@dont-email.me>
References: <11ae962$2365v$1@dont-email.me>
<6171dlho2h59l01e1jvp6so5cbddc5brct@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 15 Oct 2026 10:09:06 +0000 (UTC)
Injection-Info: dont-email.me;
logging-data="2103825"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hemCXoD+o7FdeJT3jyZt0"; posting-host="b0dc77b18da5cc7911bbe382caff639a"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:oU71BD7OBNq1qJExYSM2VSo3jIA= sha256:Li4PfBE/MBZITT/MM79WINFQkqgqTf2XyStsNrlVoEg=
sha1:HZlxd5rnnzoESq+19fb0hwiJkPI= sha256:NoehFBP8nIdSR9RD7ozsMQ31bHkqvon3V0NBV1qOT6c=
In-Reply-To: <6171dlho2h59l01e1jvp6so5cbddc5brct@4ax.com>
Content-Language: en-US