Path: utzoo!attcan!uunet!husc6!ogccse!littlei!zeus!martin From: martin@zeus.hf.intel.com (Martin Wilde) Newsgroups: comp.bugs.sys5 Subject: bug in sscanf (scanf)? Keywords: SVID problem? Message-ID: <331@zeus.hf.intel.com> Date: 16 Nov 88 18:51:56 GMT Organization: OMSO iRMX Software Engineering - Intel Corp. - Hillsboro Or. Lines: 51 I have a small fragment of code that does not work on V.3.2 386 UNIX. The problem appears to be in sscanf (scanf). The following fragment of code shows the problem. main(argc, argv) int argc; char **argv; { char optarg[1024]; int times; char s1[40], s2[40], s3[40], s4[255]; (void) strcpy(optarg, argv[1]); (void) sscanf(optarg, "%d %s %s %s %255[^\0]", ×, s1, s2, s3, s4); (void) printf("times = %d, s1 = %s, s2 = %s, s3 = %s, s4 = %s\n", times, s1, s2, s3, s4); } The invocation is: a.out "1 10 0L 1000L 31 32 33" The output under XENIX III and XENIX V is: times = 1, s1 = 10, s2 = 0L, s3 = 1000L, s4 = 31 32 33 under V.3.2 is: times = 1, s1 = 10, s2 = 0L, s3 = 1000L, s4 = wheres the last string in v.3.2? what the sscanf is trying to do for s4 is take all the characters up until the end of string (\0) and place them in s4, but do not exceed 255 characters (don't want core dumps). After RTFM, there does not seem to be a problem doing this. Does sscanf (scanf) have a problem? Could it be reading up until the end of string and then returning EOF (what the manual says) and ignoring that my stop character is the EOF? I do have a work around to the problem, but I donot like the inconsistencies. Thanks.... _/_ | ______ __. __ / o ____ | textronix!reed!littlei!zeus:martin / / / <_(_/|_/ (_<__<_/ / < |