Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!sdd.hp.com!usc!apple!archer!dwb From: dwb@archer.apple.com (David W. Berry) Newsgroups: comp.unix.aux Subject: Re: Problem in sscanf with gcc-1.37 ? Keywords: sscanf gcc Message-ID: <9458@goofy.Apple.COM> Date: 27 Jul 90 16:24:05 GMT References: <2204@s3.ireq.hydro.qc.ca> Sender: usenet@Apple.COM Organization: Apple Computer Lines: 22 In article <2204@s3.ireq.hydro.qc.ca> lamarche@ireq.hydro.qc.ca () writes: What you're seeing is a side effect of the fact that gcc puts strings into text space. To defeat this you can specify the -fwritable-strings flag to gcc. >main () >{ > char works[] = "Works 1 2"; This allocates 10 bytes on the stack and then copies a string from text space to the stack space. Under most C compilers, it isn't even allowed... > char* fails = "Fails 1 2"; This allocates 4 bytes on the stack and puts a pointer to the string in text space in the stack space. Since the data that fails points to is not writable, when _doscan trys to do an ungetc, it fails with a buserror. David David W. Berry A/UX Toolbox Engineer dwb@apple.com