πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cs.forum
Article #2

Re: Help: a very segmentation fault!

#2
From: Kurt Watzka
Date: Sat, 13 Apr 1996 00:50
36 lines
1691 bytes
Fan.. ... ... wrote:
> 
> I'm a good man (mfchan@cs.cuhk.hk) wrote:
> > This is really the most strange thing I come across in C programming.
> 
> > main()
> > {
> >    char block[82];
> >    fp2 = fopen("fool", "r+b");

If that file does not exist or cannot be accesse for both reading and writing,
or if something strange happens to the stdio library, fopen() can fail. Using
a NULL pointer returned from fopen() in calls to other functions that expect 
a FILE pointer might lead to the observed behaviour.

> >    writeblock(fp2, 0, OVERFILE, block);

We cannot say much without knowing something about writeblock(). I assume that
it does something similar to

   fwrite(block, sizeof block, 1, fp);


> > }
> 
> > Need your help. Million Thks!
> 
> I've tried the program...  That's okay... except some syntax error...
> 
> One more thing...  What is your platform??  There's no "r+b" mode for
> fopen on unix systems...  Default mode is binary for all files.

There _is_ a "r+b" mode in ANSI C. Whether it does something different from
"w+" is up to the implementation.

Kurt
Technical Details
Message-ID: <316EFA39.2A6D@stat.uni-muenchen.de>
Path: arc1-ca.pugleaf.net!news.informatik.uni-muenchen.de!usenet
References: <4ki7gu$bgc@eng_ser1.erg.cuhk.hk> <4kinqm$hnt@eng_ser1.erg.cuhk.hk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.informatik.uni-muenchen.de!usenet
From: Kurt Watzka <watzka@stat.uni-muenchen.de>
Newsgroups: cs.forum,cuhk.se.3420,comp.lang.c
Subject: Re: Help: a very segmentation fault!
Date: Sat, 13 Apr 1996 02:50:01 +0200
Organization: Institut fΓΌr Statistik
Message-ID: <316EFA39.2A6D@stat.uni-muenchen.de>
References: <4ki7gu$bgc@eng_ser1.erg.cuhk.hk> <4kinqm$hnt@eng_ser1.erg.cuhk.hk>
NNTP-Posting-Host: pc4.stat.uni-muenchen.de
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.0 (WinNT; I)