home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / std / c / 3011 < prev    next >
Encoding:
Text File  |  1992-11-16  |  1.1 KB  |  35 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!mcsun!Germany.EU.net!Urmel.Informatik.RWTH-Aachen.DE!physik.tu-muenchen.de!berg
  3. From: berg@physik.tu-muenchen.de (Stephen R. van den Berg)
  4. Subject: strcmp() on a non-nil-terminated string
  5. Message-ID: <1992Nov16.162313.3334@Urmel.Informatik.RWTH-Aachen.DE>
  6. Originator: berg@tabaqui
  7. Sender: news@Urmel.Informatik.RWTH-Aachen.DE (Newsfiles Owner)
  8. Nntp-Posting-Host: tabaqui
  9. Organization: Rechnerbetrieb Informatik  /  RWTH Aachen
  10. Date: Mon, 16 Nov 92 16:23:13 GMT
  11. Lines: 22
  12.  
  13. Suppose I have the following program:
  14.  
  15. --------------------------------------
  16. #include <string.h>
  17.  
  18. char first[]="first";
  19. char second[]={'s','e','c','o','n','d'};
  20.  
  21. main()
  22. { return!!strcmp(first,second);
  23. }
  24. --------------------------------------
  25.  
  26. Is this program allowed to behave undefined?  If so, can anyone imagine
  27. provide an example when this might happen?
  28.  
  29. You would expect a sane implementation to return with an exitcode of 1.
  30. -- 
  31. Sincerely,                                  berg@pool.informatik.rwth-aachen.de
  32.            Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de
  33.  
  34. "Be spontaneous!"
  35.