🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2948

strcmp() on a non-nil-terminated string

#2948
From: Stephen R. van den Berg
Date: Mon, 16 Nov 1992 16:23
22 lines
1163 bytes
Suppose I have the following program:

--------------------------------------
#include <string.h>

char first[]="first";
char second[]={'s','e','c','o','n','d'};

main()
{ return!!strcmp(first,second);
}
--------------------------------------

Is this program allowed to behave undefined?  If so, can anyone imagine
provide an example when this might happen?

You would expect a sane implementation to return with an exitcode of 1.
-- 
Sincerely,                                  berg@pool.informatik.rwth-aachen.de
           Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de

"Be spontaneous!"
Technical Details
Message-ID: <1992Nov16.162313.3334@Urmel.Informatik.RWTH-Aachen.DE>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!Urmel.Informatik.RWTH-Aachen.DE!physik.tu-muenchen.de!berg

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!Urmel.Informatik.RWTH-Aachen.DE!physik.tu-muenchen.de!berg
From: berg@physik.tu-muenchen.de (Stephen R. van den Berg)
Subject: strcmp() on a non-nil-terminated string
Message-ID: <1992Nov16.162313.3334@Urmel.Informatik.RWTH-Aachen.DE>
Originator: berg@tabaqui
Sender: news@Urmel.Informatik.RWTH-Aachen.DE (Newsfiles Owner)
Nntp-Posting-Host: tabaqui
Organization: Rechnerbetrieb Informatik  /  RWTH Aachen
Date: Mon, 16 Nov 92 16:23:13 GMT
Lines: 22