Received: from zoo.toronto.edu ([128.100.72.1]) by gpu.utcs.utoronto.ca with SMTP id <15736>; Mon, 26 Nov 1990 23:21:48 -0500 Received: from pnet91 by generic.UUCP id aa16233; Tue, 27 Nov 90 3:30:14 GMT Date: Mon, 26 Nov 1990 22:28:19 -0500 From: ericmcg@pnet91 (Eric Mcgillicuddy) To: st6934@siucvmb Subject: Re: Re:scanf.c Message-ID: <9011270330.aa16233@generic.UUCP> cc has to be modified so that it does not erase ('rm') the scanf.o file after linking. Remove the second last line of cc and/or ccn and that should do the trick. Also be sure to specify the full pathname to the libc file (something like /csys/libs/libc). Also make sure the right flags are used (-rv I think?), it's been awhile since I installed it. I guess you wouldn't if behaves as you expected, I don't use scanf so I had t to rely on languages specs to write the thing. Hope it's what people expected. UUCP: bkj386!pnet91!ericmcg INET: ericmcg@pnet91.cts.com Upon experimenting with scanf.c the only way I've gotten it to work is to remove the #include from scanf.c and add an #include "scanf.c" to the program that has scanf in it. Eric remarked that removing the LAST TWO LINES of cc and renaming cc to compile would work so that scanf. c wouldn't link to itself but I still had trouble with that. I've been told that this is bad programming, but it works for me for now. Andy = ST6934@SIUCVMB (.BITNET if you need it) March 19, 1991 I finally was able to add scanf.c to libc. Compile scanf.c down to scanf.o by deleting the lnk and rm $1.o lines from cc or ccn and renaming the cc or ccn file cclib or something like that. Then add scanf.o to libc BEFORE atoi.o. The command would look like: lib libc -b atoi.o -r scanf.o Always do things like this on backups. You can check libc by typing: sym libc Then you'll know if scanf.o is before atoi.o. Andy Werner st6934@siucvmb.bitnet From fozztexx%nvcc.uucp@groucho.sonoma.edu Sun Nov 8 15:40:29 1992 Received: from calvin.sfasu.edu by umaxc.weeg.uiowa.edu (5.61.jnf/920629) on Sun, 8 Nov 92 15:40:25 -0600 id AA01486 with SMTP Received: from mvax.Sonoma.EDU by calvin.sfasu.EDU with SMTP (5.59/25-eef) id AA05235; Sun, 8 Nov 92 15:34:41 CST Return-Path: Received: by mvax.Sonoma.EDU (5.57/Ultrix2.4-C) id AA03760; Sun, 8 Nov 92 13:32:18 -0800 Received: by groucho.sonoma.edu (NeXT-1.0 (From Sendmail 5.52)/NeXT-2.0) id AA20718; Sun, 8 Nov 92 13:29:49 GMT-0800 Received: by nvcc (NX5.67c/NeXT-2.0) id AA01817; Sun, 8 Nov 92 12:53:00 -0800 Date: Sun, 8 Nov 92 12:53:00 -0800 From: fozztexx%nvcc.uucp@groucho.sonoma.edu (Chris Osborn) Message-Id: <9211082053.AA01817@ nvcc > To: beejay@micor.ocunix.on.ca Cc: hyperc-l@calvin.sfasu.edu In-Reply-To: Basil Johnson's message of Sun, 8 Nov 1992 08:52:44 -0500 <9211081352.AA25369@micor.OCUnix.On.Ca> Subject: Traps - scanf Status: R Here's the manual entry on scanf from my NeXT. You may notice several differences in what you said HyperC scanf does and what it should do (like %s). ---------------------------------------------------------------------- NAME scanf, fscanf, sscanf - formatted input conversion SYNOPSIS #include int scanf(const char *format, ...); int fscanf(FILE *stream, const char *format, ...); int sscanf(char *s, const char *format, ...); DESCRIPTION Scanf reads from the standard input stream stdin. Fscanf reads from the named input stream. Sscanf reads from the character string s. Each function reads characters, inter- prets them according to a format, and stores the results in its arguments. Each expects as arguments a control string format, described below, and a set of pointer arguments indicating where the converted input should be stored. The control string usually contains conversion specifica- tions, which are used to direct interpretation of input sequences. The control string may contain: 1. Blanks, tabs or newlines, which match optional white space in the input. 2. An ordinary character (not %) which must match the next character of the input stream. 3. Conversion specifications, consisting of the character %, an optional assignment suppressing character *, an optional numerical maximum field width, and a conversion character. A conversion specification directs the conversion of the next input field; the result is placed in the variable pointed to by the corresponding argument, unless assignment suppression was indicated by *. An input field is defined as a string of non-space characters; it extends to the next inappropriate character or until the field width, if speci- fied, is exhausted. The conversion character indicates the interpretation of the input field; the corresponding pointer argument must usually be of a restricted type. The following conversion charac- ters are legal: % a single `%' is expected in the input at this point; no assignment is done. d a decimal integer is expected; the corresponding argu- ment should be an integer pointer. o an octal integer is expected; the corresponding argument should be a integer pointer. x a hexadecimal integer is expected; the corresponding argument should be an integer pointer. s a character string is expected; the corresponding argu- ment should be a character pointer pointing to an array of characters large enough to accept the string and a terminating `\0', which will be added. The input field is terminated by a space character or a newline. c a character is expected; the corresponding argument should be a character pointer. The normal skip over space characters is suppressed in this case; to read the next non-space character, try `%1s'. If a field width is given, the corresponding argument should refer to a character array, and the indicated number of characters is read. e,f,g,E,G a floating point number is expected; the next field is converted accordingly and stored through the correspond- ing argument, which should be a pointer to a float. The input format for floating point numbers is an optionally signed string of digits possibly containing a decimal point, followed by an optional exponent field consisting of an E or e followed by an optionally signed integer. [ indicates a string not to be delimited by space charac- ters. The left bracket is followed by a set of charac- ters and a right bracket; the characters between the brackets define a set of characters making up the string. If the first character is not circumflex (^), the input field is all characters until the first char- acter not in the set between the brackets; if the first character after the left bracket is ^, the input field is all characters until the first character which is in the remaining set of characters between the brackets. The corresponding argument must point to a character array. p indicates a hexadecimal value as produced by the %p pointer conversion of the printf-family of functions. The corresponding argument must be a pointer to a pointer to void. The result is only valid for a pointer converted during the same program execution. n No input is consumed. The argument must be a pointer to integer into which the number of characters read from the input stream so far is written. A %n directive does not increment the assignment count returned at the com- pletion of the function. The conversion characters d, o and x may be capitalized or preceded by l to indicate that a pointer to long rather than to int is in the argument list. Similarly, the conversion characters e or f may be capitalized or preceded by l to indicate a pointer to double rather than to float. The conversion characters d, o and x may be preceded by h to indicate a pointer to short rather than to int. The scanf functions return the number of successfully matched and assigned input items. This can be used to decide how many input items were found. The constant EOF is returned upon end of input; note that this is different from 0, which means that no conversion was done; if conversion was intended, it was frustrated by an inappropriate charac- ter in the input. For example, the call int i; float x; char name[50]; scanf("%d%f%s", &i, &x, name); with the input line 25 54.32E-1 thompson will assign to i the value 25, x the value 5.432, and name will contain `thompson\0'. Or, int i; float x; char name[50]; scanf("%2d%f%*d%[1234567890]", &i, &x, name); with input 56789 0123 56a72 will assign 56 to i, 789.0 to x, skip `0123', and place the string `56\0' in name. The next call to getchar will return `a'. SEE ALSO atof(3), getc(3S), printf(3S) DIAGNOSTICS The scanf functions return EOF on end of input, and a short count for missing or illegal data items. BUGS The success of literal matches and suppressed assignments is not directly determinable. --- Chris Osborn, Network Administrator Napa Valley College fozztexx%nvcc.uucp@groucho.sonoma.edu <- Preferred fozztexx@groucho.sonoma.edu NeXTMail ok at both