*BSD News Article 7102


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!uunet!kithrup!moria.cygnus.com!wilson
From: wilson@moria.cygnus.com (jim Wilson)
Subject: Re: mktemp - Bus Error.
Organization: Cygnus Support
Date: Tue, 27 Oct 1992 03:52:53 GMT
Message-ID: <1992Oct27.035253.8548@kithrup.COM>
References: <6607@otc.otca.oz>
Sender: news@kithrup.COM (Network News)
Nntp-Posting-Host: moria.cygnus.com
Lines: 15

In article <6607@otc.otca.oz> alexk@otc.otca.oz.au (Alex Kowalenko) writes:
>I'm having problems with mktemp failing due to a Bus Error.  Even a simple program like the
>        printf("%s\n",mktemp("XXXX"));

Mktemp modifies its argument, but you have passed it the address of a
read-only constant string.  Trying to write to a read-only constant gives
you a bus error.

The proper way to write this is
	char string[] = "XXXX";
	printf ("s\n", mktemp (string));

Jim Wilson
wilson@moria.cygnus.com